Posts

Showing posts from June, 2015

javascript - Hiding a DIV on return of if/else statement -

i've been trying hide div id #signup within code i'm working in , can't seem work i've been doing. way of hiding div id fading out , in return fading in new div #test ? here's got! html (index) <form id="signup" action="<?=$_server['php_self']; ?>" method="get"> <fieldset> <label for="email" id="address-label">email address</label> <input type="text" name="email" id="email" /> <input type="image" src="i/join.jpg" name="submit" value="join" class="btn" alt="join" /> </fieldset> </form> <div id="response"> <? require_once('inc/store-address.php'); if($_get['submit']){ echo storeaddress(); } ?> <div id="test">test</div> </d

C++ Add random characters into a string array -

so want create 1000 words length of 5 random characters. in main have word[1000] when try run code, gives me error saying "expression:string subscript out of range". i'm not sure why because thought string arrays 2 dimensional? if tell me why code wrong i'd appreciate it. thanks. void createtext(string w[], int seed) { char ch; srand(seed); for(int = 0; < 1000; i++) { for(int j = 0; j < 5; j++) { ch = ('a' + rand() % 26); w[i][j] = ch; } } for(int = 0; < 1000; i++) { cout << w[i]; } cout << endl; } i suppose array w not have 1000 elements, remember here copy of string w[] . better passing pointer w (string* w) , have wrong. remember cout writes string out untill reaches '\0' character, might cause. quick session gdb help: gdb program ... run bt full should pinpoint problem. if it's kind of ide, learn how debug in it. valgrind or other memcheck visual leak detector or luke st

c++ - boost::bind member function WriteHandlerCheck error -

i'm trying bind function boost::asio::async_write , got semantic error in write.hpp class client{ public: client(const int &frame_,char* buf,const int& size_){ frame=frame_; b=buf; size=size_; } void donothing(){ //? } void handle(const boost::system::error_code& error,std::size_t bytes_transferred ){ //should handle socket being closed , data in buffer being released cout<<"bytes sent: "<<bytes_transferred<<endl; cout<<error<<endl; } void runclient() { try { tcp::resolver resolver(io_service); tcp::resolver::query query(tcp::v4(), host, port); tcp::resolver::iterator iterator = resolver.resolve(query); s=new boost::asio::ip::tcp::socket(io_service); boost::asio::connect(*s, iterator); std::cout << "sending png: frame"<<frame<<" size: "<<size<<"bytes ...

Grant remote access to mysql database -

i've used following statement give remote access mysql user grant privileges on *.* 'root'@'remoteip' identified 'password' grant option; i use following statement see result: select * information_schema.user_privileges grantee "'root'%"; i can see user root@remoteip has access. but when run script remote server trying insert rows, insert statement rejected. ideas why? have commented out skip-networking in my.cnf file. appreciated. both remote server , server mysql db debian7.

android - Change TextSize of tab when it's selected -

is possible change textsize of textview in tabwidget when it's selected ? yes possible, example: public class mainactivity extends tabactivity { static tabhost mytabs; mytabs = gettabhost(); mytabs.setontabchangedlistener(new ontabchangelistener() { @override public void ontabchanged(string arg0) { log.i("tag", "im in tab index: " + mytabs.getcurrenttab()); tabwidget tw = (tabwidget)tabhost.findviewbyid(android.r.id.tabs); view tabview = tw.getchildtabviewat(mytabs.getcurrenttab()); textview tv = (textview)tabview.findviewbyid(android.r.id.title); // changing textsize. tv.settextsize(20); } });

php - FPDF won't create new page -

i need create pdf file updating. data updated time time , every new data placed on new line of document. problem when first page of document filled, program won't create second page. here code using $newrecord="sample data"; $sourcefilename="pdf.pdf"; $pdf = new fpdi(); $pdf->setautopagebreak(true, 0); $pdf->aliasnbpages(); $pagecount = $pdf->setsourcefile($sourcefilename); //echo $pagecount; ($loop = 1; $loop <= $pagecount; $loop++) { $tplidx = $pdf->importpage($loop); $pdf->addpage(); $pdf->usetemplate($tplidx, 0, 14); } $pdf->setfont('arial'); $pdf->settextcolor(0,0,0); $pdf->setfontsize(14); $pdf->multicell(0,14,$newrecord); $pdf->output($sourcefilename, "f"); edit 1: here whole script using <?php $newrecord="sample data"; require_once('fpdf.php'); require_once('fpdi.php'); function createnewpdf($newrecord){//this function creates pdf there no

