Posts

Showing posts from May, 2012

java - how to filter out some substrings with regex effectively? -

i want filter out srcport , dstport input string. here code tried: string input = "2014<>10.100.2.3<><189>date=2014-01-16,time=11:26:14,devname=b3909601569,devid=b3909601569,logid=000013,type=traffic,srcip=192.168.192.123,srcport=2072,srcintf=port2,dstip=10.180.1.105,dstport=3206,dstintf=port1,sessionid=121543,status=close,policyid=196,service=mysql,proto=6,duration=10,sentbyte=3910,rcvdbyte=175085,sentpkt=74,rcvdpkt=132"; pattern p = pattern.compile("(srcport=)(\\d+).[\\s]?(dstport=)(\\d+)"); matcher m = p.matcher(input); stringbuffer result=new stringbuffer(); while (m.find()) { system.out.println("srcport: " + m.group(2) + " & "); system.out.println("dstport: " + m.group(4)); } system.out.println(result); but not showing output. there mistake in regex pattern p = pattern.compile("(srcport=)(\\d+).[\\s]?(dstport=)(\\d+)"); or println lines system.out.println("srcport: " +

python - Redis Error 8 connecting localhost:6379. nodename nor servname provided, or not known -

my environment mac os 10.9.2, python3.3, redis-2.6.9 (64-bit). i have many threads (nealy 2000) use same redis instance write data, threads throw following exceptions: during handling of above exception, exception occurred: traceback (most recent call last): file "/usr/local/lib/python3.3/site-packages/redis/connection.py", line 250, in connect sock = self._connect() file "/usr/local/lib/python3.3/site-packages/redis/connection.py", line 268, in _connect self.socket_timeout) file "/usr/local/cellar/python3/3.3.4/frameworks/python.framework/versions/3.3/lib/python3.3/socket.py", line 417, in create_connecti on res in getaddrinfo(host, port, 0, sock_stream): socket.gaierror: [errno 8] nodename nor servname provided, or not known traceback (most recent call last): file "/usr/local/cellar/python3/3.3.4/frameworks/python.framework/versions/3.3/lib/python3.3/threading.py", line 901, in _bootstrap_i nner self.run() fi

asp.net - Export Data to excel using C# with separate header fields -

