Posts

Showing posts from April, 2015

c++ - How are state flags represented and how bitwise OR is used to work with bit flags? -

if open file reading, may define 1 or more state flags, example: ios::out ios::out | iso::app i read bitwise or, , how "merges" 2 bit sets, for example: 1010 | 0111 = 1111 now being said, not understand how works "behind scenes" when use method ifstream.open(filename, stateflaga | stateflagb | stateflagc) , on. can elaborate more on inner workings of these state flags , memory representation? edit: give more emphasis on trying understand (if helps), assume open method receive 1 or more state flags separate arguments in signature, , not delimited bitwise or, want understand how bitwise or works on these state flags produce different final state when combining several flags, , result allows me use 1 argument state flag or set of state flags. ie: ifstream.open(filename, stateflaga | stateflagb | stateflagc) and not ifstream.open(filename, stateflaga , stateflagb , stateflagc) if take gnu libstdc++ implementation , @ how these implemented,

mongodb - Check if value exist into array field mongoid rails -

i have groups field in mongodb database "groups" : "[\"5514efcc6970640f40150100\", \"5514efcc6970640f40160100\", \"5514efcc6970640f40170100\", \"5514efcc6970640f40180100\"] please suggest query check if field exist above database array. like modelname.find(:groups=> 5514efcc6970640f40150100) looks have string in groups , not array. string looks called inspect on array of bson objectids in ruby , stored stringified array in mongodb. the leading double quote here: ⬇ "groups" : "[\"5514efcc6970640f40150100\", ... ⬆ tells you have string. inside string have looks array of strings still string. if that's have think you're stuck regex searches (which slow), like: model.where(:groups => /"5514efcc6970640f40150100"/) that assumes groups strings consistently formed , stringified arrays of hexadecimal strings. if case i'd suggest fi

python - If statement deleted by else statement in Tkinter -

i'm creating dictionary myself in tkinter , when added else statement (for query isn't in dictionary) deleted first if statement (index). i don't know why. entry (exe) works without problems else , index works else deleted. def search_button(self, event=none): if self.entry.get() == 'index': self.search_result.set("alea jacta est") if self.entry.get() == 'exe': self.search_result.set("lorem ipsum") else: self.search_result.set("entry not in database.") your 2nd if should elif : def search_button(self, event=none): if self.entry.get() == 'index': self.search_result.set("alea jacta est") elif self.entry.get() == 'exe': self.search_result.set("lorem ipsum") else: self.search_result.set("entry not in database.") the problem code if entry text 'index' search_result set "alea jacta

Searching for a list of words within a Tkinter text widgit in Python 2.7 -

i've been trying button check on tkinter gui search entered text text widget specific word , make appear red, i've managed using following code: list_of_words = ["foo", "bar`enter code here`"] def check(): global counter text.tag_remove('found', '1.0', end) idx = '1.0' x = 0 while true: idx = text.search(list_of_words[x], idx, nocase=1, stopindex=end) if not idx: break lastidx = '%s+%dc' % (idx, len(list_of_words[x])) text.tag_add('found', idx, lastidx) idx = lastidx text.tag_config('found', foreground='red') counter += 1 print counter however need able search input words on list_of_words list , display them red. there way of doing this? your code not increment x so, if first word present, while loop never terminate. does, however, increment global variable counter no apparent reason. why not iterate on list of target words loop? inner while loop se

opencv - Draw convex hull on android -

i try draw convex hull on image.for this, find contours , select max area contour. drawcontours accepts matofpoint convexhull gives me matofint . read question , run codes. of them draw convex hull, cannot find convex points. i use below code, has runtime error on last line m.fromarray(hullpoints.get(i)); . hullpoints.get(i) has 1 point , code cannot create matofpoint object. how can convert matofpoint matofint ? // find convex hull list<matofint> hull = new arraylist<matofint>(); for(int j=0; j < contours.size(); j++){ hull.add(new matofint()); } for(int j=0; j < contours.size(); j++){ imgproc.convexhull(contours.get(j), hull.get(j)); } // convert matofint matofpoint drawing convex hull // loop on contours list<point[]> hullpoints = new arraylist<point[]>(); for(int j=0; j < hull.size(); j++){ point[] points = new point[h

jquery - loop through text and replacing * with span -

i struggling script should replace text , make bold via css. but problem is, script isn't looping. takes first text. can me out? here's my fiddle . and here's code $(document).ready(function (i) { $('.main:contains("*")').each(function () { $(this).html($(this).html().replace('*', '<span class="highlight">')); $(this).html($(this).html().replace('*', '</span>')); }); }); this 1 trick: $(document).ready(function (i) { function replace(o) { $(o).html($(o).html().replace('*', '<span class="highlight">')); $(o).html($(o).html().replace('*', '</span>')); if ($(o).html().indexof("*") >= 0) { replace(o); } } replace('.main:contains("*")'); });

html - not splitting div's properly -