Flash / Actionscript line thickness will draw lines outside co-ordinates given in lineTo -

this basic question ran when drawing as. let's have following code. g.linestyle(20, 0xff0000, 1, false); g.moveto(10, 10); g.lineto(210, 10); because line thickness 20. draw line rectangle (0,0) (220, 20). i.e. thickness/2 added in each dimension. i wanted know if: 1. correct or got wrong? 2. every time need draw line don't want bound within e.g. drawing inside border need take account line not go outside particular area. correct? yes, 1) correct. regards 2) getrect() method not take stroke width in account. here code: stop(); var mc:movieclip = new movieclip(); var gr:graphics = mc.graphics; //draw rectangle 50x50 gr.linestyle(20); gr.beginfill(0, 0.5); gr.drawrect(0, 0, 50, 50); gr.endfill(); this.addchild(mc); //will trace (x=0, y=0, w=50, h=50) trace(mc.getrect(this)); //will trace (x=-10, y=-10, w=70, h=70) trace(mc.getbounds(this));

Android : Button dependency on checkbox in Alert dialog -

i've activity starts alert dialog prompt. have checkbox of don't show again. want button clickable after checkbox clicked, thnx in advance, hope words make understand looking for. here's code: @override protected void onresume() { alertdialog.builder adb = new alertdialog.builder(this); layoutinflater adbinflater = layoutinflater.from(this); view eulalayout = adbinflater.inflate(r.layout.note_for_layout, null); final checkbox dontshowagain = (checkbox) eulalayout.findviewbyid(r.id.skip); adb.setcancelable(false); adb.setview(eulalayout); adb.settitle("warning!"); adb.setmessage(""); adb.seticon(r.drawable.alert1); adb.setpositivebutton("accept", new dialoginterface.onclicklistener() { public void onclick(dialoginterface dialog, int which) { string checkboxresult = "not checked";

javascript - decode a data URL in php -

i need decode data url in php .this data url obtained via ajax. have used file reader encoded data url of image.this data url passed php via ajax: $.ajax({ url: app, async: false, type:"post", data : "file="+strglobalimagedata, datatype: "jsonp", contenttype: 'application/x-www-form-urlencoded', processdata:false, jsonp: "jsoncallback", success: function(html){ alert("thank you. in touch you"); }, error: function(){ alert("thank you. in touch you"); } }); how this? $image =$_post['file'] ; was looking for? let me know

numbers - Why does java.lang.Long's .longValue() cast its (long) instance value to long? -

i have been investigating java.lang.long class source code. consider this: public final class long extends number implements comparable<long> { .... private final long value; .... public long longvalue() { return (long)value; } .... } what reason cast long long ? why not reralize serialize (?) number class in case? p.s.1 source code link i have these possible explanations: carelessness of developers compliance unified code style it made special case, don't understand why. p.s.2 my java version - 1.7.0_45-b18 p.s.3 information: integer : public final class integer extends number implements comparable<integer> { .... private final int value; .... public int intvalue() { return value; } .... } short : public final class short extends number implements comparable<short> { ....

c# - Windows Form Application with Microsoft Access Database Deployment -

after creating setup , installing project, got confused .accdb file located. found out located @ "c:\users\mypc\appdata\local\virtualstore\program files (x86)\winform\winform\records.accdb". how can modify location of database file located @ same folder executable file , @ same time used database? in advance. how can modify location of database file located @ same folder executable file if want able update database don't want put in same folder executable file(s) if being deployed standard location described %programfiles% environment variable (e.g., c:\program files\... ). users not have write access folders attempts update database in location fail. instead, should consider deploying database file(s) location users do have read/write access. example, use folders defined either %userprofile% (for specific user), or %public% (for users).

How to custom user url in BuddyPress and WordPress? -

