Posts

Showing posts from August, 2013

printing - How to take printout from android app? -

hi in application want take printout webview page i.e html page.can tell me did mistake.my problem code running in emultor not in other devices. mainactivity.java: package com.example.print1; import android.os.build; import android.os.bundle; import android.annotation.suppresslint; import android.annotation.targetapi; import android.app.activity; import android.webkit.webview; import android.webkit.webviewclient; import android.print.printattributes; import android.print.printdocumentadapter; import android.print.printmanager; import android.content.context; @suppresslint("newapi") public class mainactivity extends activity { private webview mywebview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.web_print); webview webview = new webview(this); webview.setwebviewclient(new webviewclient() { public boolean shouldoverrid...

running multiple FFmpeg instances to encode udp stream gives error -

please me fix problem below i trying encode multiple udp streams in hls format. run 1 one instance (process) of encoding on system. application working fine , able encode, receive , play streams using player running on stb (set top box). encoding ok till running 5 th instance. when started running 6th encoding instance on system, stream output starts freezing in 6 encoded outputs. i using intel xeon based server 24 cores , 32gb of ram. here ffmpeg build info. ffmpeg ffmpeg version n-61057-gec6d043 copyright (c) 2000-2014 ffmpeg developers built on mar 4 2014 05:33:48 gcc 4.6 (debian 4.6.3-1) configuration: --prefix=/root/ffmpeg-static/64bit --extra-cflags='-i/root/ffmpeg-static/64bit/include -static' --extra-ldflags='-l/root/ffmpeg-static/64bit/lib -static' --extra-libs='-lxml2 -lexpat -lfreetype' --enable-static --disable-shared --disable-ffserver --disable-doc --enable-bzlib --enable-zlib --enable-postproc --enable-runtime-cpudetect --ena...

ruby on rails - where to define name of s3 bucket for different env while using fog gem -

i uploading paperclip attachment s3 in model using fog credentials this... problem need have different bucket name different env, defining bucket in model gets specific every env, else can define it. has_attached_file :news_logo, :storage => :fog, :fog_credentials => "#{rails.root}/config/s3.yml", :fog_directory => "s3-bucket-name" config/s3.yml development: provider: aws aws_access_key_id: xyz aws_secret_access_key: xyz path_style: true you can use rails.env in order customize bucket name, like: has_attached_file :news_logo, :storage => :fog, :fog_credentials => "#{rails.root}/config/s3.yml", :fog_directory => "s3-bucket-name-#{rails.env}" you can like: has_attached_file :news_logo, :storage => :fog, :fog_credentials => "#{rails.root}/config/s3.yml", :fog_directory => (case rails.env when 'production' 'my-production-bucke...

c# - Register All Classes Manually or there is an automatic way? -

i using asp.net mvc 5. new autofac. have lot of classes , each class have do, builder.registertype<authenticationservice>().as<iauthenticationservice>(); builder.registertype<iauthenticationrepositry>().as<authenticationrepositry>(); ............................................................................... ............................................................................... registering each type time-consuming , quite forget-able. there automatic way register components in autofac? if want automatically register types as interfaces , can use registerassemblytypes : builder.registerassemblytypes(typeof(mvcapplication).assembly).asimplementedinterfaces(); or asself , if want resolve concrete implementations.

jquery - start and stop ajax auto refresh -

am developing school e-learning- forums module. posts loaded in <div id="posts"></div> using function: var refreshcon = setinterval( function() { $('#postcontainer').load('new/posts.php', function() { }); },5000); a text box -add new response- inside <div id=""></div> and refreshed rest of data. have added function <input type="text" onfocus="stopcounter()"/> [stop counter clearinterval(refreshcon); , working]. problem is. can't start autorefresh again onsubmit of form. jquery , not friends. please show me simple function start , stop auto refresh @ will. in advance you can use these functions:- to start:- function start(){ refreshcon = setinterval(function(){ $('#postcontainer').load('new/posts.php', function(){ }); }, 5000); } to stop:- function stop(){ try{ clearinterval(refreshcon); }catch(err)...

c++ - Draw ArcCtg ( x ) plot -

i don't how draw graph function: y = arcctg( x ).. i'm not @ math that's i've done far: void drawgraph() { double x,y,z; float xmin=0, xmax=m_pi, ymin=0, ymax=m_pi; // glpushmatrix(); glbegin (gl_line_stipple); (x = xmin; x <= xmax; x+=0.1) { (y = ymin; y <= ymax; y+=0.1) { y = atan(x); y = m_pi_2 -y; //that transform arctan( x ) actan (x ) guess.. glvertex3f (x, y, -1); } } glend (); //glpopmatrix(); } when run program it's not responding : - (... appreciated. thanks! you following: for (y = ymin; y <= ymax; y+=0.1) { y = something; } this create endless loop (unless something > ymax , not in case). imagine following: for (a = 0; <= 10; a++) { = 5; } use variable inside loop instead of y, , you'll fine.

camera - Android name image programatically -

i want give custom name image captured through camera programatically. have used snippets of codes given here how control/save images took android camera programmatically? still doesn't work , image stored default name. idea why? i'd grateful. public class mainactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button camerabutton = (button) findviewbyid(r.id.takepicture); camerabutton.setonclicklistener( new onclicklistener(){ public void onclick(view v ){ //intent intent = new intent("android.media.action.image_capture"); //startactivityforresult(intent,0); intent intent = new intent(mediastore.action_image_capture); uri muri = uri.fromfile(new file(environment.getexternalstoragedirectory(), "pic_...

algorithm - Find all M-length sets of positive integers that sum to N -

the problem i'm trying solve how find integer sets [a1, a2, ... ,am] that a1 + a2 + ... + = n and constraint ai >= 1 for example if m = 4, , n = 7 there 3 answers [1,1,1,4] [1,1,2,3] [1,2,2,2] since have print sets sum n. can employ complete search algorithm using recursion. in following code, m number of numbers in set , n sum required. int m; int n; void run(){ m = 4; n = 7; int[] arr = new int[m]; print(arr, 0, n, 1); } // req holds required sum numbers in array arr[from] // arr[m-1]. // "last" holds last value had put in array. // first call array last=1. void print(int[] arr, int from, int req, int last){ // reached end of array , sum required 0. if(from==m && req==0){ system.out.println(arrays.tostring(arr)); return; } // either reached end of array sum not eq...

segmentation fault in C during scanf -

i trying scan in integer use program. program gives me segmentation fault during compilation section giving me error: int main(void) { int totalheight=0, floorwidth=0, amountofstories, amountwindowfortop, amountwindowformiddle, amountwindowforbottom, windowheight, middlewindowwidth, topwindowwidth, bottomwindowwidth, minimumheight, minimumwidth; char topfloorwindowcontent, middlefloorwindowcontent, bottomfloorwindowcontent, windowborder, floorborder; int tempmax; printf("please enter how many stories building have: "); scanf("%d",&amountofstories); minimumheight=amountofstories*6+1; while((totalheight<minimumheight)||((totalheight%amountofstories)!=1)) { printf("please enter totalheight (minimum %d): ",minimumheight); scanf("%d",&totalheight); } printf("please enter how many window building have top floor: "); scanf("%d",amountwindowfortop); pr...

C# preprocessor-like protection -

i wondering either possible create rule in c# inside code, prevent "compiling" , print error message of choice. example: let's say: i have method takes argument bytes vector. inside method check what's length of byte vector. if it's long, short etc prevent program compiling , print error message in error list. i know use assertion , stuff, working on compiled code. i answer no because compiler (at compilation time) can't know value of parameter @ run time. have nice day, alberto edit: check first comment question because it's more complete answer compared 1 :)

Can't login to SharePoint 2013 site on server machine? -

i working on sharepoint 2013 server on premise. surprisingly, not able log in @ sharepoint 2013 site on server side, when allowing me log in on same site same credentials on local machine. what may issue? adding backhostconnectionnames should help. click start, click run, type regedit, , click ok. in registry editor, locate , click following registry key: hkey_local_machine\system\currentcontrolset\control\lsa\msv1_0 right-click msv1_0, point new, , click multi-string value. type backconnectionhostnames, , press enter. right-click backconnectionhostnames, , click modify. in value data box, type host name or host names sites on local computer, , click ok. i don't remember if iis reset necessary.

c# - Facebook Login works in localhost but not in webhost -

i have class listed below: public class facebookscopedclient : iauthenticationclient { private string appid; private string appsecret; private string scope; private const string baseurl = "https://www.facebook.com/dialog/oauth?client_id="; public const string graphapitoken = "https://graph.facebook.com/oauth/access_token?"; public const string graphapime = "https://graph.facebook.com/me?"; private string gethtml(string url) { string connectionstring = url; try { var myrequest = (httpwebrequest)webrequest.create(connectionstring); myrequest.credentials = credentialcache.defaultcredentials; //// response webresponse webresponse = myrequest.getresponse(); stream respstream = webresponse.getresponsestream(); //// var iostream = new streamreader(respstream); string pagecontent = iostream.readtoend(); ...

javascript - angularJS - ng-if and ng-model -

i trying display field based on value of select in angular app. should simple: when newjob.country === 'remote' want 'city' field disappear: html: <body ng-app> <div class="form-aside"> <label>location</label> <select ng-model="newjob.country" class="form-control"> <option>remote</option> <option>france</option> <option>uk</option> </select> </div> <div class="form-aside" ng-if="newjob.country !== 'remote'"> <label>city</label> </div> </body> for reason it's not working. here plunker: http://plnkr.co/edit/gcjneps9zvkejniattiw?p=preview how can make work? thanks you need define value for each <option> tag. then need use ng-show != dynamically display label or n...

java - Colored Table Cells -

i want color table cells according value in column 1, if values isn´t equal value in column 1 color should cyan, code doesnt work: table = new jtable(){ public tablecellrenderer getcellrenderer(int row, int column) { tablecellrenderer tcr=null; color c; if(column>=1&&getvalueat(row, column)!=null &&getvalueat(row, 1)!=null &&!getvalueat(row, column).equals(getvalueat(row, 1))) c=color.cyan; else c=color.white; if(getvalueat(row, column) instanceof boolean) { tcr= super.getdefaultrenderer(boolean.class); } else { tcr= super.getcellrenderer(row, column); } tcr.gettablecellrenderercomponent(this, getvalueat(row, column), iscellselected(row, column) , hasfocus(), row, column).setbackground(c); return tcr; } publi...

javascript - jQuery Datepicker issues with minDate & maxDate -

currently using following code in order setting date picker functionality - $("#datepicker").click(function() { $(this).datepicker().datepicker( "show" ); }); but if remove "show" parameter. doesn't work , want add more parameters mindate , maxdate . please how can "show" parameter. thanks in advance!! you can pass options like $("#datepicker").click(function () { $(this).datepicker({ maxdate: yourmaxdate, mindate: yourmindate }).datepicker("show"); }); i don't know why using click handler initialize datepicker.... can do $("#datepicker").datepicker({ maxdate: yourmaxdate, mindate: yourmindate }); demo: fiddle after plugin initialization, if want update value of options, can use option method $("#datepicker").datepicker('option', 'optioname', optionvalue)

Magento open a site in new tab by javascript -

how can opens new tab in magento using javascript call other site? when use this, new window opens: var w = window.open('/offerte/<?php echo $debiteur ;?>.pdf','_blank','fullscreen=yes'); you want open url in new tab code running? giving _tab creates new tab. var w = window.open('/offerte/<?php echo $debiteur ;?>.pdf','_tab','fullscreen=yes'); same window.open("http://www.youraddress.com","_self") new tab window.open("http://www.youraddress.com","_tab") i hope of examples can out problem.

In TYPO3 6.1, how to configure CSC content fallback only for images -

Image
in dual-language (single-tree) typo3 6.1, have regular texpic content element. tsconfig: mod.web_layout.deflangbinding = 1 typoscript: config.sys_language_overlay =1 temp.lead < styles.content.get temp.lead.select.where = colpos = 2 how can tell css_styled_content use image main language if no other image specified? setting config.sys_language_mode = content_fallback won't help, want images fall back, no text. the original image appearing in localised record, greyed out: there hidden button right of entry editors can use localise file reference: once localised, reference works expected.

python mask for different size numpy array -

i have 3 numpy arrays: x numpy array 2 dimensions (height , width), example: 1000x2000 y numpy array 2 dimensions (height , width), example: 1000x2000 img numpy array has 3 dimensions: (height, width, rgb) example: 1000x2000x3 i've created mask of x , y, example: mask = [y[:,:]>100, x[:,:]>50] , i've created sum of these masks: masks = mask[0] & mask[1] now want select x, y , img parts depending on mask: x_ = x[masks] y_ = y[masks] this works fine, want same selection img , doesn't work since 3 dimensional array. how use mask select same "fields" x , y? have tried indexing in same way? believe should work fine. >>> = arange(24).reshape(2,4,3) >>> mask = arange(8).reshape(2,4) < 5 >>> a[mask].shape (5, 3)

objective c - store value in array -

hi new in objective c. have 3 text field. have store value in 1 dictionary , dictionary in 1 array every time when clicked on button @ time every text field's value stored in dictionary , dictionary stored on next index of array. so can 1 me code given below: [fnamedict setvalue:textfield1.text forkey:@"first name"]; [fnamedict setvalue:textfield2.text forkey:@"last name"]; [fnamedict setvalue:textfield3.text forkey:@"roll number"]; [userinfoarray addobject:fnamedict]; nslog(@"%@",userinfoarray); nsmutablearray *arr=[[nsmutablearray alloc] init]; then create dictionary assign values per keys , save in array like [arr adobject:fnamedict]; then can access arr according index. make sure allocation should 1 array.

playframework 2.0 - Excluding unmanaged dependencies from universal:packageBin in sbt-native-packager? -

i have external lib directory jars. need these included in classpath in order compile , test project not want include them in distributed zip file generated via universal:packagebin (in sbt-native-packager ) (or dist if you're using playframework . i attempted using provided scope follows: unmanagedbase in provided := new java.io.file("/external/lib") but doesn't seem work advertised - jars don't seem included in compile scope. i using sbt 0.13.1 . this works (thanks @jacek-laskowski improvements answer): mappings in universal := (mappings in universal).value.filter { case(jar, _) => jar.getparentfile != unmanagedbase.value } but, still feels kludge, prefer if sbt (and sbt-native-packager ) support provided scope scenario meant for.

html - More than one email content comes as blank page in php -

i trying send approx 100 mail @ time using php. using following code $this->view->dataset['title'] = $title; $this->view->dataset['message'] = $message; ob_start(); $this->view->render('emailcontent', 'escalation-question-email-module-content', false); $emailcontent= ob_get_contents(); ob_end_clean(); $emailparam = new stdclass(); $emailparam->sendto = $email; $emailparam->subject = $title; $emailparam->content = $emailcontent; $this->sendmail($emailparam); the above code iterating approx 100 times through foreach loop. facing odd problem first mail shows html content , other 99 mail content appears blank page. i replaced ob_get_contents() function file_get_contents() working have use ob_get_contents() function. can please identify wrong code. try bringing ob_start() right @ beginning of script.

c# - Rewrite rules into web.config for js and png files -

i have application asp.net, web api c# , used https , want js, css files , images sent http. try different thinks didn't work. i've tried this: <rewrite> <rules> <rule name="redirect image http"> <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/> <action type="redirect" url="http://{server_name}/{r:1}" redirecttype="seeother"/> </rules> </rewrite> what doing wrong? try this <rules> <rule name="redirect image http"> <match url=".*\.(gif|jpg|jpeg|png|css|js)$"/> <action type="redirect" url="http://{server_name}/{r:1}" redirecttype="found"/> </rules>

html - Relative parent ignored with absolutely positioned children -

i know there lot of questions positioning out there, including absolute positioning inside relative parent. i've read many of these questions , found informative link on css-tricks ( absolute positioning inside relative parent ). after troubleshooting fails, turn ;) this jsfiddle contains think right, isn't. why child elements of parent div positioned relative body , not div? code: <div id="editorwrapper" style="posotion: relative; width:751px; height:250px; margin-left: 20px; margin-top: 20px; border: 1px solid blue;"> <a class="lnk" href="http://www.google.be" style="display: inline-block; position:absolute; left: 1%; top: 1%; padding: 5% 5%;"></a> <a class="lnk" href="http://www.google.be" style="display: inline-block; position:absolute; left: 80%; top: 80%; padding: 10% 10%;"></a> <div style="position: absolute; padding: 10px; left: ...

c# - How to count seconds and then use them in a conditional? -

i newbie programmer , i've been trying deal problem on 2 hours now. want program count seconds , if gets past second second (what?), something, example show "game over" or that. problem is, program doesn't after these 2 seconds have passed. might problem ? edit: ok here whole info behind this. user has press key corresponding character shown on screen in 2 seconds. if user doesn't press key in 2 seconds or presses wrong key, game has over, doesn't work expected lol here whole code far (yes know goto sucks , change loop later): using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.globalization; using system.threading; using system.diagnostics; class game { static void main() { start: console.cursorvisible = false; random rnd = new random(); int row = rnd.next(1, 80); int col = rnd.next(1, 25); int chars = rnd.next(0, 62); ...

hadoop - Getting the following error when trying to run a hive query -

hive> select count(1) stage; failed: runtimeexception java.net.connectexception: call server1/ipaddress server2:8020 failed on connection exception: java.net.connectexception: connection refused; more details see: http://wiki.apache.org/hadoop/connectionrefused i new hive. please me. looks job tracker down. can check using command: sudo jps

java - Glassfish: Why are there 2 pools for the same MDB: one in ejb and one in war? -

scenario: i have java maven ear project run on gf 3.1.2. in project want use mdb defined in individual ejb module put dependency. structure follows: projectear: - projectejb - projectwithproblematicmdb - projectwar - dependency projectejb scope provided actual problem: when deployed glassfish, of jconsole, see 2 different mdb pools problematicmdb: 1 in ejb module , 1 in war module. not same pool since have set deployment descriptor on projectejb limit pool size 1 , pool's size in projectejb doesn't larger 1 one in projectwar grows in size. this happens mdbs=s modules referred in projectejb dependencies, not happen "native" mdbs projectejb. must mention fact cannot exclude projectwithproblematicmdb war since using beans there (not mdb) . the question(s): why there 2 pools same mdb? how can have 1 pool in scenario? i found reason , solution. reason: looking .ear archive saw "native" ejb (projectejb) place...

Android: Programmatically validate google map key in Application -

i have application end-user can input own google map key , show map. have proper way check if key isn't empty, problem check if map key valid before showing map. i assume user can input wrong key, valid google key app. is there way detect that? i know people check proper log in logcat don't think it's best way. any appreciated. thanks if got right, want validate if user's key working. (i dont think can validate other things) i create little progressdialog or ui element indicates "validating api key" , make user wait until has been done. validate api ke performing simple request api key. if there no "simple" api key can determine if key valid can create map hidden , initialize user's key described in answer: mapactivity: set apikey programmatically validation method can work map , call functions. when exception thrown know key not valid.

python - Porting Angular to DJango Web (1.0) style: Calling functions from Django Template -

i new django , task need accomplish port of angularjs old school web 1.0 django application (for older browsers). there 1 unknown dealing , functions associated $scope in angular. don't know how replicate logic in django. an example (in angular): <div ng-show="isauthorizedas('administrator')"></div> and in controller: $scope.isauthorizedas = function(functionalrole) { if($scope.user.role == 'basic'){ if(functionalrole == 'basic') return true } else if($scope.user.role == 'advanced'){ if(functionalrole == 'basic') return true if(functionalrole == 'advanced') return true } else if($scope.user.role == 'administrator'){ if(functionalrole == 'basic') return true if(functionalrole == 'advanced') return true if(functionalrole == 'administrator') return true } return false } the gist controll...

jquery - Adding action handler using data-ember-action in Ember.js -

i noticed when have {{action}} in ember, rendered data-ember-action="somenumber". tried using data-ember-action directly in html , works. want find out id assigned particular action handler , can assign id action handler myself? using jquery datatables plugin display data. data has displayed links , on clicking links action handler must invoked. if try use {{action}} in code renders {{action}} in html. want call action handler called open parameter data.name shown in code below app.searchview = em.view.extend({ data: function(){ }, tagname:'table', didinsertelement: function(){ var mod=this.get('controller').get('model'); var self=this; this.$().datatable( { "bprocessing": false, "bfilter": false, "binfo": false, "aadata":mod, "aocolumns": [ { "mdata": "name" } ], "aocolumndefs": [ { "fnrender": function ...

c# - Generic query to get records from different tables -

in our project connecting database linq-to-entities. read valid records ,let's say, table1 there method: public list<tablename> gettablenamerecords() { try { return (from x in _context.tablename x.valid == 1 select x).tolist(); } catch (exception ex) { throw new exception(ex.message); } } it works, there problem - each table need write same query , change table name. there way write generic method pass table name? like: public list<t> getrecords<t>() { try { return (from x in _context.<t> x.valid == 1 select x).tolist(); } catch (exception ex) { throw new exception(ex.message); } } thanks help you can use reflection this, you're facing rather ugly code. however, if you're willing change models little bit, can in relatively straightforward way. create interface has 1 property - valid , so: interface ivalid { bool valid {...

regex pattern in php to find phone number between plain text -

i trying phone number between plain text. here, facing typical problem. pattern have written not matching types of phone numbers. ex: $string = 'sample text sample text sample text (216) 499 1001 sample text sample text (262) 335 60 76-77 sample text sample text sample text'; $string = str_replace('\n', php_eol, $string); //my regex pattern $regex = '/(?:1(?:[. -])?)?(?:\((?=\d{3}\)))?([2-9]\d{2})(?:(?<=\(\d{3})\))? ?(?:(?<=\d{3})[.-])?([2-9]\d{2})[. -]?(\d{4})(?: (?i:ext)\.? ?(\d{1,5}))?\s+?/'; preg_match_all($regex, $string, $matches); print_r($matches); which giving me first phone number , not second one. plz me in getting pattern also. output: array ( [0] => array ( [0] => (216) 499 1001 ) ---- --- thanks in advance! hi write algorithm 1) fetch whole string array 2) start scan document using loop(till end of line) 3) use is_numeric function finding finding numbe...

javascript - Jquery click event not firing on the element created dynamically using jquery -

i trying make simple functionality user selects value drop down , clicks on add button add selected item in below div in form of tag. each added tag has remove anchor when clicked removes tag. now when clicked on add button tags being inserted correctly, when clicked on remove button on tag, click event not firing. however if hard coded tags exact same markup of dynamically generated tags, click event remove tag firing exact , tag being removed wanted. html: <select id="ddltagname"> <option value="1">tag one</option> <option value="2">tag two</option> <option value="3">tag three</option> </select> <input id="btninserttag" type="button" value="add"/> <br/> <div id="tagsholder"> <span class="tag"> <span>tag 1 hardcoded </span> <a class="remove">x</a> ...

php - How to response a json string in Codeingniter -

i have database table named users keys 'userid, username, age', , there records in table, want them json, please @ this { "status":"1", "msg":"success", "userlist":[ { "userid":"1", "username":"chard", "age":"22" }, { "userid":"2", "username":"rose", "age":"21" }, { "userid":"3", "username":"niki", "age":"25" } ] } user_model.php file, write function get_users() { $query = $this->db->get('users'); return json_encode($query->row_array()); } user.php controller file, write function index_get() { $this->load->model('users_model'); $query = $this-...

php - preg_replace ranged out - compilation failed -

in code: $c = preg_replace('#[^a-z0-9áčďéěíňóřšťúůýž_-:().,;!?]#i', '', $_post['c']); i error: warning: preg_replace() [function.preg-replace]: compilation failed: range out of order in character class @ offset 40 idk error. do way: $c = preg_replace('#[^a-z0-9áčďéěíňóřšťúůýž_\-:().,;!?]#i', '', $_post['c']); you need escape - inside square brackets [..] because it's treated interval specifier

sum - cannot implicitly convert type 'int' to 'string' in C# -

i want make programs sum 2 number in 2 text box it's not working. don't know why. (and sorry bad english skill xd). here's code : textbox3.text = convert.toint32(textbox1.text) + convert.toint32(textbox2.text); since result of operation not string int have call tostring() assign string value textbox3.text textbox3.text = (convert.toint32(textbox1.text) + convert.toint32(textbox2.text)).tostring(); working code: string y = ""; y = (convert.toint32("3") + convert.toint32("4")).tostring();

java - Atomic actions - what is meant by reads and writes? -

its 1 thing don't concurrency - threads , atomic-actions. according docs.oracle these actions specified atomic: reads , writes atomic reference variables , primitive variables (all types except long , double). reads , writes atomic variables declared volatile (including long , double variables). but @ same time docs.oracle asserts incrementing variable not atomic action. thought write: private int number; number++; obviously not understand meant "reads" , "writes". could explain , give example of "reads" , "writes"? edit: when doing without synchronization programs suffers ´thread interference. understand not atomic. when change variable belongs object these threads share - there no interference whatsoever. shared variable object changed via mutator. in order implement number++ , runtime needs to acquire current value of number (a read). increment value. write new value number (a write). if thread star...

Set custom font for menu items in Android -

i tried implement custom menu. used answer given in this question. in code name expandedmenuitem, in examples iconmenuitemview. happening there? how can correct this? here code. public class myactivity extends preferenceactivity { @override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.proximity_alert_menu, menu); getlayoutinflater().setfactory(new factory() { @override public view oncreateview(string name, context context, attributeset attrs) { //if(name.equalsignorecase("com.android.internal.view.menu.menuitem")) {} try { layoutinflater li = layoutinflater.from(context); final view view = li.createview(name, null, attrs); new handler().post(new runnable() { public void run() { ...

Licensing Chrome Web Apps -

i have written chrome packaged app , ready publish chrome web store. i wish offer featured free trial period (eg 14 days) before requiring user buy license. have read this article concerning how receive current license state , using example code github have got license status work. however, how "set" license? example code returns "none" in response. how activate free trial programmatically or update value when customer purchases license? the licenses set automatically web store. when user chooses "free trial" install app, access level set "free_trial". paid version of app, access level set "full". if have followed instructions in article properly, app able query licenses web store.

api - Errno::ECONNREFUSED (Connection refused - connect (2)) -

i getting error when making api calls third party: “errno:: econnrefused (connection refused - connect (2)) ” i'm curious cause - api call worked yesterday, fails today. pretty definitive sign 3rd party's api having issues? also, connection refused - connect (2) mean in case? 2 supposed error code of sorts?

python - Looping through files -

i have 100 files in folder named 1.htm - 100.htm. run code extract info file , place extracted info in file final.txt. currently, have run program manually 100 files. need construct loop can run program 100 times, reading each file once. (kindly explain in detail exact edits need in code) below code file 6.htm: import glob import beautifulsoup beautifulsoup import beautifulsoup fo = open("6.htm", "r") bo = open("output.txt" ,"w") f = open("final.txt","a+") htmltext = fo.read() soup = beautifulsoup(htmltext) #print len(urls) table = soup.findall('table') rows = table[0].findall('tr'); tr in rows: cols = tr.findall('td') td in cols: text = str(td.find(text=true)) + ';;;' if(text!="&nbsp;;;;"): bo.write(text); bo.write('\n'); fo.close() bo.close() b= open("output.txt", "r") j in range (1,5): str=...

Quartz Error: No Suitable driver -

i have used quartz jobs in web application. working fine when used quartz 1.6.5 teradata database version 13.10. i faced frequent deadlock issues in quartz older version. so, upgraded version quartz2.2.1. working fine when used quartz 2.2.1 teradata database version 13.10. later faced weird charset issue in teradata 13.10, upgraded teradata 14.0. now, faced weird problem, when used quartz 2.2.1 teradata database version 14.0 we got following exception, info >2014-03-20 10:35:34,541 com.mchange.v2.log.mlog[main]: mlog clients using log4j logging. info >2014-03-20 10:35:35,007 com.mchange.v2.c3p0.c3p0registry[main]: initializing c3p0-0.9.1 [built 16-january-2007 14:46:42; debug? true; trace: 10] info >2014-03-20 10:35:35,504 com.mchange.v2.c3p0.impl.abstractpoolbackeddatasource[main]: initializing c3p0 pool... com.mchange.v2.c3p0.combopooleddatasource [ acquireincrement -> 3, acquireretryattempts -> 30, acquireretrydelay -> 1000, autocommitonclose -> fa...

Shell Script to parse log and Convert to csv -

i need shell script parse log file , pattern. if paatern found, take key values line , put csv. example: here log file have : *webauthredirect: mar 24 08:57:50.903: #emweb-6-parse_error: webauth_redirect.c:1034 parser exited. client mac= a0:88:b4:d3:55:8c bytes parsed = 0 , bytes read = 213 *webauthredirect: mar 24 08:57:50.903: #emweb-6-http_req_begin_err: http_parser.c:579 http request should begin character ***ewmwebwebauth1: mar 04 11:33:46.870: #pem-6-guestin: pem_api.c:7851 guest user logged in user account (mrathi_dev) mac address 00:1e:65:39:10:8e, ip address 192.168.133.146.** *ewmwebwebauth1: mar 04 11:33:46.870: #aaa-5-aaa_auth_network_user: aaa.c:2178 authentication succeeded network user 'mrathi_dev' *ewmwebwebauth1: mar 04 11:33:46.858: #apf-6-user_name_created: apf_ms.c:6532 username entry (mrathi_dev) length (10) created mobile 00:1e:65:39:10:8e *mmlisten: mar 24 08:57:49.030: #apf-6-radius_override_disabled: apf_ms_radius_override.c:1085 radius override...

ruby - Redmine/Rails - Undefined method while sending POST data -

redmine allows user add files document manually, goal create method automatically. i've added file manually while sniffing wireshark post requests want recreate in method me little bit (i can't post screenshots (if needed), reputation low). redmine official website offers informations how attach files here: http://www.redmine.org/projects/redmine/wiki/rest_api#attaching-files so after hours browsing web , particulary stackoverflow , here , wrote method: require 'net/http' require 'uri' uri = uri.parse("/uploads.js") http = net::http.new(uri.host, uri.port) request = net::http::post.new(uri.path, initheader = {'content-type' => 'application/octet-stream'}) request.body = file.new("/home/testfile.txt", 'rb') @response = http.request(request) as explained on redmine website specified content-type in header , added file in body request. now following error: nomethoderror (undefined method `+' nil:...