this has been posted before, couldn't find solution searching. i'm new html , css started ~1 week ago, if there solution explanation go long way rather modified code/solution. so attempting split div 2 columns 1 of 25% width , other 75% width. haven't started doing css yet hence why styling inline @ moment. general div of 100% width displays fine when try split 2 inner div's seems work list trying create displays correctly next column of 75% appears below div. why , there anyway fix it. <div style="width:100%;background:orange"> <div style = "text-align:center;width:25%;background-color:red;"> list <ul> <li> something</li> <li> something</li> <li> something</li> <li> something</li> <li> something</li> </ul> </div> <div style="width:75%;background:purple;">

AngularJS: A page calls my angularjs-page with form POST data -

Image
how call angularjs page totally different, not mine, , caller page uses post form-data. there needed special web server setup on side, or can angular handle incoming post request totally without server side logic on side (so angular-page can served anywhere, simple file server dropbox)? you mean angular page angular page communication? angular runs in browser, want client client communication. have build around server yourself. easiest way use websockets. client sends message server -> server sends message target client -> client receives message or client sends message server -> server stores message , waits client pick -> client picks message server if mean page x calls angular page via post request. your angular page communicates server time. should not try catch post request page inside angular (you can't anyways), have catch on server , somehow load appropriate page angular logic kicks in. you cant catch post requests in browser, on serve

php - Pagination not display in magento advance search -

i have issue of pagination , filter in advance search page otherwise filter , pagination works in other pages search, category , subcategory. don't why it's not working advance search page. working url : http://homefurnituretrading.co.uk/index.php/bedroom-furniture/wooden-beds.html not working url: http://homefurnituretrading.co.uk/index.php/catalogsearch/advanced/result/?manufacturer[]=164 you have not added handle catalogsearch_advanced_result layered navigation. open catalog.xml file find catalog_category_view handle category page , find whithin reference left block layered navigation. so need add left block in following layout handle <catalogsearch_advanced_result> <reference name="left"> <!-- add block here found in handle catalog_category_view --> </reference> </catalogsearch_advanced_result>

Gitlab - Can't add ssh key -

i have installed gitlab using aur on archlinux server. working well, except can not add ssh keys. i error fingerprint cannot generated . in log got started "/profile/keys/new" my.ip.on.arch @ 2015-03-28 13:13:52 +0100 processing profiles::keyscontroller#new html completed 200 ok in 159ms (views: 110.9ms | activerecord: 8.8ms) started post "/profile/keys" 92.157.142.177 @ 2015-03-28 13:13:58 +0100 processing profiles::keyscontroller#create html parameters: {"utf8"=>"✓", "authenticity_token"=>"wx7vmjy1ftk9xuwc7ol5zt5irmqbbu22hjjvpfh6iby=", "key"=>{"title"=>"my@email", "key"=>"ssh-rsa aaaab3nzac1yc2eaaaadaqabaaabaqdetfmjbxe8lzga4ywto82deh6ajyvoit3l8emteynpzed0wvdeky2tzt8vhwkstjj90e14usuxaromaewyqqdahs3lym5dzlen/vxfsucncux3dpjfxjaefr9z9/bqdhwxwcf9cdwlgiixz8u91hs4k2rxpt4q746jzce/oywlbo1mibaqd1mmkmf8d3jpj9+jxat2c2u83dpeaz4aim+m0jv3x6miqreehgfrig2lmes16mw/y638zk3wz

python - What is the structure of a vim .swp file? -

an application wants shell text out vim , know edits being made, in real time. the .swp file provides information. can provide guidance on how read binary file, say, python? i wouldn't rely on swapfile contents real-time updates. format geared towards vim's uses, , format isn't documented other implementation. have duplicate large parts of algorithm, , maintain whenever internal format changes (without prior notice). alternatively, use 1 of embedded languages (e.g. python) interface outside program wants real-time updates. python function periodically send along entire buffer contents on socket, example.

asp.net mvc - Is OData suitable for a big MVC5/WebAPI application -

i working following stack mvc5 + webapi 2.2 + ef6 + angularjs web application. today, tried incorporate odata , angular breezejs application , worked fine 1 of entities. currently, have around 45 tables translate 45 model classes. in web api, have have 5-10 controllers handle crud operations 45 models using switch statement based on variables pass entityname , operationname . but, in odata need 45 controllers scaffold-ed vs. there way can use benefits of odata such querying/paging/patching without having create controller each model class ? do work entity framework ? if so, can try restier. restier built upon web api odata , , need 1 controller make basic crud (including queries) work. you can learn more tutorial http://odata.github.io/restier/getting-started-part-1/ , sample northwind locates @ https://github.com/odata/restier/tree/master/src/microsoft.restier.samples.northwind .

c# - GetString from Byte[] producing different after sending through socket -

so using c# sockets send string 1 process another. send string using byte array. when use getstring(byte[]) in each process during debugging different results when values in byte array same point of debugger. in process send string socket same string when using getstring(). gibberish after receiving data on other size. to send string use: string strtosend = "this test"; byte[] stringbytes = system.text.encoding.ascii.getbytes(strtosend); int32 stringsize = stringbytes.length; int32 messagelengthinbytes = sizeof(byte) + sizeof(int32) + sizeof(int32) + stringsize; byte[] message = new byte[messagelengthinbytes]; message[0] = (byte)messagetype.sendstring; unsafe { marshal.copy((intptr)(int32*)&messagelengthinbytes, message, 1, sizeof(int32)); marshal.copy((intptr)(int32*)&stringsize, message, 5, sizeof(int32)); gchandle pinnedarray = gchandle.alloc(stringbyte

z index - geoJSON layer order leaflet -

i have problem geojson layer order in leaflet. have 3 polygon layers in leaflet, geojson, overlay. i'm not able figure out, how set layer order. i've tried autozindex: true/false - didn't work. after toggling layer visibility reordered , i'm unhappy :( below part of code. i'm begginer, glad help. thanks, dan var povoden_5q = l.geojson(povoden_5q_diba, {style: style, oneachfeature: oneachfeature}); var povoden_20q = l.geojson(povoden_20q_diba, {style: style, oneachfeature: oneachfeature}); var povoden_100q = l.geojson(povoden_100q_diba, {style: style, oneachfeature: oneachfeature}); map = new l.map('mapa', { layers: [topo, povoden_5q] }); var podklad = { "letecký snímek": ortofoto, "topografická mapa": topo } var overlay = { "záplavové území pětileté vody": povoden_5q, "záplavové území dvacetileté vody": povoden_20q, "záplavové území stoleté vody&qu

java - Cron Expression To List of Dates/Timepoints -

i wondering efficient way/best library parse cron expression , return list of time points in java. for example have cron expression, say, fire every minute in october 2010 , list/array of epoch times (or other date format) returned correspond times trigger fires. thanks you use org.quartz.cronexpression.getnextvalidtimeafter() . using method can iteratively many trigger times wish. you have decide starting point of iteration, current moment or epoch or smth else. and can parse string cron expression org.quartz.cronexpression using constructor cronexpression(string cronexpression) . edit: can find similar functionality in spring framework's cronsequencegenerator . both used in similar iterative fashion check 1 suits best regarding performance etc.

php - How to use function in one class in another -

im newbie in oop. have file database.php class database{ function db_row($con,$stuff,$table,$statements){ return mysqli_fetch_array(mysqli_query($con,"select {$stuff} `{$table}` {$statements}")); }} and have file player.php class player{ function get_id($con,$token){ }} and want use function db_row-class database(file database.php) in class player(file player.php) how can this? you try below. basically, instantiate database object in player 's constructor, can access methods in database inside player shown below. <?php class database{ function db_row($con,$stuff,$table,$statements){ echo "success"; //return mysqli_fetch_array(mysqli_query($con,"select {$stuff} `{$table}` {$statements}")); }} class player { var $db; function __construct() { $this->db = new database(); } function get_id($con,$token){

sprite kit - How to detect in touchesEnded which nodes are still being pressed -

i've been stuck on problem days. have multiple skspritenode's, 1 left arrow, right arrow , arrow. when hold down right arrow want character continue moving right while being held down, on other hand if press arrow jump once regardless of if hold down. problem example when hold right arrow , press arrow, touchesended called , stops character moving right though still have finger on right arrow -(void) touchesbegan:(nsset *)touches withevent:(uievent *)event { [super touchesbegan:touches withevent:event]; (uitouch *touch in touches){ cgpoint location = [touch locationinnode:self]; if (cgrectcontainspoint(rightarrow.frame, location)){ [wizard settexture:[sktexture texturewithimagenamed:@"wizardright"]]; didtouchrightarrow = yes; islookingright = yes; islookingleft = no; rightarrow.alpha = 0.5; nslog(@"touching right"); } if (cgrectcontainspoint(leftarrow.frame, location)){ [wizard settexture:[sktexture texturewi

javascript - Kendo UI/jQuery redirect after verification -

i'm coding hybrate mobile app telerik product, appbuilder. have follow problem: this code: $('#search-btn').on("click", function () { var barcode = document.getelementbyid("product-search-id"); if (barcode.value == 3800048307270) { window.location.href = "../views/scan-view.html#activia-light-yogurt-blueberry"; } }); but when select product barcode 3800048307270 , click search, window.location.href doesn't redirect me ../views/scan-view.html#activia-light-yogurt-blueberry . if write web url in window.location.href redirect me. i'm sure set right path.

asp.net - itemTemplate item id not existing in code behind -

i trying create textboxes equal number of rows in grid view (databound db). here markup <asp:gridview id="quizgrid" runat="server" cssclass="grid" autogeneratecolumns="false"> <columns> <asp:boundfield datafield="admissionno" headertext="admission no"/> <asp:boundfield datafield="studentname" headertext="name" /> <asp:templatefield> <itemtemplate> <asp:textbox runat="server" id="marks" > </asp:textbox> </itemtemplate> </asp:templatefield> </columns> but when use marks in code behind says quizgrid_marks_0 not exists in current context what im doing wrong here? you can't access textbox in code behind file, rather need find th

Download file from a link that redirects c# -

i'm quite new c# , need download file link: http://www.addic7ed.com/original/94097/1 problem keeps redirecting me page got url from. ( original url ) couldn't manage webclient neither httpwebrequest, maybe me doing wrong. hints on how this? even tried this edit: more specific, url supposed download .srt file , when click on chrome. however, when try download .srt file through c# being redirected , end downloading site's html source. how can replicate chrome's behavior? edit2: managed importing webclient headers webbrowser. still interested in other ways it, tho. 1 seems durty me. this behaviour happening on server side, not client side - ie, it's not c# problem. can url request fine using curl . maybe try setting different user-agent string on webclient or httpwebrequest objects, if can that?

paperclip - Rails 4, Simple Form, accepts_nested_attributes_for, Dropzone image upload -

is there way has_many association (user --> uploads) work nested form? have strong params working fine. users can have 5 images uploaded. using accepts_nested_attributes_for in model , uploading working, there gotchas. but example when try edit user, , build new images using: (5 - @user.uploads.count).times { @user.uploads.build } ...it builds 5 upload entries within nested form, no matter what. form section looks this: <%= f.simple_fields_for :uploads |i| %> <hr> <% user.uploads.each |upload| %> <% if upload.image? %> <%= image_tag(upload.image.url(:medium), class: 'img-rounded').html_safe %> <br> <%= i.input :_destroy, as: :boolean, label: false, inline_label: 'remove picture', wrapper_html: { class: 'text-center' } %> <% end %> <% end %> <%=

objective c - Disable WiFi with CWWiFiClient -

it appears cwinterface deprecated in 10.10 yosemite, , has been replaced cwwificlient . in cwinterface use setpower method disable wifi, not know of similar method in cwwificlient . does know how disable wifi cwwificlient ? thanks. get cwinterface instance this: let _en: cwinterface! = cwwificlient.sharedwificlient().interface() and can use setpower method disable wifi again!

javascript - adding textInput values to another text input using js function in Yii 2 -

simply i'm trying add value of text input fields : http://jsfiddle.net/mak2k/1/ my form code : <?php $script = <<< js $('#amount_value_id').keyup(function(){ var amountsum=0; $('#amount_value_id').each(function(){ if (this.value != "") amountsum+=parseint(this.value); }); // alert('foo'); $("#totalamount").text(amountsum); //console.log(amountsum); }); js; $this->registerjs($script); ?> <?php $form = activeform::begin(["id" => "project-form"]); ?> <?php foreach ($project $i => $project) { ?> <div class="col-lg-2 col-md-3" id="amount_value_id"> <?= $form->field($project, "[{$i}]amount")->textinp

processing - Get the envelope of a signal in Matlab -

i don't know how compute envelope of signal. i've seen mathwork solutions firstsolution secondsolution not work in signal i'm working with. this signal provides pressure sensor , it's sampled @ frequency of 1khz , has 100000 samples. i've read hilbert transform envelope doing abs(hilbert(data)) being data values of signal2.txt has not work. i've tried taking absolute value of analytic signal has not work either. the solution i've tried find peaks , put them linearly not work because want continuous , derivable function result need derivate it. i hope knew solution problem. :)

html - JavaScript undo onclick action? -

i have html checkbox. uses onclick javascript event increment integer var 1. i want decrement var 1 if checkbox unchecked. how can this? $('.checkbox').click (function(){ var thischeck = $(this); if ( thischeck.is(':checked') ) { // increment } else { // decrement } });

c - Not even my main fuction runs -

i cant print "main" on screen. seems none of code runs. when dont specify command line arguments in prints out warning. input file contains integers on each line. #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> #include <semaphore.h> #include <sys/types.h> int patientcount,treatedpatientcount,maxpatient,allregistered; int *list; file *input,*output; sem_t semoutputfile,semglobalvars; void* nurse(); void* doctor(void *); int main( int argc, char *argv[] ){ printf("main"); if(argc != 3){ printf("command line argument count different expected. aborting!"); return -1; } input = fopen(argv[1],"r"); output = fopen(argv[2],"w"); allregistered = 0; maxpatient = 5; treatedpatientcount = 0; patientcount = 0; list = malloc(sizeof(int)*maxpatient); pthread_t nurse,doc1,doc2; sem_init(&semglobalvars,

java - How to set validation context with annotations -

imagine i've action myaction , field user getters , setters. then have 2 exposed public methods want use visitor validation object user 2 different contexts, user validated in 2 different ways, depending on method has been called. i want annotations only, no validation.xml. see example public class myaction extends actionsupport { private user user; public user getuser() { return this.user; } public void setuser(user user) { this.user=user; } public string execute() { //some code here ... return success; } @validations( visitorfields = {@visitorfieldvalidator(context="mycontext1", fieldname="user", key="error.message", message="a default error message", shortcircuit=true)} ) public string save() { //some code here ... return success; } @validations( visitorfields = {@visitorfieldvalidator(context="mycontext

Android Navigation Drawer Icon reverting to default when Drawer is open -

i'm having problem navigation drawer icon. replaced default "back caret" use different icon , works fine. however, if navigation drawer open , user rotates device, icon reverts default caret , won't go custom 1 until navigation drawer closed , oncreate() method activity called again (usually rotating device). here code: @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_start); // set toolbar action bar toolbar toolbar = (toolbar) findviewbyid(r.id.my_awesome_toolbar); toolbar.setnavigationicon(r.drawable.ic_drawer); setsupportactionbar(toolbar); if (savedinstancestate == null) { getsupportfragmentmanager().begintransaction() .add(r.id.container, new startfragment()) .commit(); } //init gamelog gamelog.init(this); } /** * initializes drawerlayout particular activity */ public static void init

c# - How to construc Inbox per user in database -

please, have have in mind don't know if best. if want construct private message, think inbox should new table in database. right? have not seen tutorial in internet shows how construct one. please, can point me right direction. public class inbox{ public int id {get;set;} //other properties }

ios - How to register custom CollectionViewCell? -

i have been far using uitableviews successfully, can't uicollectionview working. @interface newscollectionviewdatasource : nsobject <uicollectionviewdatasource, uicollectionviewdelegate> -(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { tncollectionviewcell *newscell = nil; newscell = [collectionview dequeuereusablecellwithreuseidentifier:newscellreuseidentifier forindexpath:indexpath]; if (!newscell) { [[nsbundle bundleforclass:[self class]] loadnibnamed:@"tncollectionviewcell" owner:self options:nil]; } newscell.newslabel.text = [[self newsforindexpath:indexpath] headline]; return newscell; } everytime everytime line: newscell.newslabel.text = [[self newsforindexpath:indexpath] headline]; newscell nil. am registering wrong? somewhere before retrieving cells collectionview (i.e. in viewdidload ) call following method of uicollectionvie

javascript - nested arrays with ng-repeat and table html -

i want take json place html table. "columns" : [ { "id" : 0, "column_name" : "column 1", "cards" : [ { "id" : 0, "task" : "task 1" }, { "id" : 1, "task" : "task 2" } ] }, { "id" : 1, "column_name" : "column 2", "cards" : [ { "id" : 0, "task" : "task 3" } ] }] i have done quite bit of searching on , cannot find why not doing expect. https://jsfiddle.net/6nh100ca/9/ this expecting. **column 1 | column 2** task 1 | task 3 task 2 | https://stackoverflow.com/a/20063394/3279550 http://www.bennadel.com/blog/2456-grouping-nested-ngrepeat-list

java - How to find the last element in an under capacity array? -

say array defined this: int [] p = new int[10]; p[0] = 1; p[1] = 4; p[2] = 7; i know use arraylist , not worry resizing, want know how 1 find index of last element (7) in array. tried , failing because can't compare int null. how else go doing this? int tail=0; for(int i= 0; < p.length; i++){ if(a[i]==null){ tail= i-1; break; } } check out this code : import java.util.arrays; class intarrayexample { public static void main(string[] args) { int[] p = new int[10]; p[0] = 1; p[1] = 4; p[2] = 7; system.out.println(arrays.tostring(p)); int tail=0; for(int i= 0; < p.length; i++){ if(p[i]==0){ tail= i-1; system.out.println("tail : " + tail); break; } } } } output: [1, 4, 7, 0, 0, 0, 0, 0, 0, 0] tail : 2 as can see print array , int array initialised zeros . tail 2 in case. if want have elements value of zero in array

html - Make right div within container responsive -

i have 2 divs in container, 1 in center , 1 right. want width of right div responsive . currently, max-width on centered 1 works. see jsfiddle . how make right div responsive too? html: <div id="container"> <div id="middle">centered</div> <div id="right">make me responsive</div> </div> css: #container { width: 100%; text-align: center; position: relative; } #middle { background: #ddd; margin: 0 auto; position: relative; width: 100%; max-width:300px; height:300px; display: inline-block; vertical-align: top; } #right { background:yellow; width:100%; max-width:300px; display: inline-block; vertical-align: top; position: absolute; } @media screen , (max-width: 350px) { #right { display: none; } } the idea use flexbox . , add pseudo element left column, in order make middle 1 in center existing markup.

How can I solve this type mismatch in Scala? -

def balance(chars: list[char]): boolean = { if (chars.isempty == true) true else transcount(chars, 0) def transcount(chars: list[char], pro: int): boolean = { var dif = pro chars match { case "(" :: nil => false case ")" :: nil => dif -= 1; if (dif == 0) true else false case _ :: nil => if (dif == 0) true else false case "(" :: tail => dif += 1 transcount(tail, dif) case ")" :: tail => dif -= 1; if (dif < 0) false else transcount(tail, dif) case _ :: tail => transcount(tail, dif) } } } i have type mismatch problem error:(30, 13) type mismatch; found : string("(") required: char case "(" :: nil => false ^ but not know how fix (do not use char.tolist please) chars declared list[char] . however, first pattern "(" :: nil , list[string] because "(" string - hence type mismat

java - Singleton networking object gives error on second call -

communication class of singleton object created: import java.net.*; import java.io.*; import java.util.scanner; public class communication { private static communication minstance = null; private static final string request_login = "login"; private bufferedoutputstream socketoutput = null; private printwriter printout = null; private socket socket = null; private scanner reader = null; private communication() { //connect server using loopback address try{ socket = new socket("127.0.0.1", 4242); //set inputs , out puts socketoutput = new bufferedoutputstream(socket.getoutputstream()); printout = new printwriter(socket.getoutputstream(), true); reader = new scanner(socket.getinputstream()); } catch( unknownhostexception uhe){ uhe.printstacktrace(); } catch( ioexception ex){ ex.printstacktra

asp.net - How to completely remove toggle button bootstrap -

i want remove toggle button in navbar. site on asp.net , bootstrap 3. want remove it, when browser window resizes, menu items should stay in places. just add these css: .navbar-collapse.collapse { display: block!important; } .navbar-nav>li, .navbar-nav { float: left !important; } .navbar-nav.navbar-right:last-child { margin-right: -15px !important; } .navbar-right { float: right!important; } here's jsfiddle above codes: http://jsfiddle.net/andrewl32/t4ym3/49/

android - Alarm Manager goes off as i click the Button -

i have code set on button sets alarm manager send broadcast , activate wifi on device. have set delay 1 min code alarm goes off click button here's code on button: public void start(view view){ alarmmanager alarm = (alarmmanager) getsystemservice(alarm_service); intent intent1 = new intent(this,myreceiver.class); pendingintent turnwifi = pendingintent.getbroadcast(getapplicationcontext(), 0, intent1, 0); long milli = 60000; alarm.set(alarmmanager.rtc,milli,turnwifi); } the code in receiver: public class myreceiver extends broadcastreceiver{ @override public void onreceive(context context, intent intent) { log.i("broadcastreceiver","------------>in on receive method<-------------"); wifimanager wifi_man = (wifimanager) context.getsystemservice(context.wifi_service); wifi_man.setwifienabled(true); } in alarm.set(alarmmanager.rtc,milli,turnwifi); milli pas

Is R compatible with windows 8.1 64bit edition? -

i have installed latest version of r official site however when open it takes time open. have tested in windows 7 64bit edition , opens fast. is there known , common problem windows 8.1?

php - How to know a USB device's supporting function? -

i want figure out how usb device works. lets have scanner. when start scanning there must command being given windows device in order start scanning , transfer data. want know how work ? , there way can list of usb device's supporting commands ? can execute these commands , take data directly php ? usb complicated subject, not possible teach need know in single stackoverflow answer. there lots of things learn such control transfers, descriptors, interfaces, , endpoints. can learn them reading official usb 2.0 specification, or summary of it. once know stuff, can @ device descriptors using utility lsusb , , might tell lot commands device supports. if device implements standard class defined in usb specification, can read document find list of commands. if not, contact manufacturer documentation, or might need usb protocol analyzer , reverse engineering.

git - How to deploy different subsets of a repo -

i have project many plugins , keep them in 1 git repository, because consist of 1 file each: plugins +-- +-- b +-- c +-- d +-- e i want deploy software different production systems , of them should different combinations of plugins. let's say, a, b, d , c, e , b, c, d . if change plugin upstream, want update easy possible on production systems. there .gitignore file "do not check files out!"? or how can without creating own git repository each file? it seem easier isolate deployment mechanism in script able deploy right script right environment. if keep using git on production (which isn't ideal), same script activated automatically on checkout each plugin, , determine (again dependent on deployment environment somehow detects) copy file or not. this called content filter driver , not prevent files appear in <yourgitrepo/plugins> : deployment environment should expect find plugin in other place (other git repo itself), in order give chanc

EXCEL. How do i find all the rows matching the values on a different row n a different file? -

Image
i have 2 .xls files. 1 of files has column named "customer id" witch contains 700 8 digit values such 11557096. other file has column named "requested for" includes 2000 values customer id plus / name such 11557096 - john doe. find rows on second file match customer id's on "customer id" column on "requested for" column. here simple filter example can start with. the set up sub button1_click() dim rws long, rng range, filtrng range rws = cells(rows.count, "a").end(xlup).row set rng = range(cells(2, 1), cells(rws, 2)) application.screenupdating = 0 rng.autofilter 1, range("d1") set filtrng = rng.offset(1) filtrng.copy sheets("sheet2").cells(rows.count, "a").end(xlup).offset(1, 0) activesheet.autofiltermode = 0 end sub the filter result paste next sheet. the sample workbook once have going can work on different sheets , different workbooks.

Tidy with PHP - output <link>, <style> and <script> elements without explicit type? -

i'm testing tidy php add 'human' layout view of given html page once it's sent browser (it's generated in compressed form default), have problem. every <link> element rel attribute set stylesheet gets type="text/css" appended @ end. same goes <style> element, behaves in same fashion. <script> element gets type="text/javascript" appended. while it's fine me, filter these bits out, , know if there's option in tidy configuration (i've been reading option list in tidy website haven't found suggesting me such filtering) or must filtering manually like: $output = str_replace([" type=\"text/javascript\"", " type=\"text/css\""], ["", ""], tidy_parse_string($input, $options, "utf8")); is there better filtering procedure one?

android - Trouble understanding LatLngBounds using GoogleMaps in AndroidStudio -

i have coordinates of current location , trying find out how ne , sw corners current location on google maps using latlngbounds. i don't seem understand how implement latlngbounds api google has written here: https://developers.google.com/maps/documentation/business/mobile/android/reference/com/google/android/m4b/maps/model/latlngbounds if explain me latlngbounds , how use great. please let me know if need add more information clear up. thank you. a latlng point; latlngbounds rectangle. @ minimum, construct latlngbounds, need 2 latlngs: 1 southwest corner of rectangle, , 1 northeast corner of rectangle. given 2 points, other 2 points of rectangle trivially computed. its not clear question why need latlngbounds. should need if plan put imagery onto map, or draw type of rectangle. if want show marker or infobox don't need latlngbounds. if plan use groundoverlay show image centered upon latlng point, more complicated think. have use geolocation mappin

java - Play JPA - Error: Removing a detached instance -

i'm using play framework 2.4 , got error: [illegalargumentexception: removing detached instance models.account#8] in: (...)\models\account.java jpa.em().remove(this) my code looks this: profilecontroller : http://pastebin.com/embed_iframe.php?i=257pthm4 account : http://pastebin.com/embed_iframe.php?i=wn1wchni i tried (as suggested many other answers similar questions): jpa.em.remove(jpa.em().merge(this); or jpa.em().remove(account.findbyid(this.id)); or adding @transactional delete() function. but both result in rollbackexception: error while committing transaction . update - solution: it mixture of 2 problems: i missed line in console output saying there constraint table , account cannot deleted. the account instance returned component.currentaccount() detached instance , fixed with: account current = jpa.em().merge(component.currentaccount()) only guess: object tree must in sync database structure. if remove jpa con

What are the conventions in Dart about class members' encapsulation and type annotations? -

i new dart language. know more conventions programmers follow while developing in language. should encapsulate class members do, example in java? whenever create property of class, should make private , provide getters/setters? or there situations when should leave them public? if so, examples of these situations? in opinion, type annotations such string, int, etc. increase readability of code. serve documentation other developers reading/using code. programmer should not think value of type storing in variable right now. again, situations, require using var keyword when declaring variable? dmitry. thank you. thanks checking out dart! no need encapsulate class fields. dart creates implicit getters , setters you. if need compute field, can implement getter or setter manually. bonus: doesn't break consumers of api. example: class person { int age; } later, want calculate age: class person { datetime birthdate; int age => new datetime.now().di

javascript - How would I use a data-attribute in HTML to fill a link and image source with a link from a database? -

i have database has table column called "link" holds link such " http://www.google.com ", , column called "image" holds " http://www.placehold.it/500x500 ". i have following html: <a href="" data-field="link"> <img src="" data-field="image"> </a> i have php backend uses json , jquery plugin retrieve , populate information don't know how fill href"" , src"" attributes specifically. how can jquery/javascript? is the thing want? $("a[data-field='link']").attr("href",yourvalue); $("img[data-field='image']").attr("src",youranothervalue);

Detecting amount of shifts in Caesar Cipher? in C -

i wondering how in caesar cipher 1 detect amount of shifts in encrypted text file read program , display amount? thank you! edit** read in smalldictionary file argv[2]. rotate function: int rotate(int c, int n){ if (n == 0) return c; int nrot = abs(n) % (rangechar + 1); if(n > 0) return rotateplus(c + nrot); else return rotateminus(c - nrot); } int main( int argc, char *argv[]){ file *fp = stdin; // defaults int n = 13; int shift; int = 0; // process command line switch(argc) { case 2: // have n, assumed input stdin n = atoi(argv[1]); break; case 3: // have n , input file fp = fopen(argv[1], "r"); // should check problems n = atoi(argv[2]); break; default: fp = stdin; n = 13; } // rotate text int c; while( (c = fgetc(fp)) != eof){ if(!isspace(c)){ c= rotate(c,n); } i++; printf("%c", c); } fclose(fp); } you need distribution data language (presumably english) come in form of array int lang_distribution[26] . have make array, int

Ruby / Rails Groups only Adjacent Array Elements -

i have sorted array full of objects i'd group attribute, if they're adjacent in array. a sorted start attribute. a = [{name: "joe", start: "9am", end: "10am"}, {name: "joe", start: "10am", end: "11am"}, {name: "harry", start: "11am", end: "12pm"}, {name: "harry", start: "12pm", end: "1pm"}, {name: "harry", start: "1pm", end: "2pm"}, {name: "joe", start: "2pm", end: "3pm"}, {name: "joe", start: "3pm", end: "4pm"}] i group adjacent objects name attribute results looks like: a = [[{name: "joe", start: "9am", end: "10am"},{name: "joe", start: "10am", end: "11am"}], [{name: "harry", start: "11am", end: "12pm"},{name: "harry", start: &qu

mysql - Different page for different users using PHP -

i want know how user 'mckenzie' see own unique page can manipulate , 'wendy' see own page when logs in. i've created login , pages, connected them mysql database given them id's etc, can of , know sessions etc. ;) so can tell me how this, have make different pages each separate user? i'm thinking along lines of register page: store data in database, user id , use "?pageid=1" take user id based page. but i'm not sure how make each page without making them manually, can imagine making new page each separate user pain... , inefficient. ideas? and please show me example code, appreciated! thank in advance! my answer assuming want create customizable user data added possibility of sharing page between users (like profile page). out of way can creating 1 php page searches mysql table $_get or $_post data. ill expand answer in couple of steps... sql tables the first thing need mysql set-up, ill assume have basic set-u

How to make an object in java to be called from outside Bluej -

i'm entering studing programming in college, , give me homework create 1 app in java actualy identify different types of triangles acording sides they'll receive. i'm fine that, i'm trying understand , write part call others methods , show results outside bluej. can gave me last method , explain me little bit how works? i need see actual working code learn how , when make objects classes, , how connect methods ones. the console returning me error: non-static variable base cannot referenced static context update: returning me: '.class' espected in part of code: ... public static void main (int args[]){ triangle obj1 = new *triangle(int[]* args); system.out.print(obj1.trianglecheck()); } } note: parte between " " shows error exist, " " not part of actual code itself. note2: see after "update" see on actual context. also, if of out there tell me how improve code woulde too, i'm new in o

ssl - Java https server -

i building application server in java using httpserver class. have server functioning using plain text communication on http. however, wish upgrade using ssl, using httpsserver class. used question basis work from: simple java https server my server class follows: public server(options options){ sslcontext sslcontext = null; try { server = httpsserver.create(new inetsocketaddress(8080), 0); sslcontext = sslcontext.getinstance("tls"); char[] password = options.getsslpassword().tochararray(); keystore ks = keystore.getinstance ("jks"); fileinputstream fis = new fileinputstream (options.getsslkeystore()); ks.load ( fis, password ); keymanagerfactory kmf = keymanagerfactory.getinstance ( "sunx509" ); kmf.init ( ks, password ); trustmanagerfactory tmf = trustmanagerfactory.getinstance ( "sunx509" ); tmf.init ( ks ); sslcontext.init ( kmf.getkeym

javascript - Knockout JS Json get -

i newbie @ knockout.js , have question. found code here . function returns {"id":"1", "name":"cardio", "image":"aslas", "header":"kardio", "message":"message\r\n"} not working. can me? <ul class="folders" data-bind="foreach: folders"> <li data-bind="text: $data, css: { selected: $data == $root.chosenfolderid() }, click: $root.gotofolder"></li> </ul> <div class="mails" data-bind="with: chosenfolderdata"> <p><label>from</label>: <span data-bind="text: name"></span></p> </div> <script> function webmailviewmodel() { // data var self = this; self.folders = ['cardio', 'classic', 'mass', 'abs'] ; self.chosenfolderid = ko.ob

c++ array of objects, failed initialization -

this question has answer here: cin , getline skipping input [duplicate] 4 answers need project school using arrays of class objects. can't use vectors, answers suggesting them not help. ive been trying create such , array, put name in each object. ive tried running loop this, , keeps skipping first object in array. help? #include <iostream> #include <cstring> using namespace std; class car { private: char* driver; public: void setdriver(char* name) { driver = name; } void getdriver() { cout<<driver; } }; int main() { int numdrivers; cout<<"how many drivers like?"; cin>>numdrivers; car* roster = new car[numdrivers]; for(int i=0;i<numdrivers;i++) { char* name; name = new char[20]; cout<<"name:"; cin.getline(name, 20); roster[i].setdriver(name); } for(int