thanks support! need custom user url in page using wordpress , buddypress. example: from: (current) http://example.com/user/pum_su411 to http://example.com/user/548234 with 548234 id of user. i want after completed custom, users have url above automatically. thanks solutions! add code theme functions.php file. function _bp_core_get_user_domain($domain, $user_id, $user_nicename = false, $user_login = false) { if ( empty( $user_id ) ){ return; } if( isset($user_nicename) ){ $user_nicename = bp_core_get_username($user_id); } $after_domain = bp_get_members_root_slug() . '/' . $user_id; $domain = trailingslashit( bp_get_root_domain() . '/' . $after_domain ); $domain = apply_filters( 'bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login ); if ( !empty( $domain ) ) { wp_cache_set( 'bp_user_d

regex - Matching address in mbox format in python -

i trying address of sender in mbox formated mails in python. when line contains sender, looks from: mister x <misterx@domain> . able retrieve mail address with, example, re.findall('<[a-za-z0-9\.]+@[a-za-z0-9\.]+>', str) . think should fine since email addresses, far know, cannot contain other characters. not understand why expression <*@*> , expected match characters in email address not work @ all. in fact, re.findall('<*@*>', 'from: mister x <misterx@domain>') returns ['>'] . <* means: "the character < 0 or more times". looking <.*@.*>

assembly - What's wrong with this code in ARM -

i compiled simple program add 2 number , print on console.i have compiled on rpi board.i think compiled fine when run getting segmentation fault. .text .global main .extern print out: .ascii "the sum %d\n\0" main: push {ip,lr} mov r0,#5 mov r1,#4 add r2,r1,r0 ldr r2,=out bl printf pop {ip,pc} stop: b stop is because didn't follow arm eabi properly? could let me know doing wrong? the format string printf ( out ) needs go in r0, not r2. change: ldr r2,=out to: ldr r0,=out also if want print sum of 4 , 5 should in r1 (otherwise you're printing 4). change: add r2,r1,r0 to: add r1,r1,r0

javascript - Mockjax dynamic mock stops working with `dataType="Script"` -

i have dynamic mock setup using mockjax, , works of ajax requests, fails when datatype set script , , lets request fall through regular ajax handler. // gets mocked $.ajax({ type: "get", url: "http://myurl.com/myfile.js?_=1395314460347" }) // not mocked! $.ajax({ type: "get", datatype: "script", url: "http://myurl.com/myfile.js?_=1395314460347" }) how can configure dynamic mocks in mockjax intercept requests datatype set? update: example code mockjax definition i creating dynamic mock, defining via function, not plain object, this... $.mockjax(function(settings) { // settings.url == '/restful/<service>' var service = settings.url.match(/\/restful\/(.*)$/); if ( service ) { return { proxy: '/mocks/' + service[1] + '.json', // handle `datatype: 'script'` datatype: 'application/javascript' }; } return; }); this

javascript - How to submit a form using jQuery? -

i want submit form using jquery, have 4 fields needed checked, when submit, displays first alert submit doesn't check if fields valid or not. what's error in code? appreciated. $(document).ready(function(){ $('input[name=subdomain]').keyup(subdomain_check); $('input[name=password]').keyup(password_strenght); $('input[name=c_password]').keyup(password_check); $('input[name=email]').keyup(email_check); $('#install').on('submit', function(){ alert("submit"); if ($('input[name=subdomain]').valid() == true && $('input[name=password]').valid() == true && $('input[name=c_password]').valid() == true && $('input[name=email]').valid() == true){ alert("true"); return true; } else { alert("false"); return false; } }); }); here's html form : <form class="form-horizontal" method="post" id=&qu

javascript - d3.js Rescaling shape path and keeping it in the center -

Image
in part of application - trying rescale path shape , keep inside viewport. i've managed rescale shape accordingly translation needs adjusted keep inside view port. http://jsfiddle.net/ppmqq/101/ rescalepath: function(zoomlevel){ //now need rescale path map , region match? var ratiox = zoomlevel/this.width; var ratioy = zoomlevel/this.height; this.svg.attr("transform", "scale("+zoomlevel+") translate("+ratiox+", "+ratioy+")"); }, bindevents: function(){ var = this; $(".up").click(function(e) { e.preventdefault(); that.rescalepath(3); }); $(".down").click(function(e) { e.preventdefault(); that.rescalepath(12); }); } what best way of achieving this? - surely not right set translate information - there n

Does Primefaces 2.2.1 version supports IE 9 and 10 -

