Posts

Showing posts from May, 2011

C function to get data from a MySQL Database and store as a variable -

i able c function insert , update cell on table, having issues able value cell , have saved variable can use compare , calculations on it. thank in advance. void mia_get_data_temperature() { mysql_res *query_results = mysql_store_result(conn); mysql_row row; //this declare row variable //int total_rows = mysql_num_rows(query_results); int num_fields = mysql_num_fields(query_results); int i; char buffer[256]; // setting buffer query string const char *query = "select temperature `temperature` mode='current_temperature'"; //snprintf() - safer thatn sprint use //checking make sure query string not large buffer & formatting query passed if (snprintf(buffer, sizeof(buffer), query) >= sizeof(buffer)) { printf("issue buffer \n"); exit (-1); } //reading mysql table if(mysql_query(conn, buffer) !=0) { fprintf(stderr, "%s\n", mysql_error(conn));

ruby on rails - Mongoid ignores length validation on embedded document -

i have following model: class man < user field :surname, type: string, default: "" field :name, type: string, default: "" name_length = 1..50 validates :surname, length: {in: name_length}, allow_blank: true validates :name, length: {in: name_length}, allow_blank: true validates :father, length: {in: name_length}, allow_blank: true field :birthday, type: integer #timestamp field :about, type: string about_length = 2000 validates :about, length: {maximum: about_length}, allow_blank: true embeds_many :skills max_skills_count = 10 validates :skills, length: {maximum: max_skills_count} #user got unique skills index({login: 1, 'skills.caption_to_index': 1}, {unique: true, sparse: true}) end and embedded skills model: class skill include mongoid::document caption_length = 1..50 caption_filter = /[^a-zĐ°-ŃŹ0-9]/ field :caption, type: string field :caption_to_index, type

React Native (JSX) string replace -

is possible modify string in jsx? instance want search , replace string in image url. rendermovie: function(movie) { return ( <view style={styles.container}> <image source={{uri: movie.posters.thumbnail}} style={styles.thumbnail} /> <view style={styles.rightcontainer}> <text style={styles.title}>{movie.title}</text> <text style={styles.year}>{movie.year}</text> </view> </view> ); i want modify url here ( code taken here https://facebook.github.io/react-native/docs/tutorial.html#content ) movie.posters.thumbnail

javascript - Having trouble building a simple audio player in React using HTML5 -

i've started learning react , i'm trying build simple audio player. i'm using example reference it's built in 1 file https://github.com/cezarluiz0/react-cl-audio-player the 1 i'm trying make done in "react" way ui has reusable components i'm having trouble separating code meaningful , working components. example, if try move of rendering code parent component (audioplayer) (playbutton), audio methods created on mounting of parent component becomes inaccessible child components. here code repo. https://github.com/vincentchin/reactmusicplayer it works i'd improve it. it'd great if can point out huge flaws in since i'm sure i've broken rules or standards coding in react. you can access parent component's methods child component passing method prop, , invoking inside child component. for example (in child component's render method): <button onclick={this.props.methodfromtheparent}>click me</button

PHP classes to store table data, column name + type -

i getting error: using $this when not in object context $this->filterarray so change self::filterarray , error: unknown: non-static method abstract::filterarray() should not called statically i not sure if have correct or if should using abstract or interface? basically trying setup array(column_name => type) can use build basic insert forced data type: $cols = sentdao::describe(); foreach ($cols $col => $type) { if (!isset($data[$col])) continue; switch ($type) { case self::int: $value = intval($data[$col]); case self::text: $value = $this->escape($data[$col]); case self::date_now: $value = 'now()'; } $return[] = " {$col} = '{$value}'"; } i didn't want end creating hundreds of different objects , wanted keep simple stored in array. /** * abstract * */ abstract class accountsabstract { /** * data types */ const i

wordpress - How to add metabox.io inside posttype / postmeta? -

i try integrate metabox.io in own custom postmeta plugin, i tried move add filter code plugin file, add_filter( 'rwmb_meta_boxes', 'your_prefix_meta_boxes' ); function your_prefix_meta_boxes( $meta_boxes ) { $meta_boxes[] = array( 'title' => __( 'test meta box', 'textdomain' ), 'post_types' => 'post', 'fields' => array( array( 'id' => 'name', 'name' => __( 'name', 'textdomain' ), 'type' => 'text', ), array( 'id' => 'gender', 'name' => __( 'gender', 'textdomain' ), 'type' => 'radio', 'options' => array( 'm' => __( 'male', 'textdom

vba - Format specific text in Outlook -

i need format specific string value acquired excel in outlook. once value provided excel, macro append value in email message. i tried testing , setting value bold of contents of message became bold. how format value in such way can use font type, size , color liking? obj.htmlbody = "<b>" & stragnt & vbcrlf & obj.htmlbody see working outlook htmlbody option explicit sub createhtmlmail() 'creates new e-mail item , modifies properties. dim olapp outlook.application dim objmail outlook.mailitem set olapp = outlook.application 'create e-mail item set objmail = olapp.createitem(olmailitem) dim stragnt string stragnt = "<html><h2>the body html.</h2><body>type message text here. </body></html>" & vbcrlf & vbcrlf & _ "<p><font face=""comic sans ms"" size=""6"" color=""re

java - Center Justify Text in libgdx -

i have started libgdx , have figured out how center text it. having trouble center justifying text. wondering if can help. have attach code centering. thank in advance. package com.tutorials.game; import com.badlogic.gdx.applicationadapter; import com.badlogic.gdx.gdx; import com.badlogic.gdx.graphics.gl20; import com.badlogic.gdx.graphics.texture; import com.badlogic.gdx.graphics.g2d.bitmapfont; import com.badlogic.gdx.graphics.g2d.glyphlayout; import com.badlogic.gdx.graphics.g2d.spritebatch; public class textdemo extends applicationadapter { spritebatch batch; bitmapfont font; string mytext; glyphlayout layout = new glyphlayout(); @override public void create () { batch = new spritebatch(); font = new bitmapfont(gdx.files.internal("myfont.fnt")); mytext = "i took one, 1 cause left me\n" + "two, 2 family\n" + "three, 3 heartache"; layout.settext(font,

iOS app going to background after launch -

my problem follow when launch app, launch image appears few seconds , apps goes background. faced problem after updating ios 9.2.1 for solving problem delete app , reinstall it, works fine lost important data, not suitable solution. i search possible solution unable find help, please me solve problem. https://www.dropbox.com/s/gzdkm3tq4qfnovq/appcrash.mov?dl=0 this happen app when launch thank you are using application security software ixguard? had faced similar silent crash , due ixguard obfuscating uikit call sometime. one way resolve add uikit in blacklist array.

android - Display progress bar beside the text in ListView -

Image
i'm trying make listview progress bar image below i'm use android:layout_torightof display progressbar beside pro-xxx-xxx , display below text . <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <textview android:id="@+id/listproject" android:textstyle="bold" android:textcolor="@color/black" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <progressbar android:id="@+id/downloadprogressbar" style="?android:attr/progressbarstylehorizontal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:lay

rest - Web API 2 use Windows Authentication for public users -

how use windows authentication in web api internal users on public network? rest api public facing , need authenticate intranet users internet users. basically, not on active directory won't able access , 1 more ad groups authorized. the rest service @ moment has security filter validate token using attribute filter. public class restauthorizeattribute : authorizeattribute { private const string securitytoken = "token"; public override void onauthorization(httpactioncontext actioncontext) { if (authorize(actioncontext)) { return; } handleunauthorizedrequest(actioncontext); } private bool authorize(httpactioncontext actioncontext) { try { httprequestmessage request = actioncontext.request; //extract token request. work all. // e.g \api\facilitiles\token\298374u23lknndsjlkfds== // \api\ward\123\token\298374u23lknndsjlkfds==

python socket handle keepalive request -

i using python write simple web server, , sending requests it. , use libevent http client. every time send keep-alive request, http connection have close callback before success callback. think might keep-alive problem. , python(server) code: import socket host, port = '', 8999 listen_socket = socket.socket(socket.af_inet, socket.sock_stream) listen_socket.setsockopt(socket.sol_socket, socket.so_keepalive, 1) listen_socket.setsockopt(socket.sol_tcp, socket.tcp_keepidle, 60) listen_socket.setsockopt(socket.sol_tcp, socket.tcp_keepcnt, 4) listen_socket.setsockopt(socket.sol_tcp, socket.tcp_keepintvl, 15) listen_socket.bind((host, port)) listen_socket.listen(1) print 'serving http on port %s ...' % port while true: client_connection, client_address = listen_socket.accept() request = client_connection.recv(1024) print request http_response = """\ http/1.1 200 ok hello, world! """ client_connection.se

android - Square Image View on RecyclerView Item -

Image
i have square imageview left of recyclerview . how achieve this? hoping solution not hard coded. any idea please? <relativelayout android:id="@+id/containerview" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginleft="12dp" android:layout_margintop="12dp" android:layout_marginright="12dp" android:layout_marginbottom="12dp" android:padding="0dp"> <imageview android:id="@+id/profileimageview" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignparentleft="true"/> <textview android:id="@+id/nametextview" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginleft="12dp" an

sockets - How can I use asyncore with the multiprocessing IPC module in Python 3? -

i'm trying utilise client/server architecture of multiprocessing module facilitate communication between python scripts. want able implement separate connection listener apart main event loop, using asyncore . how can this? while there no outward documentation of how so, i've tried construct basic asyncore.dispatcher using listener socket multiprocessing.listener : import asyncore import socket multiprocessing.connection import listener, client class connectionlistener(asyncore.dispatcher): def __init__(self, ln): asyncore.dispatcher.__init__(self) self.set_socket(ln._listener._socket) def handle_accepted(self, sock, addr): print("accepted client!") if __name__ == "__main__": address = ('localhost', 19378) try: ln = listener(address) x = connectionlistener(ln) while true: asyncore.loop() except socket.error: c = client(address) print("clie

bash - unix sed command does not work -

i'm trying edit file called bookdb.txt contains boy:man:67.00:15:28 harry potter - order of phoenix:j.k.rowling:70.00:40:20 harry potter - half blood prince:j.k.rowling:40.00:50:20 this command sed -i "s/""$title""/""$newtitle""/g" ./bookdb.txt it works. want make sure edits exact string of $title, because if lets contains "a", letter in file changed. how use <\ \> in case ? a simple option try, since title begins @ beginning of line , delimited colon, this: sed -i "s/^""$title:/""$newtitle"":/g" bookdb.txt note ^ anchors match beginning of line, , : in both match , replacement section.

Encoding error PHP and MySQL for languages of Europe -

this question has answer here: utf-8 way through 14 answers i want insert word languages of europe mysql. e.g á , ó , Ö , ü .(sorry, don't know language is. maybe can me fix title.) but become can't read. i try solution how inserting french characters in mysql db table? i find out php version 5.1.6 . can't use mysql_set_charset mysql charset utf8_general_ci , version 5.0.45 . how can fix problem? db changes : change charset in db, tables + columns (yes! changing table charset not enough, have column column! took me long time figure out!) "utf8" change collation in db, tables + columns (really check every column) "utf8_slovak_ci" import data , check looks fine in db php changes : when querying, use "mysql_query('set character_set_results = utf8;');" prior select/update statements

Get Facebook User Email Using Graph API PHP SDK -

i'm using graph api of facebook php i'm trying user information login user site after lot of searching , reading i'm getting required data expect email. <?php include_once('../dashboard/includes/db_connection.php'); // added in v4.0.0 require_once 'autoload.php'; use facebook\facebooksession; use facebook\facebookredirectloginhelper; use facebook\facebookrequest; use facebook\facebookresponse; use facebook\facebooksdkexception; use facebook\facebookrequestexception; use facebook\facebookauthorizationexception; use facebook\graphobject; use facebook\entities\accesstoken; use facebook\httpclients\facebookcurlhttpclient; use facebook\httpclients\facebookhttpable; // init app app id , secret facebooksession::setdefaultapplication( '1393606834280204','3faf1ede6ccc48d6adf096f1a6850359' ); // login helper redirect_uri $helper = new facebookredirectloginhelper('http://lhefficise.com/facebook/fbconfig.php' ); try { $session = $hel

Split Multiple character in C# -

i want split each words in string? i write code string s1=" welcome our website,thanku." string s2= s1.split(",-.".toarray()); but isn't working. i believe want split on space , , , . , - , try: string[] splitarray = s1.split(',','-','.',' '); string.split returns array of string element, not single string element.

how to run java file using javascript and batchscript -

i want run java file using javascript. therefore took of batch file. when tried following code giving, page cannot displayed... can please possible... <html> <head> <script type="text/javascript"> function compression(str) { try{ alert("welcum"); wshshell = new activexobject("wscript.shell"); wshshell.run (str,1,true);} catch(e) { document.write("erro has occured "); } } </script> </head> <body> <a href="compression('explorer file:///c:\\documents , settings\\test.bat')">batch file</a> </body> </html> --------test.bat file------ @echo off cls javac *.java java lzwtut pause can try following <a href="compression('file://c:/test.bat');">batch file</a> also can try exec insted of run in compression function?

internet explorer - jQuery hasClass() not working in IE 11 , but works in Chrome and Firefox -

i have below piece of code works in chrome , firefox , in ie 10 , 11 , not working. also when open developer tools in ie ,it works correctly. can out? $("body" ).on( "click", ".js-save-request-meta", function(event) { event.preventdefault(); var el = $(this); var meta_value = el.data('meta-value') || $('input[name="meta_value"]').val(); if(el.hasclass('aspect-is-selected')){ $.post( "../ajax/delete_request_meta.php", {meta_value:meta_value,request_id:requestdata.request_id} ) .done(function( data ) { showmessage( data ); }); }else{ $.post( "../ajax/save_request_meta.php", {meta_value:meta_value,request_id:<?=$request['request_id']?> } ) .done(function( data ) { showmessage( data ); } }); }); try adding missin

java - How to serialize Out of the box bean -

we developing web application using adf. in application using classes available in third party jars. we using weblogic 11g cluster environment deploying application. while running application getting error log " object can not serialized ". getting error wherever trying use classes available in third party jar. now concern how serialize these classes? or there other way/ setting using can avoid error?

javascript - Twitter Bootstrap popover not working on first click -

i showing popover when click on anchor. popover not triggering on first click, how ever works on second click. html: <!-- pop check --> <div class="popover-markup"> <input class="checkbox-inline" type="checkbox" value="option1"> <a href="javascript:void(0)" class="trigger" data-placement="bottom" tooltip="manage users">option1</a> <!-- popup content--> <div class="content hide"> <div class="head hide">select users option1<span class="close_popover"><i class="fa fa-times"></i></span></div> <div> <label class="checkbox-inline"> <input type="checkbox" id="" class="si_dscm" value="user6"> user 6 </label> </div> </div> </div> js: $

jsf 2 - Equivalent of JSP scriptlet method call in JSF -

i need convert jsp file equivalent jsf file. jsp follows: step 1: class import: <%@ page import="org.keycloak.constants.serviceurlconstants" %> <%@ page import="org.keycloak.common.util.keycloakuribuilder" %> <%@ page session="false" %> <html> step 2: define variable: <% string logouturi = keycloakuribuilder.fromuri("/auth").path(serviceurlconstants.token_service_logout_path).queryparam("redirect_uri", "/customer-portal").build("demo").tostring(); %> step 3: refers variable: <a href="<%=logouturi%>">logout</a> the imported library external library project. in jsf, know how step 3. don't know how import classes in step 1 , how define variable shown in step 2 in jsf. is there equivalent way of performing step 1-3 in jsf? thank you. you can't call methods directly in jsf or create variables, therefore don't need i

javascript - How to stop execution for function with Userscript -

the website want write userscript has that: p.stream = p.class.extend({ . . . _processresponse: function(data) { if (!data.items || !data.items.length) { return null; } this.reached.start = data.atstart || this.reached.start; this.reached.end = data.atend || this.reached.end; var oldestid, newestid; if (this.options.promoted) { data.items.sort(p.stream.sortbypromoted); oldestid = data.items[data.items.length - 1].promoted; newestid = data.items[0].promoted; } else { data.items.sort(p.stream.sortbyid); oldestid = data.items[data.items.length - 1].id; newestid = data.items[0].id; } var position = (oldestid < this._oldestid) ? p.stream.position.append : p.stream.position.prepend; this._oldestid = math.min(this._oldestid, oldestid); this._newestid = math.max(this._newestid, newestid); var prev = null; var itemvotes = p.user.votecache.votes.items;

tcl - How do I run interactive shell such as "exec tclsh" from inside tclsh? -

is possible run interactive shell inside tclsh? it's easy run interactive shell such bash or tclsh inside bash, have not found way reverse. if run "exec tclsh" or "exec bash" inside tclsh don't prompt until type "exit" , hit enter, or use "ctrl-c" kills parent tclsh. i prefer not use external package, if @ possible. provided don't want pass values (other exit code) back calling tcl code can pretty redirecting standard channels tcl doesn't capture them: exec tclsh <@stdin >@stdout 2>@stderr this work pretty subprocess (i've tested vi ) , tclsh magically in interactive mode if decides try running subprocess. if want more complex that, need using expect there's long list of tricky gotchas otherwise.

java - Is it helpful to set the variable and object to null? -

i optimize code, , have little question. if this: textview currentconsole = (textview)findviewbyid(r.id.txt_mainactvt_currentconsole); string currentconsolename = currentconsole.gettext().tostring(); currentconsole = null; floatingactionbuttonclickevent(currentconsolename); is set objects null way, or useless? the garbage collector tracks references objects, , when there no pointer object marked deletion. no deleted immediately. when write currentconsole = null; tell gc console object should deleted , on next garbage collection. to optimize can call system.gc(); trigger collection, gc might chose ignore there no guarantee console object delete after null assignment. the garbage collection interval calculated in run-time depending on number of objects , frequency of new allocations, best thing can let gc job, in cases best thing. and null assignments in general, yes useful in rare cases, consider code void testgcmethod() { //create big object verybigob

Bad gateway errors at load on nginx + Unicorn (Rails 3 app) -

i have rails (3.2) app runs on nginx , unicorn on cloud platform. "box" running on ubuntu 12.04. when system load @ 70% or above, nginx abruptly (and seemingly randomly) starts throwing 502 bad gateway errors ; when load less there's nothing it. have experimented various number of cores (4, 6, 10 - can "change hardware" it's on cloud platform), , situation same. (cpu load similar system load, userland 55%, rest being system , stolen, plenty of free memory, no swapping.) 502's come in batches not always. (i run 1 unicorn worker per core, , 1 or 2 nginx workers. see relevant parts of configs below when running on 10 cores.) i don't know how track cause of these errors. suspect may have unicorn workers not being able serve (in time?) looks odd because not seem saturate cpu , see no reason why wait io (but don't know how make sure of either). can you, please, me how go finding cause? unicorn config ( unicorn.rb ): worker_proces

html - javascript one input field connect to several functions -

i'm new programming , have problems. i'would create 1 form (in html , javascript), can calculations. numbers , years. @ first need put input field, can type year (like 2013). input value connected several functions: calculating difference current year (if ask 2018 should write 5, or if ask 2000 iz shoul write -13 , on...) check if year leap year (true/false or yes/no, ...) calculate sum of numbers ask (2018 = 11, 2013=6, ...) if number prime number (true/false, yes/no, ...) reverse number (2013 = 3102, 2018=8102, ...) show chinese zodiac sign year convert year roman numerals (1=i, 2=ii, 10=x, ...) i did find function, can't put work. helpful if can this. examples find on internet: function isleap() { var yr = document.getelementbyid("year").value; if ((parseint(yr) % 4) == 0) { if (parseint(yr) % 100 == 0) { if (parseint(yr) % 400 != 0) { alert("not leap"); return "false

php - Doctrine2 dont want to insert the columns in the table -

here insert query, how can tell that, created_at (current time-stamp), is_active (default 1) set in mysql db structure needs taken. when omit $question->setcreatedat($this->createdat); in insert operation shows me integrity constraint violation , know issue? in questions table: question: id question created_by created_at modified_by modified_at is_active entity: <?php namespace library\entity; use doctrine\orm\mapping orm; /** * base class entities * class maps id, active, created , modified columns * * @author */ /** * @orm\mappedsuperclass */ class baseentity { /** * @orm\id * @orm\generatedvalue * @orm\column(name="id", type="integer") * @var integer */ protected $id; /** * @orm\column(name="is_active", type="boolean") * @var boolean */ protected $active; /** * @orm\column(name="created_at", type=&

powershell - Show-Command cmdlet layout -

i'm experimenting powershell show-command cmdlet . i discovered parameters shown in alphabetic order (except mandatory ones @ top). there way keep param() order or position ( [parameter(position=0)] ) order ? also, there way show default values?

numbers - Compare x ='' and x = 0 in Javascript -

i have following: var = 0; if (number(a) != '') { alert('hi'); } i never alert though not empty, 0 , need value numeric calculations. enter code here what's going on here? the != operator type conversion if needed, '' converted numeric value 0 . you can use !== operator avoid type conversion: var = 0; if (number(a) !== '') { alert('hi'); }

sockets - Java: measure network bandwidth for a specific code segment -

i want add bandwidth measurements servers (written in pure java). thinking of api like measurebandwidthsignletone.getinstance().startmeasuring(); ...... .....//here may connect db or using http (httpurlconnection)... ..... measurebandwidthsignletone.getinstance().endmeasuring(); problem have many different kinds of code access network (jdbc, httpurlconnection, ftp, etc...) wondering if can somehow attach threadlocal monitor sockets, allow me know how many bytes uploaded or download. i know 1 way using asm / aspectj change byte code - there simpler way plug in java socket api? thank you what setting custom made socketfactoryimpl? can work? that work specific version of jvm. if know version targeting create modified version of class. the reason won't work generic jvm class uses internal apis can different between versions why byte code injection more work broad range of jvms.

c# - Calling .Dispose() on a class that has a Finalizer -

according essential c# 6.0 should: avoid calling dispose() on owned objects have finalizer. instead, rely on finalization queue clean instance. could please elaborate on i'm not clear on point of dispose if we're not call owned objects? apart reflection, how figure out if object has finalizer ? how figure out when call close() / close() + dispose() other searching api documentation (if have access , exists) or reflection? see lot of questions around net specific types ( memorystream / form / sqlconnection / etc ) i'm looking more @ "how figure out yourself". according dispose pattern should: consider providing method close(), in addition dispose(), if close standard terminology in area. when doing so, important make close implementation identical dispose , consider implementing idisposable.dispose method explicitly. but there times when should call both form , etc. questions " close , dispose - call? " close there&#

sparql - Pellet internalReasonerException in OWL API -

have been stuck 1 day , kind enough help? have loaded ontology imported sweet(semantic web earth , environmental ontology). did sparql query on it, , got such answer: "object property haslowerbound used hasvalue restriction value literal: "0"^^integer". (haslowerbound, have checked in sweet, datatype ontology in sweet) how can solve problem? here code wrote , error got,thank help~ public class load { public static void main(string[] args) throws owlontologycreationexception { // hold of ontology manager owlontologymanager manager = owlmanager.createowlontologymanager(); file file = new file("g:/protege/owlfiles/before_gather.owl"); // load local copy owlontology loadmodis = manager.loadontologyfromontologydocument(file); pelletreasoner reasoner = pelletreasonerfactory.getinstance().createnonbufferingreasoner( loadmodis ); knowledgebase kb = reasoner.getkb(); pelletinfgraph graph = new

java - Android Tabbed Activity Bottom off Screen -

Image
anybody idea why bottom off screen in new generated tabbed activity in android? viewpager long total screen <android.support.v4.view.viewpager android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> result views in child fragments off screen 55dp if align them bottom of screen. thanks, paul p.s.: full xml of generate code: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssys

css - Positioning last child drop-down menu in wordpress? -

Image
the drop-down menu works fine on theme have little problem last-child submenu fix text position cannot move top nearby submenu , how remove transparency background last child submenu concept below: css drop-down menu .navbar-default { box-shadow: 0 2px 10px rgba(0,0,0,0.67); background: #fff; background: url(data:image/svg+xml;base64,phn2zyb4bwxucz0iahr0cdovl3d3dy53my5vcmcvmjawmc9zd…ixiibozwlnahq9ijeiigzpbgw9invybcgjdg9wvg9cb3r0b21hcmfkawvudckilz48l3n2zz4=); background: -moz-linear-gradient(top, #fff 0, #e6e6e6 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(100%, #e6e6e6)); background: -webkit-linear-gradient(top, #fff 0, #e6e6e6 100%); background: -o-linear-gradient(top, #fff 0, #e6e6e6 100%); background: -ms-linear-gradient(top, #fff 0, #e6e6e6 100%); background: linear-gradient(to bottom, #fff 0, #e6e6e6 100%); width: 100%; height: 44px; border-width: 0 0 1px; border-s

c++ - Why does Mat.forEach doesn't change itself? -

Image
basically, i'm trying use less pixels represent image itself. the steps below: say input image size [1000*600], got 600_000 pixels(rgb), [600_000, 3] vectors. k-means used cluster centers. the each pixel in image placed nearest neighbor among clusters found via k-means. the source is: template <typename t> void nn(point3_<t>& pixel, const mat& points) { vector<t> vt {pixel.x, pixel.x, pixel.z}; double min_dist = ldbl_max; int min_index = -1; (int = 0; < points.rows; ++ i) { double dist = norm(vt, points.row(i), norm_l2); if (dist < min_dist) { min_dist = dist; min_index = i; } } // assert(min_index != -1); pixel.x = points.at<t>(min_index, 0); pixel.y = points.at<t>(min_index, 1); pixel.z = points.at<t>(min_index, 2); } template <typename t> void nn(mat& img, const mat& points) { timer::start("assi