Image
i have export data excel.i have done exporting data, sql query , bind them grid view , after exporting grid view excel. works fine. but issue when there additional information display in excel sheet below ( report date , style name ), how can add them top of excel sheet before data list. are there libraries available this.. plzz help... and asp.net application. take @ epplus library. you can bind resultset returned sql query worksheet , insert new row @ desired position. private void dumpexcel(datatable tbl) { using (excelpackage pck = new excelpackage()) { //create worksheet excelworksheet ws = pck.workbook.worksheets.add("demo"); //load datatable sheet, starting cell a1. ws.cells["a1"].loadfromdatatable(tbl, true); excelworksheet.insertrow(int rowfrom, int rows, intcopystylesfromrow); response.contenttype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; response.

Python: append to mysql command depending on list length prior to execution? -

i want append conditional clauses mysql command prior execution vary based on number of elements want pull db. for example, have massive list of genes , each gene of interest have coordinates of of exons. gene_id exon start end genea exon1 325 359 genea exon2 554 601 geneb exon1 870 900 geneb exon2 990 1010 geneb exon3 1200 1350 as can see genea has 2 exons , geneb has 3 exons. want execute command such following return count of elements db within exons coordinates. select count(*) db_x position between exon1_start , exon1_end , position between exon2_start , exon2_end; because of different number of exons in each gene (some genes can contain tens of exons), need append additional "and position between exon_end , exon_start" conditional statement each , every exon before execution of overall command. i'm struggling come logical solution this. @ moment each gene, i'm passing list of concatenated start_end positions function queries mysql serv

javascript - Facebook like box plugin not working on navigation -

i have added facebook box plugin code in web application https://developers.facebook.com/docs/plugins/like-box-for-pages in application there 1 html body tag , dynamically adding other html div tag per requirement html. added following code in 1 of such divs. <div class="fb-like-box" data-href="http://www.facebook.com/drsailablog" data-width="265px" data-colorscheme="dark" data-show-faces="true" data-header="true" data-stream="false" data-show-border="true"> </div> i following whatever mentioned in directives use plugin i.e <body> <div id="fb-root"></div> <script> (function(d, s, id){ var js, fjs = d.getelementsbytagname(s)[0]; if (d.getelementbyid(id)) {return;} js = d.createelement(s); js.id = id; js.src = "//connect.facebook.net/en_us/all.js"; fjs.parentnode.insertbefore(

sql server - Sql design for the employee details and salary table. where employee code are not repeat in employee details and find salry,employee name,designation -

i want how fetch employee salary information , employee_code,first_name,through both table , want see salary of employee such employee ramesh salary 1000 rs.. , changes in tbl_basic_salary on basis of employee code. tbl_addnew_employee here employee information employee_id primary key employee_id int employee_code varchar(200)=null first_name varchar(200)=null last_name varchar(200)=null user_name varchar(400)=null father_name varchar(200)=null mother_name varchar(200)=null gender varchar(50)=null department varchar(200)=null designation varchar(200)=null profile_pic varchar(200)=null address varchar(200)=null second table tbl_basic_salary salary_id primary keys salary_id int basic_salary decimal(18, 0)=null salary_type varchar(50)=null , add information details of employee , employee_code unique every employee alter procedure [dbo].[usp_addnew_employee] -- add parameters stored procedure here @employee_code varchar(200)=null

javascript - Partial View on Submit using Ajax call -

here jquery code: <script type="text/javascript"> $("#submitfileform").submit(function () { $.ajax({ type: 'post', contenttype: 'application/html;charset=utf-8', datatype:'html', success:function (result) { $('#tablepartialview').html(result); }, error:function (xhr, status) { alert(status); } }) }); </script> and here html.beginform, @using (html.beginform("propertycolumnmap", "importfile", formmethod.post, new { enctype = "multipart/form-data", @class = "form single-col",id="submitfileform"})) { <input type="file" name="uploadfile" id="uploadfile" value=""/> <select id="assetlist" name="assetlist">

vb.net - How to maintain the page state in asp.net when autopostback = true? -

how can same scroll position after postback? doing code in vb. have referred , tried mentioned in following question link .but nothing worked me. how overcome problem? maintainscrollpositiononpostback = "true" in page declaration should work

bash - read a list of IP address and execute commands depending on OS type -

i working on script read file having multiple ip addresses, login each system (no ssh keys involved , manually entering password), execute command depending on os type , print result. here how ips defined in hosts.txt file #~] cat hosts.txt 10.6.3.131 10.6.3.132 10.6.3.11 10.6.3.12 when execute below script, following errors shown. also, script not prompt 2nd , rest ips in list. causing this? # ./hq-test1.sh root@10.6.3.131's password: awk: cmd. line:1: nr==1{print awk: cmd. line:1: ^ unexpected newline or end of string bash: line 2: [: !=: unary operator expected 10.6.3.131 == pass this script used in test : #!/bin/bash while read host; if ssh root@$host ' status=`awk 'nr==1{print $1}' /etc/*release` [ $status != "centos" ] '; echo "$host == fail" else echo "$host == pass" fi done < hosts.txt your script isn't closing stdin while running s

string - How to convert an integer according to international number system in java (Number Formatting) -

i want convert given number according international number system. // example: 345678 -> 345,678 12 -> 12 123 -> 123 4590 -> 4,590 here code snippet , ideone link public static void main (string[] args) throws java.lang.exception { int number = 345678; string s = integer.tostring(number); s = putcommas(s); } private string putcommas(string s) { // how put commas in string after every 3rd character right ? } here approach not comfortable. start traversing string right if (length - currentindex -1) % 3 == 0 insert comma in string any suggestions ? you can use numberformat locale#us : numberformat.getnumberinstance(locale.us).format(number); or decimalformat : decimalformat formatter = new decimalformat("#,###"); string newnumber = formatter.format(number);

c - defining the CHAR pointer with variable size -

how can define char pointer correct or variable width? my scenario below.. void processra(int _racount, char *rafile) { char *command; // how correctly define variable ? sprintf(command, "somecomm -r %s -n%d-%d ", rafile, (_racount - 1), (_racount - 1)); system(command); } in scenario, defining char pointer command . size of command depends on function passed variable rafile , following line's command. char* in c come without associated storage. different languages fortran character type stands string of fixed size. either have define character array using char command[size+1] , or use malloc() allocation (don't forget call free() when done string). the tricky part correctly compute required length. however, in posix-2008 standard, there function called asprintf() , precisely need: combines function of sprintf() allocation of enough memory using malloc() (again, don't forget call free() when done string). usage follows:

java - Spring 4 - websocket messaging stomp handler -

i trying tutorial provided spring - messaging-stomp-websocket , working fine now want extend , add websocket handler intercept channel. public class websockethandlerspring extends textwebsockethandler { @override public void handletextmessage(websocketsession session, textmessage message) { } } this handler websocketconfig class. @configuration @enablewebsocketmessagebroker public class websocketconfig extends abstractwebsocketmessagebrokerconfigurer { @override public void configuremessagebroker(messagebrokerregistry config) { config.enablesimplebroker("/topic"); config.setapplicationdestinationprefixes("/app"); } @override public void registerstompendpoints(stompendpointregistry registry) { registry.addendpoint("/hello").withsockjs(); } } any how configure websockethandlerspring handler websocketconfig ? raw websockethandler support comes @enablewebsocket (n

php - Issue in displaying large no of records on view file in codeigniter without using pagination -

i'm fetching list of users mysql db table & displaying on view file of codeigniter application, i'm not using pagination, want show records on same page . partial data displaying on page, have 3000 records 1000 1500 records gets shown on page. after script dies down, tried changing max_execution_time max_input_time memory_limit no help. public function usersce14($sort = null, $column = null) { if (!empty($sort)) { switch ($column) { case 'id': $sortcolumn = '`id`'; break; case 'username': $sortcolumn = '`username`'; break; case 'firstname': $sortcolumn = '`first_name`'; break; case 'lastname': $sortcolumn = '`last_name`'; break; case 'email': $sortcolumn = '`email`'; break;

command line arguments - Keep quotes in $args using PowerShell -

is possible keep quotes in $args ? the script called this: .\test1.ps1 a=application o="this object" msg_text="this text" the quotes mandatory further processing. there way keep them inside $args ? the way can think of without being able modify input parameters still require modifying command called somewhat. in order preserve quotes, perhaps try capturing full command-line powershell script called with. so put in test1.ps1 script: write-host (get-wmiobject -query "select commandline win32_process commandline '%test1%'").commandline then returned if script called in manner: ps c:\temp> powershell .\test1.ps1 a=application o="this object" msg_text="this text" "c:\windows\system32\windowspowershell\v1.0\powershell.exe" .\test1.ps1 a=application "o=this object" "msg_text=this text" this possible if new instance of powershell called, however, otherwise parameters won&#

How can changing the size of the string to be scanned affect the output completely independent of it? -

my code giving wrong answer on problem 400a on http://codeforces.com while working fine on laptop. suggested me problem can solved increasing size of string , after doing that, code got accepted. find mistake in original code, placed print statements in 2 codes find out going wrong , made 2 submissions in codeforces. in following submissions, changed size of array w 12 13: http://codeforces.com/contest/400/submission/5948686 http://codeforces.com/contest/400/submission/5948717 as can see, in former case, inner loop not executed i=0 in later case is. why happening (i know string size must kept greater string how related functioning of inner loop @ i=0 )? here's best guess, depends on compiler used, how memory way laid out, - there may no way know sure. else may have better guess. so here's maybe happened: scanf read in 13 characters - 12 characters, plus null terminating character (\0). null terminator has ascii value of 0 the 12 characters thrown buffer

c - Green Hills Sw small data area overflow -

this question has answer here: greenhills - small data area overflow 2 answers i trying compile embedded c code, small data area overflow occurs. know mean, don't know how solve it. can make suggestion? so, problem there r13 register base pointer of sda, , 16 bits long. signed points middle of sda, , can used offset given variable value. if variable told put sda #pragma ghs startsda addressed sda_base+r13, if variable @ address cannot addressed base+register offset, sda overflow reported. how can find caused overflow? if don't have map file yet don't know variable addresses. you need check see compiler configuration. compiler can automatically put data .sda area. forget exact flag can exclude data greater specific size .sda. example can things greater 64-bits not go sda. way big buffer define not waste of sda space.

add in - Unwanted excel add-in loads but no trace of it anywhere -

when loading excel2013, old add-in continues appearing in tabs, although not requested the add-in not appear in vba projects nor in file in office or users folders the add-in not show in excel options add-ins list i wonder excel loads , looks way rid of it thanks avi if "phantom toolbar/menu" appearing in addins tab can remove right-clicking , choosing delete. also make sure have checked com addins list excel addins list.

ZIP compress all files (*.txt) in a directory and subdirectory c# -

i need help, new c#. i have program compress folder files , folders, compress specific kind of file. i use code compress: if (!file.exists(name_of_zip_folder)) { zipfile.createfromdirectory(folder, name_of_zip_folder); } i following: public void zipfunction(string folder, list<string> files_to_compress){ //compress these kind of files, keeping structur of main folder } for example: zipfunction(main_folder, new list<string> { "*.xlsx", "*.html"}); how compress specific file types? this code snippet jan welker (originally posted here) shows how compress individual files using sharpziplib private static void writezipfile(list<string> filestozip, string path, int compression) { if (compression < 0 || compression > 9) throw new argumentexception("invalid compression rate."); if (!directory.exists(new fileinfo(path).directory.tostring())) throw new argumentexception("the path not exi

android - Dynamically change intent URI in SharedPreferences? -

my users can jump google play rate app settings screen, clicking preference starts intent: in xml: <preference android:title="@string/prefrate" android:summary="@string/prefratehint"> <intent android:action="android.intent.action.view" android:data="market://details?id=app.package.name" /> </preference> in code: public class settingsactivity extends preferenceactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.prefs); } } now i'm planning upload amazon store url different. there way programmatically change intent url inside sharedpreferences before showing settings screen? it's going add few bytes code, having 2 seperate prefs_play, prefs_amazon files, , establishing reference when find out store working with? quick-and-dirty way come out of original

Calling django methods from a twisted server -

consider problem, in parent directory there 2 (2) directories. in 1 directory root django server whilst directory root twisted server. twisted server receives data, whilst django server serves data website , manages database. |-root- django -| |-manage.py |-site/ - twisted -| |-server.py i want twisted server able supply data models in django site, however, getting following error when calling methods. you must either define environment variable django_settings_module or call settings.configure() before accessing settings. which best workaround this? to exactly tells to . export django_settings_module=yoursite.settings ... setup_environ(settings) ... settings.configure(...)

Incorrect datetime value: '1/1/0001 12:00:00 AM' for column 'call_time' at row 1 in Mysql -

i have column named call_time in table of datatype datetime in mysql.now trying insert 1/1/0001 12:00:00 am in call_time colum is giving following error.. incorrect datetime value: '1/1/0001 12:00:00 am' column 'call_time' @ row 1 here complete query string .. insert outcall values('0117','509','02240576000','','1/1/0001 12:00:00 am','07:1','7') please me .. to insert dates , times, have use iso date format: insert outcall values('0117','509','02240576000','','0001-01-01 00:00:00','07:1','7') if want use format, use str_to_date function: str_to_date("1/1/0001 12:00:00 am", "%c/%e/%y %r")

dictionary - embeddable array type of schema in python-eve -

i know can make resource embeddable in resource, below schema not seems working? right way make array of resources embeddable in resource? outer = { 'type': 'dict', 'schema': { 'inner': { 'type': 'list', 'schema': { 'type': 'objectid', 'required': true, 'data_relation': { 'resource': 'other_resources', 'embeddable': true, }, }, }, } } currently not supported: currenly support single layer of embedding, i.e. /emails?embedded={"author": 1} not /emails?embedded={"author.friends": 1} . however, there's active pull request right ( add support 2 layers of document embedding ) tries address limitation.

java - Print writer format -

i have list several objects each containing 3 strings , how should format output (in outfile.format() ) make in sample output below? public void save() { try { printwriter outfile = new printwriter (new bufferedwriter (new filewriter("reg_out.txt"))); (int = 0; < list.size(); i++) { outfile.format("???", list.get(i).getlastname(), list.get(i).getfirstname(), list.get(i).getnumber()); } outfile.close(); } catch (ioexception ioe) { ioe.printstacktrace(); } } sample output in reg_out.txt: allegrettho albert 0111-27543 brio britta 0113-45771 cresendo crister 0111-27440 try this outfile.printf("%-20s%-20s%-20s%n", list.get(i).getlastname(),

Drag and drop rows in a jqgrid -

i new jqgrid. trying drag & drop option rows in jqgrid. have tried fiddle http://jsfiddle.net/qezhr/298/ lot valuable suggestions. have tried jquery("#mytable").griddnd(); , with jquery("#mytable").jqgrid('griddnd'); i having same problem looked example. made few changes , seems work. include: jquery ui.js base jquery drag , drop code is. include: jquery.tablednd.js move dnd call , sortable rows calls after create grid. working fiddle: http://jsfiddle.net/netroworx/6wmm7/ $(document).ready(function() { jquery("#mytable").jqgrid({ datatype:"clientside", data:[ {"number": 1, "segment":"first", "name": "chap0"}, {"number": 2, "segment":"second", "name": "chap1"}, {"number": 3, "segment":"third", "name": "chap2"},

sockjs - Spring 4 websockets dynamic MessageMapping not executed -

i'm using spring 4 websockets on tomcat 8 , have following configuration: <websocket:message-broker application-destination-prefix="/app"> <websocket:stomp-endpoint path="/notify"> <websocket:sockjs /> </websocket:stomp-endpoint> <websocket:simple-broker prefix="/topic" /> </websocket:message-broker> my spring controller has following method: @messagemapping("/notify/{client}") public void pushmessage(@destinationvariable long client, string message) { system.out.println("send " + message + " " + client); template.convertandsend("/topic/push/" + client, message); } so i'm trying here if client 1 wants send message client 2, uses /app/notify/2 . spring controller push message topic /topic/push/2 . i wrote following code in client: var id = 1; var sock = new sockjs('/project/notify'); var client = stomp.over(sock); client.co

c# - How to Compare Two ArrayList -

how compare 2 arraylist ? arraylist l1 = new arraylist(); l1.add(1); l1.add(2); and have arraylist same value .now want compare both.if both arraylist contains same value return true else false. there method without loop?? as mentioned in comments, can use list instead of arraylist , then: l1.sequenceequal(l2); i'm assuming l2 name of second list. also, values need in same order in both lists sequenceequal return true. more information here: http://msdn.microsoft.com/en-us/library/bb348567%28v=vs.110%29.aspx

php - Symfony2 ignores form validation of collection -

i have problem symfony2 , validation of email addresses collection. entity\user /** * user * * @orm\table() * @orm\entity */ class user { /** * @orm\id * @orm\column(type="integer") * @orm\generatedvalue(strategy="auto") */ protected $id; /** * @var email[] * @orm\onetomany(targetentity="email", mappedby="user", cascade={"all"}, orphanremoval=true) * @assert\valid */ private $emails; public function __construct() { $this->emails = new \doctrine\common\collections\arraycollection(); } public function getid() { return $this->id; } /** * add emails * * @param email $emails * @return user */ public function addemail(email $emails) { if($emails->getemail() !== null && strlen($emails->getemail()) > 0) { $emails->setuser($this); $t

java - How to get selected row values in easygrid -

i create custom button "open" in grails easygrid plugin. want parameters in button. how can values selected row? <grid:grid id='jqgridinitial' name='customerlist' jqgrid.caption="'customer'" open="${g.createlink(controller: 'customer', action: 'index', params:[???] }" this javascript code return selected row: var row = jquery("#jqgridinitial_table").jqgrid('getgridparam','selrow'); but, think need custom jqgrid formatter: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter you can see example here: https://github.com/tudor-malene/easygrid_example/blob/master/grails-app/views/author/_jqgrid.gsp and here how works ( click on author name , links wikipedia): 199.231.186.169:8080/easygrid/author/list?impl=jqgrid in case should construct link customer based on actual row data

javascript - How to list CheckBoxes in a vertical way? -

when create checkbox, want them listed in vertical way, , not horizontal. how able this?? html: <div id="cblist"> <input type="checkbox" value="first checkbox" id="cb1" /> <label for="cb1">first checkbox</label> </div> <input type="text" id="txtname" /> <input type="button" value="ok" id="btnsave" /> jquery: $(document).ready(function() { $('#btnsave').click(function() { addcheckbox($('#txtname').val()); }); }); function addcheckbox(name) { var container = $('#cblist'); var inputs = container.find('input'); var id = inputs.length+1; $('<input />', { type: 'checkbox', id: 'cb'+id, value: name }).appendto(container); $('<label />', { 'for': 'cb'+id, text: name }).appendto(container); }

android - Download large Images from server and showing in listview Items -

i used volley network library , networkimageview display listview. images download server images big sizes. used gzipinputstream gzip not enough. want more effective way download data. problem heap sizes increases when download data , images disk cache memory increased. there effective way implement download large data.

sql server - Visual Studio SSDT Data Compare how to compare two tables in a single database -

trying simple data compare in ssdt proving bit hard. in 1 database, have 2 tables want compare. these tables have same schema, different table names. , want see if tool give me nice way compare data in both. i.e. tbloutput tbloutput_210314 but picking of 2 tables compare against each other in single database can't see how achieve. seems can pick table name exists in both source , target databases. since source , target database same, comparing table ? anyone know of way achieve data compare ? visual studio 2012 sql server data tools data compare data compare supports comparing 2 different databases matching schemas. unfortunately can't looking data compare. help documentation : requirements when compare data in table or view, table or view in source database must share several attributes table or view in target database. tables , views not meet following criteria not compared , not appear on second page of new data comparison

hadoop mapreduce partitioner not invoked -

need mapreduce job, custom partitioner never invoked. checked million times, no result. used work while ago, have no idea why isn't. appreicated. adding code (it doesn't work either custom keys input either easy cases). mapper outputs right values 100%, , partitioner skipped. //import of libs import org.apache.hadoop.conf.configured; import org.apache.hadoop.conf.configuration; import org.apache.hadoop.mapreduce.job; import org.apache.hadoop.mapreduce.reducer; import org.apache.hadoop.mapreduce.partitioner; import org.apache.hadoop.hbase.mapreduce.tablemapper; import org.apache.hadoop.hbase.mapreduce.tablemapreduceutil; ... public class hbasecounttest extends configured implements tool { .... static class mymapper extends tablemapper<text,text> { @override public void map(immutablebyteswritable rowkey,result result, context context) throws ioexception { ...... //dropping calculations context.write(new text(gender), new text(capsstr)); /

Unable to add an Image to a powerpoint presentation using open xml -

i using following code add new slide ppt file , add image. using open xml 2.5 sdk. a new slide getting added not image. there wrong in code? int position = 1; using (presentationdocument presentationdocument = presentationdocument.open("c.pptx", true)) { presentationpart presentationpart = presentationdocument.presentationpart; slide slide = new slide(new commonslidedata(new shapetree())); nonvisualgroupshapeproperties nonvisualproperties = slide.commonslidedata.shapetree.appendchild(new nonvisualgroupshapeproperties()); nonvisualproperties.nonvisualdrawingproperties = new nonvisualdrawingproperties() { id = 1, name = "" }; nonvisualproperties.nonvisualgroupshapedrawingproperties = new nonvisualgroupshapedrawingproperties(); nonvisualproperties.applicationnonvisualdrawingproperties = new applicationnonvisualdrawingproperties(); // specify group shape properties of new slide. slide.commonslidedata.shapetree.appendchild(new groupshapeproper

c++ - Using fftw with column major square matrices (armadillo library) -

i find armadillo c++ library convenient matrix computations. how 1 perform 2 dimensional fft on armadillo matrices using fftw library? i understand armadillo matrix class stores data in column major order. how pass fftw? fftw 3.3.3 documentation says if have array stored in column-major order , wish transform using fftw, quite easy do. when creating plan, pass dimensions of array planner in reverse order. example, if array rank 3 n x m x l matrix in column-major order, should pass dimensions of array if l x m x n matrix (which is, perspective of fftw) i cannot understand means, given syntax creating plan follows. fftw_plan fftw_plan_dft_2d(int n0, int n1, fftw_complex *in, fftw_complex *out, int sign, unsigned flags); could explain this? it means can try both fftw_plan plan=fftw_plan_dft_2d(4, 2,(double(*)[2])&aaa(0,0), (double(*)[2])&bbb(0,0), fftw_forward, fftw_estimate); and fftw_plan

java - 2 randoms seem to give near identical result -

thanks in advance taking time @ q. , same problem hope solution... so basicly have app spins 2 coins @ same time , displays result is. this method generates first coin... public void coinresult1(){ imageview coin1view = (imageview) findviewbyid(r.id.coin1); random r = new random(); int coin1result = r.nextint(2); if (coin1result == 0){ coin1view.setbackgroundresource(r.drawable.coinheads); coinresult1 = 0; } else if (coin1result == 1) { coin1view.setbackgroundresource(r.drawable.cointails); coinresult1 = 1; } } and second coin public void coinresult2(){ imageview coin2view = (imageview) findviewbyid(r.id.coin2); random r = new random(); int coin2result = r.nextint(2); if (coin2result == 0){ coin2view.setbackgroundresource(r.drawable.coinheads); coinresult2 = 0; } else if (coin2result == 1) { coin2view.setbackgroundresource(r.drawa

javascript - Editing two canvas elements -

i have 2 canvas elements, first 1 empty, , in second drawed big grid. in first 1 need add text , images going dragged grid. problem is, when add text empty canvas, grid disappears!! don't know how happen. i'm using simple code in script tag: var canvas=document.getelementbyid("canvas"); var ctx=canvas.getcontext("2d"); var canvas2=document.getelementbyid("canvas2"); var ctx2=canvas2.getcontext("2d"); ctx2.font = "30px arial"; ctx2.filltext("catalog of equipments",10,50); and i'm calling 2 canvases in body: <canvas id="canvas2" width=300 height=1000 style="border:2px solid #c3c3c3; left:320px; top:50px"></canvas> <canvas id="canvas" width=1000 height=1000 style="border:2px solid #c3c3c3; top:50px;"></canvas> in jsfiddle have spelt filltext capital f rather filltext. have corrected in jsfiddle . var canvas2 = document.getelementby

java - Android GCM Registration is failing -

i working on google cloud messaging service in android app. need register android app gcm server. gcm registration failing. i have checked: gcm register code async call. sender id (project id) correct. manifest file per google doc. http://developer.android.com/google/gcm/client.html device has google account set up. have tried both cases - add google-play-services jar , import project. went on specify version number (com.google.android.gms.version) in manifest per http://developer.android.com/google/play-services/setup.html#setup where , why failing? when catch exception, exception cause null. i had done demo app gcm part , working fine. had used eclipse jellybean sdk. extended project make current app - package stucture remains same. on kitkat sdk. i used same sender id before register gcm. failed giving null id. created new project @ cloud console , used project number sender id. still same error. registration id null. don't think sender id should issue. any apprec

jquery - How To Add Description To JCarousel -

i using jcarousel . can't add description photo in slider. <div id="jcarousel"> <ul id="mycarousel" class="jcarousel-skin-tango"> <li> <img src="images/about_img1.jpg"/> </li> </ul> </div> you can create div after jcarousel container , change content of div on next , previous button click callback function in jquery. check this: <div id="jcarousel"> <ul id="mycarousel" class="jcarousel-skin-tango"> <li> <img src="images/about_img1.jpg"/> </li> </ul> </div> <div id="description"> <label id="caption">first image</label> </div> in jquery code: keep data structure, array captions. , change caption according image being shown. hope helps.

matlab - Recursive Function to generate / print a Fibonacci series -

i trying create recursive function call method print fibonacci until specific location: 1 function f = fibonacci(n) 2 fprintf('the value %d\n', n) 3 if (n==1) 4 f(1) = 1; 5 return; 6 elseif (n == 2) 7 f(2) = 2; 8 else 9 f(n) = fibonacci(n-1) + fibonacci(n-2); 10 end 11 end as per understanding fibonacci function called recursively until value of argument n passed 1. function stack rollback accordingly. when call function command: >> fibonacci(4) the value of n 4, line 9 execute like: 9 f(4) = fibonacci(3) + fibonacci(2); now believe that first fibonacci(3) called - hence again fibonacci(3) 9 if(3) = fibonacci(2) + fibonacci(1); the ifs in line number 3 , 6 take care. but how fibonacci(2) + fibonacci(1) statement change to: if(3) = 2 + 1; i receiving below error , unable debug further resolve it: >> fibonacci(4) value 4 value 3 value 2 value 1 in assignment a(i) = b, number of elements in b , must same. error in fibo

java - JSF actionListener method not found -

i have actionlistener within h:commandbutton when pressed error comes out method not found. here's code: <h:form id="course"> <ui:repeat value="#{stationcourses.course}" var="course"> <h:commandbutton class="buttons" id="courseid" value="#{course.coursename}" actionlistener="#{stationcourses.courseselected}" style="alignment-adjust: central; white-space: pre-line; word-wrap: break-word;"/> </ui:repeat> </h:form> and bean: import javax.faces.event.actionevent; import java.io.serializable; import javax.faces.bean.managedbean; import javax.faces.bean.requestscoped; import java.util.list; @managedbean @requestscoped public class stationcourses implements serializable { //provide connection db private coursequeries cq = new coursequeries(); private list<course> courses =

symfony - Create repository action from form selected items in Symfony2? -

edit found how data $filter_form->handlerequest($request); if ($filter_form->isvalid()) { $users = $filter_form->get('users')->getviewdata(); $tags = $filter_form->get('tags')->getdata(); $links = $em->getrepository('lancrmbundle:link')->findfiltered($users, $tags); } else { $links = $em->getrepository('lancrmbundle:link')->findby( array(), array('id' => 'desc') ); } now have create findfiltered method in repository. but don't know how make working. public function findfiltered($users, $tags) { $querybuilder = $this->createquerybuilder('l'); $querybuilder->orderby('l.id', 'desc'); if($users) { ??? } if($tags) { ??? } return $querybuilder->getquery()->getresult(); } i hope understandable, if not not hesitate ask me more infor

python - Shebang doesn't work with python3 -

i have following program: #!/usr/local/bin/python3 print("hello") via terminal test.py , get: traceback (most recent call last): file "/usr/lib/python3.3/site.py", line 629, in <module> main() file "/usr/lib/python3.3/site.py", line 614, in main known_paths = addusersitepackages(known_paths) file "/usr/lib/python3.3/site.py", line 284, in addusersitepackages user_site = getusersitepackages() file "/usr/lib/python3.3/site.py", line 260, in getusersitepackages user_base = getuserbase() # set user_base file "/usr/lib/python3.3/site.py", line 250, in getuserbase user_base = get_config_var('userbase') file "/usr/lib/python3.3/sysconfig.py", line 610, in get_config_var return get_config_vars().get(name) file "/usr/lib/python3.3/sysconfig.py", line 560, in get_config_vars _init_posix(_config_vars) file "/usr/lib/python3.3/sysconfig.py"

iphone - Error 404 using DavKit on IOS APP -

i try integrate davkit ios app when try connect webdav server 404 error , , when debug davkit code cfnetwork sslhandshake failed (-9819) error here code nsstring root = @"https://137998.webdav.cloudsafe.com/test"; davcredentials *credentials = [davcredentials credentialswithusername:@"hatim.haffane@gmail.com" password:@"bxwhe6-hphdsm-rxtijw"]; davsession *session = [[davsession alloc] initwithrooturl:[nsurl urlwithstring:root] credentials:credentials]; davrequest davrequest = [[davlistingrequest alloc] initwithpath:root]; davrequest.delegate = self; [session enqueuerequest:davrequest]; so if 1 can me or suggest library can use connect , listing , uploading , downloading files usen webdav ?

vk - User info from VKontakte in Android -

i writing application needs use user data taken client social network vkontakte. did authorize vkontakte. vksdk.initialize(sdklistener, string.valueof(idvk), vkaccesstoken.tokenfromsharedpreferences(this, stokenkey)); and got accesstoken. name , email user? you can request email scope user, email access token: string email = vksdk.getaccesstoken().email; string userid = vksdk.getaccesstoken().userid; //get user info vkapi.users().get().executewithlistener(new vkrequest.vkrequestlistener() { @override public void oncomplete(vkresponse response) { vkapiuser user = ((vklist<vkapiuser>)response.parsedmodel).get(0); log.d("user name", user.first_name + " " + user.last_name); } }); but remember, email available after first access request. old answer: can't email. not available. can user name: vkapi.users().get().executewithlistener(new vkrequest.vkrequestlistener() { @override public void oncomplet

javascript - Clean Html from contenteditable -

i'm trying save contenteditable data javascript-array. every new line should array-item first of cleaned out chromes html: html = html //empty line looks this: .replace(/<div><br\s*[\/]?><\/div>/gi,'') //chrome wraps each line in div .replace(/<div>/gi,'\n') .replace(/<\/div>/gi,'') //sometimes chrome adds break. .replace(/<br\s*[\/]?>/gi,''); later on do: html.split("\n"); i tested in firefox, , realized make newlines adding breaks. haven't looked @ internet explorer yet. is there more general-approach or well-tested way extract text lines of text separated newline-carachter html? try this: html <div id="container" contenteditable=true></div> javascript var container = document.getelementbyid('container'); container.onblur = function () { console.log(this.innertext.split('\n')); } jsfiddle: http://jsfiddle.net/ezlhf/

ios - Resize UITableView for iPhone 5 -

Image
how can adapt uitableview height iphone 4-inch screen? have following configuration, works iphone 4. on iphone 5 (see image below) there blank space because tableview not rezise. tableview scrollable. i've autolaout enabled , tried defining horizontal , vertical spacing constraints views , tableview, same results (see image below). suggestion? this viewcontroller placed inside placeholder since created custom menu. tried settting constant of placeholder in parent view following code. not working, tableview clipped. -(void) viewdidload{ if([[uiscreen mainscreen] bounds].size.height == 568) //iphone 4inch { nslog(@"iphone5"); self.dynamictvheight.constant = 465; [self.placeholder needsupdateconstraints]; } else{ nslog(@"iphone4"); self.dynamictvheight.constant = 375; [self.placeholder needsupdateconstraints]; } and these constraints of par

Saving a model with multiple foreign keys in Laravel 4 -

i understand in order save foreign key, 1 should use related model , associate() function, worth trouble of going through this $user = new user([ 'name' => input::get('name'), 'email' => input::get('email') ]); $language = language::find(input::get('language_id'); $gender = gender::find(input::get('gender_id'); $city = city::find(input::get('city_id'); $user->language()->associate($language); $user->gender()->associate($gender); $user->city()->associate($city); $user->save(); when 1 can this? user::create(input::all()); i feel i'm missing here, maybe there's simpler , cleaner way handle foreign keys in controllers (and views)? you can use push() method instead allow push related models. this link should answer query. eloquent push() , save() difference

scala - Defining an array in play's config file -

i didn't find information topic. there way define array in standard play config file app.config have such values as? application.secret="gk<9kcgmu@a62eyfcj;yz2nfna;4324/gfdg]afdsfds" application.langs="en" application.global=common.global yes, possible , described here in general, looking this: my.setting="[value1,value2,value3]" in code can access this: play.current.configuration.getstringlist("my.setting") //returns option[java.util.list[string]] you may use getlonglist , getbooleanlist , on.

java - How to Handle Invalid (HTML) Messages in JAX-WS -

my soap client based on jax-ws. server (which written , operated else) returns valid xml messages, occasionally, when experiences internal error, returns html message error code (http 500). unfortunately, in case jax-ws client merely throws unsupportedmediaexception: "unsupported content-type: text/html" . what need way find out error condition server reports in order take actions. i'd rather change server, that's not possible, outside reach. at least, need log incoming raw response. i know possible log all requests , responses following advice: https://stackoverflow.com/a/5647686/578759 but overflow system log, have several requests per second. so instead i'd rather log response in case of error. we have soaphandler in place, logs incoming , outgoing soap messages, works on valid soap messages, i.e. after parsing xml. if incoming response html, don't point handler invoked. is there way add similar handler @ stage?

c# - Reading RAM and Disk utilization for VM's in Hyper-V using WMI Classes -

i new wmi classes, want read cpu, ram , disk utilization different virtual machines on hyper-v using wmi classes in c# code. cpu utilization: able using properties processorload , processorloadhistory managementbaseobject outparams = virtualsystemservice.invokemethod("getsummaryinformation", inparams, null); managementbaseobject[] summaryinformationarray = (managementbaseobject[])outparams["summaryinformation"]; ram utilization: not able exact value of current ram utilization dynamic , static allocation. virtualquantity , reservation proprty of 'msvm_memorysettingdata' class gives startup ram value in case of dynamic ram , minimum value of ram allocated in case of static ram. harddisk utilization : not able harddisk utilization of each virtual machine. my code is: public static managementobject gettargetcomputer(string vmelementname, managementscope scope) { string query = string.format("select * msvm_computersy

c# - retrieve data to textboxt using LINQ to SQL -

hi want ask retrieve data textbox using linq sql c# i'm using visual studio 2013 ultimate edition i have *.dbml file , textboxt.. this code : dataclasses1datacontext db = new dataclasses1datacontext(); var query = c in db.library select c.book; and want retrieve data : **textboxt**<hr> title.text;<br> name.text;<br> bookcode.text;<hr> nb : using c# (linq sql) winform visual studio 2013 var query = c in db.library select c.book; above code return multiple record of books. have loop on "query" for eg foreach (var q in query) { response.write(q.tostring()); // "q" have database record }

java - connect to the mysql database with jdbc connector in intellij13 -

when have connect mysql jdbc error occure in code line: connection con = drivermanager.getconnection("jdbc:mysql://localhost:3306 /server1","root","admin"); the error is: c:\jdk\bin\java -didea.launcher.port=7539 "-didea.launcher.bin.path=c:\intellij idea 13.0.2\bin" -dfile.encoding=utf-8 -classpath "c:\jdk\jre\lib\i18n.jar;c:\jdk\jre \lib\jaws.jar;c:\jdk\jre\lib\rt.jar;c:\jdk\jre\lib\sunrsasign.jar;c:\users\kamyar \desktop\chatjava\untitled3\out\production\untitled3;c:\users\kamyar\desktop\myjdbc \mysql-connector-java-5.1.6-bin.jar;c:\intellij idea 13.0.2\lib\idea_rt.jar" com.intellij.rt.execution.application.appmain ccc java.lang.noclassdeffounderror: java/sql/savepoint @ com.mysql.jdbc.nonregisteringdriver.connect(nonregisteringdriver.java:282) @ java.sql.drivermanager.getconnection(drivermanager.java:517) @ java.sql.drivermanager.getconnection(drivermanager.java:177) @ ccc.main(ccc.java:17) @ java.lang.reflect.method.in

android - close activity and dialog box on back press -

i have activity has progressdialog box setcancelable(false) . i want finish activity dismiss progressdialog box on backpressed() . i have implemented onbackpressed() below not working. @override public void onbackpressed() { if(pdialog.isshowing()){ pdialog.dismiss(); } this.finish(); super.onbackpressed(); } progress dialog code is pdialog = new progressdialog(mainactivity.this); pdialog.settitle("connecting server"); pdialog.setmessage("updating assignee detail. please wait..."); pdialog.setindeterminate(false); pdialog.setcancelable(false); pdialog.show(); set pdialog.setcancelable(true); and rest of code fine.

actionscript 3 - How to change SWC component's width shown on the Flash IDE? -

Image
i linked item in library .as file.in .as file,i write class this: public class textarea extends movieclip { ....... public function setwidth(w:number):void { this.width = w; } } then change item complied clip in library(it same complied ***swc* )**.i add stage , change it's property fire setwidth function.but width doesn't change.what should change movie clip's width? p.s. child ,a textfield , in item can changed width. in pic, put swc component on stage , swc have 1 textfield child. the text field given black border , swc being selected,the blue border bounds. and print this.width in text , width auto changed adjust text field. but blue border want change.it shows on flash panel , stand transform bounds this: so, don't have trouble change children's data. , found class this: there livepreviewparent this.parent . provide live preview of swc on stage.and size change absolutely changed,but think blue border stand

php - Get MySQL data WHERE column equals HTML link when clicked -

don't quite know how work one, appreciated. i'm trying display products match column of link have been clicked. have succeeded in doing search function when click button (search). i'm trying implement similar method when link pressed. $sql = "select * products "; if(isset($_post['submit'])){ if(empty($_post['search'])){ $error = true; }else{ $searchq = mysql_real_escape_string($_post['search']); $searchq = preg_replace("#[^0-9a-z]#i","",$searchq); $sql .= "where type '%$searchq%' or name '%$searchq%'"; } } $query = mysql_query($sql) or die(mysql_error()); the links this, when user has clicked link, displays data according name="" in link matches column type in table products. <ul> <li name="books" class="menu-781"><a href="#">books</a><