currently using primefaces 2.2.1 version our web application. in ie9 buttons not working(when click on button nothing happening) , pagination not working. primefaces 2.2.1 version supports ie 9 , ie 10. if doesn't support latest versions of ie version of primefaces should use. thanks help. you're using really ancient version of primefaces. current version 4.0. aside compatibility issues newest browsers, should expect more , more problems finding help. should consider upgrading versions 3.5 or 4.0. please note version 3.5 primefaces no longer supports ie 7. ie 8, 9 , 10 supported.

linux - Varnish - virtualhosts & multiple backends on one server -

i seem having confusing issues varnish. i've got simple setup (as haven't been using long, haven't got more complex). backend default { .host = "11.22.33.208"; .port = "8081"; } backend default2 { .host = "11.22.33.210"; .port = "8081"; } ## multiple virtual hosts sub vcl_recv { if (req.http.host ~ "^domain1.com(:[0-9]+)?$") { set req.backend = default; } elsif (req.http.host ~ "^domain2.co.uk(:[0-9]+)?$") { set req.backend = default; } elsif (req.http.host ~ "^domain3.com(:[0-9]+)?$") { set req.backend = default2; } now, seems work domain1.com, domain2.co.uk (plus subdomains - i'm not sure why should be, regexes have ^ anchor tag ?). problem is, doesn't seem work domain3.com, pointing different backend. well, work, in ends @ server's default page (it's cpanel machine), rather timing out. fear not, i'm more command line panel user :) i've che

sql - Find duplicates takes a long itme -

i'm having following table layout: 4 different tables, each containing around 10 15 million entries. 3 string attributes of each table same (let's call them id, name1, name2). want read entries having same id column different (name1,name2) tuples. estimated less 0.5 % of entries matching. we've created view allentries (basically union of relevant attributes on 4 tables) , our query looks this: select * allentries group id having count(distinct(name1)) > 1 or count(distinct(name2)) > 1 executing query in our test database 2 million entries in each table (i.e. 8 million entries in view) takes around 2 3 minutes (nice server). q: there performance improvement possible improve performance? try cte row_number() instead of traditional group by/having approach: ;with ctedups ( select * ,row_number() over(partition name1 order id) rn1 ,row_number() over(partition name2 order id) rn2 allentries ) select * ctedup

java - Should the service in an MVC app return entities or list of entities -

i've mvc application spring , hibernate i've each controller calling service layer call dao controller > service > dao should service return entities? i trying move logic controller service. @ moment logic in controller autenticate retrieve user information (service call) retrieve appointments (other service call) create status response in xml return appointemnts as can see if move logic in service need service call return xml instead of user or list of appointemts. is right way or should keep logic in controller , return service entities? as far understand it, think immaterial you. must remember to keep service layer clean of data access implementations (for example: import java.sql.whatever bad idea inside service layer) the service layer ideal place put declarative transaction management in. idea write transactional service layer methods, , under that, have totally naive dao layer have connections injected, errors managed outside,

Android / iPhone href link not firing - focus rectangle appearing instead -

i having problem on android , iphone versions of html5 site using responsive layout. links not firing unless hold down on them 1 second. otherwise act if hover event taking place. example code: <div class="homepagecardiv"> <div class="note"> <div class="imgdiv"> **<a href="ficha-vehiculo.php?v=19"><img src="_imgup/19/thumbnail/imagen_2.jpg" alt=""></a>** </div> <h3>mitsubishi asx<br>asx 200 di-d challenge 4wd (2010)</h3> <h4>16.500€</h4> <div class="verdet"> <p>**<a href="ficha-vehiculo.php?v=19" class="homebut">ver detalle</a>**</p> </div> <div class="cornerimage"> <img src="images/fold.png" alt="">

Is it possible to use a PHP class in AJAX? -

i started wonder possible create class in php, instance 1 containing books title, author , publisher, , using class in ajax? to clarify. using meant possible access variables in class or use functions created in php, such setters/getters. what can create separate class file , function trigger methods of class. ajax send requests file functions , call method of class need.

Casting with C# source code in PowerShell -

i have custom c# method in powershell script writing. goal of function figure out if line exists in file. here source: $source = @" using system; public class differ { public static bool isinfile(array file, string line) { foreach(string curline in file) { if(curline.replace(" ", "") == line.replace(" ", "")) { return true; } } return false; } } "@ add-type -typedefinition $source $file1 = get-content "path\to\file" $file2 = get-content "path\to\file" $diff = new-object system.collections.specialized.ordereddictionary $linenumber = 0 $file1 | foreach { [string]$theline = $_ if ([differ]::isinfile([array]$file2, [string]$theline) -eq $false -and -not [system.string]::isnullorwhitespace($theline)) { $diff.add($linenumber, $_.tostring().trim()) } $linenumber++ } $diffheader = @{expression={

Write bits in different bytes c c++ -

this question exact duplicate of: extract , combine bits different bytes c c++ 1 answer i have declared array of bytes: uint8_t memory[123]; which have filled with: memory[0]=0xff; memory[1]=0x00; memory[2]=0xff; memory[3]=0x00; memory[4]=0xff; and requests user write in bits. example, user provides starting bit (ex:10), amount of bits (ex:9) , bits set. in example provided receive 2 bytes: setbit[0]=0b11110010; setbit[1]=0b00000001; //padded zeros bits this used modbus big-endian protocol. have come following code: for(int j=findbyteinit;j<(findbytefinal);j++){ aux[0]=(unsigned char) (setbit[j]>>(startingbit-(8*findbyteinit))); aux[1]=(unsigned char) (setbit[j+1]<<(startingbit-(8*findbyteinit))); memory[j]=(unsigned char) (aux[0] & memory[j] ); memory[j+1]=(unsigned char) (aux[1] & memory[j+1] ); aux[0]=0x00;//

php - Submit Button with multiple ID Inside Looping?(Shopping Cart) -

Image
i want create shoping cart on php, the code simple, when customer fill qty , click button add cart, code save product id , qty cart table. problem form inside looping. , how can id , qty button customer click. the program this and script this <?php if(isset($_post[add])) { $qty = $_post[qty]; $harga = $_post[harga_asli]; $id = $_post[id]; print_r($_post); } $kolom = 3; $sql = "select *,format(harga,0)as harga_digit item"; $hasil = mysql_query($sql); echo "<form method=post action=index.php>"; echo "<table> <tr>"; $i = 0; while($data=mysql_fetch_array($hasil)) { if($i >= $kolom) { echo "</tr><tr>"; $i = 0; }

c++ - Android NDK : Aborting. Stop -

Image
i'm trying call c++ method in java coding. i received android ndk : aborting. stop when defined android.mk file below : local_path := $(call my-dir) include $(clear_vars) local_module := ffmpeg local_src_files := libs/ffmpeg.so include $(prebuilt_shared_library) include $(clear_vars) local_module := ffmpeg local_src_files := ffmpeg.cpp local_shared_libraries := ffmpeg include $(build_shared_library) but if defined this, run : local_path := $(call my-dir) include $(clear_vars) local_module := ffmpeg local_src_files := libs/ffmpeg.so include $(build_shared_library) questions : 1 - how fix error? 2 - in android.mk file, can not call libs/ffmpeg.so , ffmpeg.cpp in same time? people know this, please tell me, thanks, p/s : project structure : when seeing android.mk structure . i think need change android.mk file : local_path := $(call my-dir) include $(clear_vars) local_module := ffmpeg local_src_files := libs/ffmpeg.s

quartz.net - building a quartz cron expression -

basicly need create complex quartz cron expression strings .net. have idea how achieve that? for example: everyday, every (2 hours, 1 minutes, 10 seconds), between 10am - 19pm or @ least can please me understand cron strings manually create them? of course did homework before asking here , looked quartz.net tutorials, several jquery plugins , cron string generator web sites of them generating or giving examples of simple crons "on every seconds/minutes/hours", "on fridays @ 11 am".

import html table to datatable in c# -

i wanted import data html table datatable. i've read best way use html agility. code used i'm getting error 'htmlagilitypack.htmlnodecollection' not contain definition 'select' , no extension method 'select' accepting first argument of type 'htmlagilitypack.htmlnodecollection' found (are missing using directive or assembly reference?) c:\webbrowser\webbrowsercontroldialogs\mainform.cs. this error line : otable.rows.add(row.selectnodes("td").select(td => td.innertext).toarray()); any idea on how fix ? appreciated htmlagilitypack.htmldocument doc = new htmlagilitypack.htmldocument(); var document = webbrowser1.document; var documentasihtmldocument3 = (mshtml.ihtmldocument3)document.domdocument; var content = documentasihtmldocument3.documentelement.outerhtml; doc.loadhtml(content); datatable otable = new datatable(); otable.columns.add("id .", typeof(string)); otable.columns.add("art.", typ

c++ - Why raw socket sendto() function fails with 10022? -

i developing protocol fuzzer icmp, tcp, udp , on under vs2010. have sent out icmp , udp packets raw socket interface. encountered problem when sending tcp. my environment: windows 7 ultimate x64, administrator account. here way: 1) construct transport header , data myself. 2) use raw socket ipv4 header , below. rawconnect() function used create such raw socket. strip ip address, , strprotocol ip protocol number need specified (like icmp 1, igmp 2, tcp 6, udp 17). because didn't construct ip header myself (m_bselfconstructipheader = false), ip protocol number necessary. didn't know if used right or not? 3) use sendto() function send buffer, returns -1, , wsagetlasterror() returns 10022 means "an invalid argument supplied." below code, thx! #include "stdafx.h" #include "afrawsocket.h" #define ip_hdrincl 2 afrawsocket::afrawsocket() { m_socket = null; m_bselfconstructipheader = false; } cstring afrawsocket::itos(int i) {

sql - Regular expression REGEXP_LIKE -

please me regular expression: where regexp_like(dbfield, '*п* 2($| )', 'i') but find: "кран № 2 пом. 144" "кр. № 2 пом. 260" ... i don't understand why find that. must "п" before "2". what's wrong? (db oracle) regexp п* means symbol "п", repeated 0 or more times try where regexp_like(dbfield, 'п.*2($| )', 'i') or , faster where lower(dbfield)||' ' '%п%2 %'

android - Push from Device to Device -

when want send push notification 1 device another, have learned, need send message device server , server send other device! so, need 2 id's, app-id , device-id, right. how device-id generated? randomly me? , then, how stored @ e.g. parse? can light questions?

java - Nutch 2.2.1 doesnt continue after Injector job -

i learning nutch , trying carawl per tutorial .i working on ubuntu machinewith bash shell. when run script, execution happens, nothing happens after , injectorjob: starting @ 2014-03-23 09:28:50 injectorjob: injecting urldir: urls/seed.txt i have waited hours, tried running same sudo . same issue occurs. have tried default urls given in tutorial well. can probable errors? what missing didnt add proxy , port details in nutch-site.xml, accessing through proxy. setting same ant or jvm not enough

converting c++ DTW code to java -

i want translate code c++ java. original code implements fast dtw algorithm. piece of code couldn't figure out i attribute i'm not sure hence, can't convert it. the error in java in statements l_buff+i & u_buff+i because plus operator not supported between int i & double[] l_buff,u_buff . i have included statements involves i int i; for(i=0; i<ep; i++) { /// bunch of data has been read , pick 1 of them @ time use d = buffer[i]; /// calculate sum , sum square ex += d; ex2 += d*d; /// t circular array keeping current data t[i%m] = d; /// double size avoiding using modulo "%" operator t[(i%m)+m] = d; /// start task when there more m-1 points in current chunk if( >= m-1 ) { mean = ex/m; std = ex2/m; std = math.sqrt(std-mean*mean); /// compute start location of data in current circular array, t j = (i+1)%m; /// start location of data in cur

extjs - Sencha Touch. NestedList move, insert, remove items -

my question how move, insert , remove items in nestedlist have nestedlist this: // model ext.define('myapp.model.comments', { extend: 'ext.data.model', config: { fields: [ {name: 'text', type: 'string'} ] } }); // nestedlist ext.define('myapp.view.comments', { requires: [ 'ext.data.treestore' ], config: { id: 'comments', store: { type: 'tree', root: {}, model: 'myapp.model.comments', proxy: { type: 'ajax', actionmethods: {read: 'post'}, url: './comments.php', timeout: 4000, enablepagingparams: false, extraparams: { action: 'get-comments' } } }, displayfield: 'text', detailcard:

TextView & Button Not Showing After Add DatePicker In Android -

i new in android. have app picks user date of birth using datepicker . when add feature xml elements textview & button not showing. how's possible? may know correct way achieve objective? maybe question basic, did't find suitable solution.please me out here code : public class userdobactivity extends activity { datepicker datepickerbirthday; textview textviewuserdate; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_user_dob); actionbar ab = getactionbar(); ab.setdisplayuselogoenabled(false); ab.setdisplayshowhomeenabled(true); ab.setdisplayoptions(actionbar.display_show_custom); ab.setcustomview(r.layout.actionbar); ab.setdisplayhomeasupenabled(true); colordrawable colordrawable = new colordrawable(color.parsecolor("#33ccff")); ab.setbackgrounddrawable(colordrawable); // create date picker datepickerbirthday = new

C++ typedef function definition as a class member to use later for function pointer? -

i need have class stores function definition/prototype class member in order use later function pointers based on definition. #include <cstdlib> #include <cstdio> #include <functional> template<typename... ts> class function; template <typename r> class function<r> { public: using functype = r (*) (); function() { printf("r()\n"); } }; template <typename r, typename... a> class function<r, a...> { public: using functype = r (*) (a...); function() { printf("r(a)\n"); } }; void fn1(int i) { printf("called fn1: %d\n", i); } void fn2(int i, float f) { printf("called fn2: %d, %f\n", i, f); } void fn3() { printf("called fn3: n/a \n"); } int main(int argc, char **argv) { function<void, int> myfuncx; function<void, int, float> myfuncy; function<void> myfuncz; myfuncx.functype mf1 = fn1; myfuncy.func

Fuse Example File System - The file changed on disk do you want to reload the file -

Image
running built-in fuse hellofs example file system, shows hello.txt file on root. opening file show error "...the file changed on disk want reload file. reload/cancel" how can remove error. i facing same error in custom file system because had taken hellofs starting point. make question simple quoted hellofs code because same error in hellofs also. example code, log , screenshot of error below: hellofs java code: package net.fusejna.examples; import java.io.file; import java.nio.bytebuffer; import net.fusejna.directoryfiller; import net.fusejna.errorcodes; import net.fusejna.fuseexception; import net.fusejna.structfusefileinfo.fileinfowrapper; import net.fusejna.structstat.statwrapper; import net.fusejna.types.typemode.nodetype; import net.fusejna.util.fusefilesystemadapterfull; public class hellofs extends fusefilesystemadapterfull { public static void main(final string... args) throws fuseexception { if (args.length != 1) { syst

java - Google OAUTH: The redirect URI in the request did not match a registered redirect URI -

i trying make upload youtube java based web app, spent few days understand , problem , cannot it, pulling hair out off head. i registered web app in google console, got pair of client id , secret , possibility download json type file config. so here config: { "web":{ "auth_uri":"https://accounts.google.com/o/oauth2/auth", "client_secret":"***", "token_uri":"https://accounts.google.com/o/oauth2/token", "client_email":"***", "redirect_uris":["http://localhost:8080/webapp/youtube-callback.html","http://www.webapp.md/youtube-callback.html"], "client_x509_cert_url":"***", "client_id":"***", "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs", "javascript_origins":["http://www.webapp.md/"

Define 2D array in scala -

i have call function defined foo(seq[seq[int]]) in scala i have defined int array as: var myarray = array.ofdim[int](n,n) and calling foo(myarray) however, getting error: type mismatch; found : array[array[int]] required: seq[seq[int]] if try define array as var myarray = seq[seq[int]](n,n) i error: type mismatch; found : int required: seq[int] why that? struggling more 2 hours, find might problem, have no idea... can me this? well, array no subclass of seq , why error. you can convert array[array[int]] seq[seq[int]] that: val myarray = array.ofdim[int](n,n) //use vals if can, arrays mutable val myseq = myarray.map(_.toseq).toseq //convert inner arrays seq , outer array seq foo(myseq) keep in mind array mutable, while seq not.

No route matches (rails) -

Image
i trying create simple link page in rails app doesnt seem work.even though have configured route posts index page gives me following error: no route matches {:action=>"posts", :lat=>5, :controller=>"coordinates"} here's directory structure: my routes.rb file highwaypolice::application.routes.draw resources:posts resources:coords resources:coordinates 'posts', to: 'posts#index' end ../app/views/coordinates/index.html.erb <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=aizasycthq7kv6r4-cilkpujzek5e-uzgbgdjku&sensor=false"> </script> <script type = "text/javascript"> function initialize() {console.log("click"); var mapoptions = { center: new google.maps.latlng(-34.397, 150.644), zoo

python - What information is __init__.storing? -

i read somewhere __init__ stores information while creating object. so, let's have code: class bankaccount(object): def __init__(self, deposit): self.amount = deposit def withdraw(self, amount): self.amount -= amount def deposit(self, amount): self.amount += amount def balance(self): return self.amount myaccount = bankaccount(16.20) x = raw_input("what do?") if x == "deposit": myaccount.deposit(int(float(raw_input("how deposit?")))) print "total balance is: ", myaccount.balance() elif x == "withdraw": myaccount.withdraw(int(float(raw_input("how withdraw?")))) print "total balance is: ", myaccount.balance() else: print "please choose 'withdraw' or 'deposit'. thank you." what __init__ doing or storing. don't understand "self.amount" or how making = deposit anything. "self

ios - NSPredicate apply predicate on an Object within an object array. -

i have array, containing objects of order item class, , in each order item there article object in it, contains details. now want order items have specific name in article of individual order item. how should write nspredicate ? what trying like: nspredicate *predicate = [nspredicate predicatewithformat:@"self.itemarticle.articlename contains[c] '%@'", searchstring]; nsarray *resultsarray = [allorderitemarray filteredarrayusingpredicate: predicate]; try removig both self. part , single quotes place holder (and close double quotes). nspredicate *predicate = [nspredicate predicatewithformat:@"itemarticle.articlename contains[c] %@", searchstring]; nsarray *resultsarray = [allorderitemarray filteredarrayusingpredicate: predicate];

arrays - find largest rectangle not (necessary) aligned with image boundary in binary matrix -

i using this solution find rectangles aligned image border in binary matrix. suppose want find rectangle not aligned image border, , don't know orientation; fastest way find it? for sake of example, let's rectangle containing 1's. example: 1 1 1 1 0 0 0 0 0 1 0 0 1 1 1 0 1 1 1 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 1 1 1 0 1 0 0 1 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 then algorithm described in solution described above find rectangle of size 6 (3x2). find bigger rectangle tilted; can see rectanble of @ least size 10 or more... i working in c/c++ algorithm description in language or pseudo-code me lot. some more details: there can more 1 rectangle in image: need biggest only the rectangle not beautiful rectangle in image (i adapted example above little bit) i work on large images (1280x1024) i'm looking fastest solution (a brute-force o(n³) algorithm slow) (optional) if solution can parallellized, pl

Wordpress and qTranslate - getting current language in functions.php -

i using qtranslate plugin wordpress site , have detect active language in themes functions.php file. detection function qtrans_getlanguage() working, however, shows default language (en) active, though have switched in page itself. how can detect language in function file? this worked me: if (qtrans_getlanguage() == 'en') { // english print "hello world!"; } elseif (qtrans_getlanguage() == 'es') { // spanish print "hola mundo!"; } notice change in qtranslate x (the new version) : if (qtranxf_getlanguage() == 'en') { // english print "hello world!"; } elseif (qtranxf_getlanguage() == 'es') { // spanish print "hola mundo!"; } there compatibility functions in plugin options according this notice apply code need php knowledge, , works translate exact parts of wordpress theme

ruby - String manipulation using MD5 in rails 3 -

i have big string approx 4000 characters i want encrypt , decypt using md5 because of want convert in small string please me lot of finding found base64 not our solution please 1 me my_string="abcdefghhhhhhhhhhhhhhhhhhhhhh" base64.encode64(my_string) it gives lengthy string. encrypting string not make smaller, @ best same length. think looking way compress string. aside, md5 one-way hashing algorithm, means designed, there way of recovering source string (it turns out designed rather poorly ).

java - JavaFX WebView not working using a untrusted SSL certificate -

i'm developing simple embedded browser using javafx: final webview browser = new webview(); final webengine webengine = browser.getengine(); when use webengine load http website, works fine: webengine.load("http://google.es"); despite this, if try load website untrusted certificate (my own ssl certificate), webengine not work , white screen in browser. is there way (automatically) trust in ssl certificate? finally, solved question. should add code before loading website: // create trust manager not validate certificate chains trustmanager[] trustallcerts = new trustmanager[] { new x509trustmanager() { public java.security.cert.x509certificate[] getacceptedissuers() { return null; } public void checkclienttrusted( java.security.cert.x509certificate[] certs, string authtype) { } public void checkservertrusted( java.security.cert.x509certificate[] certs,