Posts

Showing posts from February, 2014

Image resizing fail jQuery animate -

when using jquery .animate() function on images, works fine on desktops, using android 4.2 device , browser, fails. i use function animate image resize. animation starts, duplicate image in mobile browser original size. duplicate image stays there when animation completed. anyone recognizes this? jquery fail or can own failure? $( "#imageid" ).animate( { height: "67px" }, 1500 );

mysql - Rails: Issue with recieving nested forms with has many through join -

i seem having problem receiving products through join table, it's giving me strange error seems receiving no id order. can assume because order has not been created yet, creating order during step anyway, order doesn't have id yet. problem. here error recieve: activerecord::recordnotfound in orderscontroller#create couldn't find product id=1 order id= rails.root: /billingsystem application trace | framework trace | full trace app/controllers/orders_controller.rb:10:in `new' app/controllers/orders_controller.rb:10:in `create' request parameters: {"utf8"=>"✓", "authenticity_token"=>"je2wderoxe7pkwbhn60kafguxwaq8qdw4wbru51smfg=", "order"=>{"client_id"=>"1", "products_attributes"=>{"1368396234677"=>{"id"=>"1", "_destroy"=>"false"}}}, "commit"=>"create order"} show session dump

image - losing quality after adding watermark to the picture -

i'm working on website wich haven't create/developed anyway users can upload image , when , there's function create duplicate of image watermark but copy watermark has low quality , it's size smaller original image i dont see lowering quality , maybe it's how ci watermark works ?! without watermark http://img.akstube.ir/images/2013/05/dsc_0168_69_70_tonemapped.jpg with watermark http://img.akstube.ir/images/2013/05/irwm_dsc_0168_69_70_tonemapped.jpg here function function ir_watermark($file,$name='',$rebuild=false) { $ci = &get_instance(); $pathinfo = pathinfo($file); $filename = $pathinfo['basename']; $path = $pathinfo['dirname']; $new_image = $path . '/irwm_'. $filename; $path_to_img = base_url(str_replace(base_path(),'',$new_image)); if ($rebuild == false) if (file_exists($new_image)) { if ($ci->uri->segment(1) == 'test') echo "<img src='{$path

C# for-loop performance estimates: i++ vs. ++i implementation: which is faster? -

my question relates performance comparison (numeric estimates) pertinent following sample cases implementing for-loop in c# 4.0 and/or c# 5.0 in 4 different manners: for (int i=0; i<10000; i++;){string _s="a";} (int i=0; i<10000; ++i;){string _s="a";} (int i=10000; i>0; i--;){string _s="a";} (int i=10000; i>; --i;){string _s="a";} question : of following implementations provide better performance (execution time) in generic for-loop implemented in c# 4.0 or c# 5.0? note 1 : string _s="a"; sample operation, potentially omitted testing purpose. note 2 : far, per discussion on ( is there performance difference between i++ , ++i in c? ) seems ++i runs faster i++ in c++. the optimizer should know pre-incremented value of i never used, , therefore should same (simply increment i ). the reason i++ may slower ++i if compiler has save off old, pre-incremented value before incrementing i . however, given l

image - Getting canvas data without using canvas.toDataURL? -

i'm making painting application browser want work (nintendo 3ds browser) doesn't support canvas.todataurl. i know it's possible getting canvas data without canvas.todataurl, because robdeprop (creator of 3dsplaza.com) created painting application nintendo 3ds browser. i asked how, , replied the 3ds not support functions canvas data. then, how do it? every time line drawn save begin coordinates , end coordinates of line array. when user hits save, convert array string , send php file post parameter. in php file convert string array. use php gd functions draw each line on image. save image. imagecreatetruecolor, imageline , imagepng need think. but have no idea how this... help? in advance.. i'm new here please don't down note ;-; https://code.google.com/p/todataurl-png-js/ it may android worth shot.

Django query to filter out current user from a list of users -

i have query returns list of users. contains current logged in user , make same query without returning user. in models book has foreignkey library called library , library has m2m users called subscribers. it's not important simple query users should work example well. users = book.library.subscribers.all() request.user ends in users , don't want that. know take out of list after making query know if there directly way exclude request.user query. you can do book.library.subscribers.exclude(user=request.user) assuming, user attribute stores users

Config.php security and Facebook Secret Key -

some how developer getting our app secret , using perform https/api banned requests banning our users our app. how getting secret key have listed in our config.php file located on server. cannot find breaches on server , config.php non-readable or shown anywhere. will whitelists settings made available facebook block hacker/developer banning or blocking changes app settings? i suggest reset app secret using presently generate new 1 , restrict extent of damage. you may utilize server ip whitelist according documentation suggests that we enable restrict api calls come set of white-listed servers. can set whitelist going advanced section of developer settings in app dashboard , set 'server whitelist' field. and may further utilize update settings ip whitelist restrict changes app's settings. quoting documentation , we allow specify whitelist of ip addresses must used update app settings. helps prevent attacks ensuring developers using compa

Remove values from url using php -

i appending values url in order pass them next page using tag. want remove appended values once access them on next page without reloading page. there anyway in php? want display updated url in browser. use parse_url() split url components , put components want form new url. if want modify query string, call parse_str() on it, passing array second parameter, , modify array.

Using echo with lists in php? -

i have following php code: $getnews = mysql_query("select * news order id desc") or die(mysql_error()); while ($row = mysql_fetch_assoc($getnews)) { $id = $row['id']; $title = $row['title']; $body = $row['body']; $date = $row['date']; echo "<div class=\"title\">$title</div><br>"; echo nl2br($body); echo "<br><div class=\"date_time\">".time_ago($date)."</div>"; echo "<hr>"; } this used create news feed , use echo print out within updates. there way in maybe use list print out each update instead of way im doing it? or possible create div around each update while loop creates? i'm sorry if question not clear help! my newsfeed creates updates in news feed twitter. each update printed out using echo , surrounded . im trying find way in can create list or div entire layout of each update. im finding difficult arran

facebook - Django-Social-Auth force user grant permission -

i'm create , facebook app must require publish_stream publish information on user's wall. when user interact auth dialog have option skipping publish on wall behave. have ask if django-social-auth support check permission want, if user reject it, reopen auth dialog user can grant it. i've put publish_stream in facebook extend permissions settings.

mod rewrite - Non Port 80 Web Server and Pretty URL's -

this "blocked port 80" related question, maybe bit unique. i've yet find answer. it's more academic know running production server @ house ridiculous idea. i'm running development server (lamp) @ home isp blocks port 80. dns domain set "url redirect" ip , port number. router port-forwarding server, , have apache set it's listening on port 8081. the issue when access domain, url in browser resolved domain name ip , port number, , displayed such. for example, type "www.banana.com" browser, site displayed url shown "12.23.456.11:8081". is there way fix domain name not become ip , port number? can use apache proxy functionality somehow? could use mod_rewrite change ip , port number domain name? thanks in advance! this question has 3 parts. first issue of domain: in order substitute domain name in place of ip address need name server can map desired name address. @ host level , not port level domain name e

How create dynamic GroupBox in C# -

i trying create groupbox dynamically , these gb create on selection on checkbox. means have 5 check boxes if select 1st cb 1 gb other dynamic checkbox shall created, if select 3rd check gb shall created few more other checkboxes. trying code whee able create dynamic checkboxes fixed groupbox created @ design time. my scenario - 5 branches have multiple batches. user choose branch dynamically checkboxes , on basis btaches displayed in groupbox each branch. branch1 branch2 branch3 branch4 branch5 if user select 3rd , 5th branch gb1 show branch3's batches , gb2 shall show branch5's batches here code - private void ro_selectedindexchanged(object sender, eventargs e) { groupbox1.controls.clear(); string m = ro.selecteditem.tostring(); console.writeline(m); acommand2 = new oledbcommand("select * branch_tbl,region_tbl branch_tbl.region_id=region_tbl.region_id , region_tbl.region_name '"+m +"'", main_connection);

jqgrid - beforeShowform in inline editing -

is possible fire beforshowform event in inline editing, because per wiki m not able find solution call before show form in inline editing option editformbutton:true . appreciated inline editing don't display form. usage of beforeshowform not possible in inline editing mode. you wrote usage of editformbutton: true . use formatter: "actions" property. in case use form editing. can specify form editing options inside of editoptions option (see the documentation ). usage of formatter: "actions" should below formatter: "actions", formatoptions: { editformbutton: true, editoptions: { beforeshowform: function ($form) { alert("in beforeshowform"); } } }

php - select the submenu of a menu and append it to the sidebar -

<li class="dd-item" data-id="5"> <div class="dd-handle"> <a class="color5" href="index.php?seite=eltern-info">eltern-info</a> </div> <ol class="dd-list" style="display: none;"> <li class="dd-item" data-id="1"> <div class="dd-handle"> <a class="color1" href="index.php?seite=impressum">impressum</a> </div> </li> </ol> </li> i have menu this(the example 1 element menu , submenu) jquery function open submenu on hover. need make when menu active show submenu in sidebar. there way achive jquery? when menu eltern-info active html of side bar submenu?

Flash/Actionscript 3 - import/embed XML file for export? -

how import or embed xml file can export 100% independent swf? project reads external xml file text fields , images. when export swf, none of images/text show unless have xml file in same directory. want 100% independent swf without need xml. here have far, code tutorial: var imagearray:array = new array(); var painterarray:array = new array(); var titlearray:array = new array(); var datearray:array = new array(); //loader event xml var loader:urlloader = new urlloader(); loader.addeventlistener(event.complete, onloaded); var xml:xml; loader.load(new urlrequest("mday.xml")); function onloaded(e:event):void { //load xml xml=new xml(e.target.data); var il:xmllist=xml.images; listlength=il.length(); //fill array xml populatearray(); } function populatearray():void { //takes properties defined in xml , stores them arrays var i:number; (i = 0; < listlength; i++) { imagearray[i]=xml.images[i].pic; titlearray[i]=xml.

PHP Mail function not working on Web Services -

i using 2 different servers dev site , live site. webservice function send email confirmation working on dev site not working in live site. email confirmation function is: function getemailconfirmation($username, $checklistid,$userid,$answerbulkid, $totalsubmitted){ if ( ($userid == '') || (!isset($userid)) ) { return error("partial"); } $entry = new entry(); $entry_date_check = date('y-m-d'); //for check if $count_tbl_answers = $entry->listentry("select count(*) total_from_answers tbl_answers user_id='".$userid."' , answer_bulk_id ='".$answerbulkid."' , date(ent_date) = '".$entry_date_check."' "); $to = "****@gmail.com"; $subject = "tdl checklist email"; $message = "hello there! \n user id: ".$userid." \n user name: ".$username."\n check list id: ".$checklistid."\n answer bulk id: &quo

asp.net - jQuery how to use variables -

the code below working $(function () { $('.bigdiv input:checkbox').click(function () { alert('working'); }); }); but 1 not working var checkboxes = $('.bigdiv input:checkbox'); $(function () { checkboxes.click(function () { alert('working'); }); }); chances have put line: var checkboxes = $('.bigdiv input:checkbox'); inside $(function () { block document ready before run previous line of code. if document isn't done loading, there won't checkboxes find. point of $(function () { /* code here */}); wait until document done loading before running code in callback function. you should able this: $(function () { var checkboxes = $('.bigdiv input:checkbox'); checkboxes.click(function () { alert('working'); }); }); or alternately, put code in script tag @ end of body , not need ready handler: var checkboxes = $('.bigdiv input:checkbox')

html - What does the "#" mean or stand for in a code? -

i'm trying figure out coding newbie. wondering # symbol means or stands in code, #55555 number. or #menu1 in div: div#menu1 ul.rmenu ? trying education i think in case of #55555 , # indicates hexadecimal code , in case of #menu1 , # indicates menu1 id attribute ..

android - How can I call findViewById inside IntentService? -

is there way call findviewbyid inside intentservice? in case, tried using static reference of mainactivity class. didn't work. mainactivity class calls intentservice: public static mainactivity ma; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); ma=this; startservice(new intent(this,myservice.class).setaction("myintent")); } and myservice class is: protected void onhandleintent(intent intent) { if(intent.getaction()=="myintent"){ listview lv=(listview)(mainactivity.ma.findviewbyid(r.id.listview)); toast.maketext(getapplicationcontext(), (mainactivity.ma.findviewbyid(r.id.listview)).tostring(), toast.length_long).show(); } } this gives nullpointerexception. verified mainactivity.ma ok inside service class. still, cannot call findviewbyid . how can resolve this?

c# - Android Application Crash Management using Xamarin -

general scenario : while developing android application using xamarin, tend crash application multiple times , behavior acceptable , normal. but time, when navigate 1st activity 2nd activity. , on 2nd activity if application crashes, on next run application starts 2nd activity, should start 1st activity. please note 1st activity : mainlauncher property set true. application : 1 st activity = splash screen; 2 nd activity = login screen; [sets global appication variable user id] 3 rd activity = user profile [fetch data database using user id]; 4 th activity = preference page, settings saves username n password login form. ============================================================================== problem : while running application flow should go according given activities, when enter correct credential on login page saves (int)userid . , using userid fetch details of user , display them on 3rd activity. but times if application crashes on 3rd activity, , when r

Python Import Hooks and __main__ -

pep 302 defines way user code hook import process , intercept imports. however, works imports occur after code has run register import hook. almost definition, no code runs before __main__ module, script run. haven't had luck trying import hooks (which useful things) intercept code being loaded __main__ module. is there way forward i'm missing, or out of luck? can accept having import hooks not perform transformations on __main__ module, nice if did. have tried importing inside main this? if __name__ == '__main__': import foo # rest of code here

java - Collision between two images with transparency -

i'm writing game scratch in java , need detect collision between 2 images irregularly shaped , have transparent pixels. i'm able detect collision bug-free between 2 images' bounding boxes, need more specific. how go this?

android - MediaPlayer is not looping -

i want create activity background music, mediaplayer playing not repeatedly :( why mediaplayer not looping? there code: mediaplayer mediaplayer; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); requestwindowfeature(window.feature_no_title); setcontentview(r.layout.tersetetete); mediaplayer = new mediaplayer(); mediaplayer.setvolume(8f, 8f); mediaplayer.setlooping(true); mediaplayer = mediaplayer.create(this, r.raw.fon); mediaplayer.start(); } replace mediaplayer = new mediaplayer(); line mediaplayer = mediaplayer.create(this, r.raw.fon); wrote below. you having issues because new mediaplayer(); creates new mediaplayer object on set volume , looping properties, after you're creating new object mediaplayer.create(this, r.raw.fon); , play sound represented new object doesn't have looping property set true nor volume of 8f 8f. here's full code can use: mediaplayer m

eclipse - Git duplicates commit files -

Image
i'm using aptana plugin eclipse. when try commit, doubles file, i.e 1 file appears couple times. if have 10 files commit, shows 20 files (1 file 2 times). tried close , open project, clean eclipse ( project menu -> clean ), refresh project. not helped. shows 1 file 3 times. how can show files correctly, once? edit it's screenshot of duplicated files: i've solved issue that: i've deleted project form eclipse. then i've imported project locally. but it's temporary solution. after couple successful commit, files duplicated again. , don't want delete , import project each time before commit.

javascript - How to rename a jQuery plugin -

i working on custom control used in many others application. control contains own resources include jquery , other plugins' scripts required control. problem arises when control inserted in application has same plugins' javascripts included. have made changes scripts in control, name conflicts, when javascript function called initializing plugins, uses scripts in project rather control's resources. resolving this, thought changing string "abc" (as use mycontrol.abc() in code)in plugin script it, not working. changing string "abcde" , using mycontrol.abcde() gives error "has no method 'abcde' ". trying rename tokeninput script. below code, please suggest changes should initialize control tokeninputes instead of tokeninput. i couldnt copy code, script can found @ https://github.com/loopj/jquery-tokeninput/zipball/jquery-tokeninput-1.6.0 change line 123: $.fn.tokeninput = ... into $.fn.yourname = ...

Two Player Tic Tac Toe Game in Javascript -

i wanted make own tic tac toe game, new javascript , has been 2 days, , unable reach concrete... far.. have achieved in game- http://jsfiddle.net/f9sv4/ //tic tac toe //global variables //get input user sign should playerone. //set signs both players. //when user click on button triggers play function() //play function detects playing turn. //display sign on button accordingly. var playeronechoice; var playertwochoice; var playerturn=1; var matrix = [[], [], []]; var buttons = [[], [], []]; var row1; var x = "x"; var o = "o"; var x; var y; var i; //input matrix (i = 0; <= 8; i++) { switch (i) { case 0: x=0; y=0; break; case 1: x=0; y=1; break; case 2: x=0; y=2; break; case 3: x=1; y=0; break; case 4: x=1; y=1; break; case 5: x=1; y=2; break; case 6: x=2; y=0; break; case 7: x=2; y=1; break; case 8: x=2; y=2; break; } matrix[x][y] = document.queryselector(".cell"+i); buttons[x][y] = document.quer

java - How to set Heap Space for non executable JAR using JNI -

currently working on mac application in getting outofmemoryerror frequently. using non executable jar file our application cannot set heap size before starting application because java code execute using jni, there possible way set heap size using jni or c. or other solution above problem. in advance. i found answer. using jni before creating jvm must fill javavmoption parameter "-xms256m" minimum size , "-xmx512m" maximum size. allocate minimum jvm heap size 256 mb , maximum jvm heap size 512 mb. so code others: javavminitargs args; javavmoption options[3]; args.noptions = 3; options[0] = (char*)"-xms256m"; options[1] = (char*)"-xmx512m"; options[2] = //your jar file path. args.options = options; then pass args (javavminitargs object) while creating jvm. above code set minimum , maximum heap size. remember 1 more thing not set minimum heap size before setting maximum heap size because in case minimum heap size more or equ

django rest framework - Append trailing slash to cURL file upload -

i'm using curl test rest api of django app (apache server) uses django rest framework. problem i'm encountering upload url requires trailing slash, using following curl approach not append trailing slash: curl -i -b cookie.txt -x put -t "somefile.txt" http://myserver/api/upload/ from curl man know: if there no file part in specified url, curl append local file name. note must use trailing / on last directory prove curl there no file name or curl think last directory name remote file name use. however, curl doesn't put trailing slash after filename automatically appends. so, can't find way curl make url http://myserver/api/upload/somefile.txt/ instead of http://myserver/api/upload/somefile.txt any advice? i got answer curl users mailing list (curl-users@cool.haxx.se): when doing http put, you're supposed identify resource you're create request. claim api requires have trailing slash bit on broken side. but no, curl

jQuery UI droppable, draggable, resizeable and snap to grid -

i have following structure: <div id="grid"> <div class="columns"></div> <div class="columns"></div> <div class="columns"></div> ... </div> <div id="assets"> <div class="assets" id="asset1"></div> <div class="assets" id="asset2"></div> ... </div> and want make each asset droppable, draggable, resizable , snapping each column positioned underneath assets. jquery ui draggable doesn't have snap grid out of box i'm trying adapt suit needs, snap of resizable snaps grid of pixel values (as far know anyway). there way use $(".assets").resizeable({ grid: $(".columns") }); ? i've tried , doesn't work. i've found this: https://github.com/polomoshnov/jquery-ui-resizable-snap-extension but doesn't seems work whit 2 different elements (one grid

Replacing substrings given a dictionary of strings-to-be-replaced as keys and replacements as values. Python -

i have dictionary strings replaced keys , replacement values. other looking through strings token token, there better/faster way of doing replacement? i've been doing such: segmenter = {'foobar':'foo bar', 'withoutspace':'without space', 'barbar': 'bar bar'} sentence = "this foobar in barbar withoutspace" in sentence.split(): if in segmenter: sentence.replace(i, segmenter[i]) string immutable in python. so, str.replace returns new string instead of modifying original string. can use str.join() , list comprehension here: >>> segmenter = {'foobar':'foo bar', 'withoutspace':'without space', 'barbar': 'bar bar'} >>> sentence = "this foobar in barbar withoutspace" >>> " ".join( [ segmenter.get(word,word) word in sentence.split()] ) 'this foo bar in bar bar without space' another problem str.rep

PHP and SMTP server -

my simple code below: $headers = 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=utf-8' . "\r\n"; $headers .= "from: info@mail.com \r\n"; $headers .= 'bcc: test@mail.com' . "\r\n"; $subject = "information"; if (mail($email, $subject, $message, $headers)) { $mail_status = "success"; } else { $mail_status = "fail"; } if ($mail_status == "success") echo '{"status":"success"}'; how can support smtp support? as mentioned phpmailer in tags. can use phpmailer class process. require_once('../class.phpmailer.php'); //include("class.smtp.php"); // optional, //gets called within class.phpmailer.php if not loaded $mail = new phpmailer(); $body = file_get_contents('contents.html'); $body = eregi_replace("[\]",'',$body); $mail

OpenCV and Windows Store App using C# on a x64 platform -

we trying integrate opencv c++ windows runtime component c# windows store app. working on windows 8 (x64) platform , using visual studio 2012 opencv 2.4.5. actual aim detect faces in c# windows store app working on x64 platform. set opencv 2.4.5 visual studio 2012 (x64 platform) , copied dll's of opencv "system32" folder able build , run opencv projects on above mentioned platform. here problems faced us: we successful in building c++ windows runtime component contains code face detection. integrate store app , try make object of winrt's class. throws exception. but whole project works fine if comment lines trying work on images , cascades. solely able detect faces in win32 console application using above code. not able task. i giving link project working on. " https://www.dropbox.com/l/okeznmrazzfmv6uoj59kmb " about project: 1. "facedetectwinrt" c++ windows runtime component project contains "class1.cpp" , "class1.

asp.net - Convert HTML to PDF in MVC with iTextSharp in MVC Razor -

i trying convert html pdf itextsharp in mvc razor, have tried has not worked. know how accomplish this? there's detailed , step-by-step tutorial on codeproject might follow. illustrates how serve asp.net mvc view pdf file using itextsharp conversion. bear in mind though itextsharp not meant converting html pdf might not cope complex html pages , css styles.

html - How to edit the google description of your site? -

Image
i know <meta name="description" content="[description here]" /> can used wonder how make description 1 in facebook. does description use <meta> tag well? or there other secret behind it? edit: code site myself (no wordpress , stuff) :) it depends on website popularity. google it, don't. google may can persuade them. and check out sub sitelinks in google search result for starters, sure have “sitemap.xml” file. file tells search engine pages on site , makes easier spiders crawl , understand it. webmaster or website provider or content management system (like wordpress) should have handled you, it’s worth checking. if you’re not master of website technical stuff, whoever technical support person able tell if page there, , set up. you should register site google webmaster tools, if haven’t already. exact process changes time time, basically, you’ll give google url of sitemap file, you’ll have previou

c# - How to serialize list property of a dynamic object -

i have issue serialization wcf service (json output). use dynamicobject return ligth json rest service. this code return empty result (impossible serialize): public dynamicjsonobject dowork() { dynamic result = new dynamicjsonobject(); result.values = new list<int>() { 1, 2 }; } but code works perfectly public dynamicjsonobject dowork() { dynamic result = new dynamicjsonobject(); result.values = 1; } my dynamicjsonobject class : [serializable] public class dynamicjsonobject : dynamicobject, iserializable { private idictionary<string, object> dictionary { get; set; } public dynamicjsonobject() { dictionary = new dictionary<string, object>(); } public dynamicjsonobject(serializationinfo info, streamingcontext context) { dictionary = new dictionary<string, object>(); } public override bool trygetmember(getmemberbinder binder, out object result) { var haskey = dictionary.c

android - how to use Alert Box? -

i have application uses data stored on sd card, problem, want display dialog box error message before application terminates. tried create dialog box not in activity in simple class. code use unkown. first part , second every thing ok. when sd card installed , when use nexus google tablet. have message no sdcard before application crashed, or start other activity used tell user application need sdcard. code use given below. application print log crash when no sdcard. public file getrootdirectory() { if (this.rootdirectory == null) { file sdcardroot = mainapplication.getinstance().getsdcardrootdirectory(); if (sdcardroot != null) { this.rootdirectory = sdcardroot; } else if(build.brand.equals("google")) { this.rootdirectory = environment.getexternalstoragepublicdirectory(mainapplication.appli_directory); } else { log.d(cla

Checking membership in python list trouble -

i encountered problem item membership in list, can't understand. while checking object instance in list( simple "item in list" ) returns me false if instance in list. notice same pointers have no same id. do have use special method or what? can helps me compare instance equality, please. note: occasion happens in pyside if matters. your objects need have __eq__ method define how compare objects equality. in [18]: class a(object): ...: def __init__(self, n): ...: self.n = n ...: in [19]: class b(object): ...: def __init__(self, n): ...: self.n = n ...: def __eq__(self, other): ...: return self.n == other ...: in [20]: = a(1) in [21]: b = b(1) in [22]: in [a(n) n in range(10)] out[22]: false in [23]: b in [b(n) n in range(10)] out[23]: true in [24]: b in [b(n) n in range(10, 20)] out[24]: false

javascript - Changing style of file browse button (MyFaces inputFileUpload) -

my task implement css style submit button of file upload widget. decided make original widget invisible , add text field , button visible , have styles need , can use functionality of original widget. <t:inputfileupload id="fileupload" style="display:none" value="#{handler.upfile}" accept="application/pdf,image /tiff" onchange="handlechange();"/> <input type="text" id="filename" class="input400px" readonly = "readonly"/> <input type="button" id="fakebrowse" class="browsebutton" value="browse..." onclick="handlebrowseclick();"/> function handlebrowseclick() { var fileinput = document.getelementbyid("uploadform:fileupload"); fileinput.click(); } function handlechange() { var fileinput = document.getelementbyid("uploadform:fileupload"); var textinput = document.geteleme

java - How can i create a custom listview in SherlocklistActivity? -

i have not worked on sherlock wanna create sherclockactionbar interface 2 3 tabs @ 1 tab wanna have listview sub item text works on simple activity not working in sherlockfragmentactivity.and wanna disable title bar have disable on android 3.0 , greater still showing on android version less 3.0. public class fragmentlistarraysupport extends sherlockfragmentactivity { @override protected void oncreate(bundle savedinstancestate) { settheme(samplelist.theme); //used theme switching in samples super.oncreate(savedinstancestate); // create list fragment , add our sole content. if (getsupportfragmentmanager().findfragmentbyid(android.r.id.content) == null) { arraylistfragment list = new arraylistfragment(); getsupportfragmentmanager().begintransaction().add(android.r.id.content, list).commit(); } } public static class arraylistfragment extends sherlocklistfragment { public static final string[] items = ("first","second","

java - Can an instance of MongoClient be long running -

this morning found java servlet (tomcat 7) interacts mongodb (using standard java mongo driver) had failed after running approximately 1.5 days. in context listener servlet instance of mongoclient defined, , there connects database. use mongoclient instance perform database interaction, in separate functions call mongoclient.getdb(dbname) database object use perform queries. have done wrong? should checking connection live or handled mongoclient object, i'm aware provides pool of connections - assumed (mother of mistakes) keeps connections database live no management. thanks much, apologies simple question, mark i found there memory leak else in servlet. fixed not having problems. means yes instances of mongoclient can see can long running (so far mine has been running on 2 days!).

qt - SDL OpenGL Texture display issue -

Image
i'm following this tutorial in order load opengl texture sdl_surface , i've copy/paste code , adapted display wrong old part of buffer little bit annoying... cause can't figure what's wrong. work qt5 on mac os x. here's code gluint texture; // handle our texture object sdl_surface *surface; // surface tell details of image glenum texture_format; glint nofcolors; surface = img_load("/brique.png"); if ( surface ) { // number of channels in sdl surface nofcolors = surface->format->bytesperpixel; if (nofcolors == 4) // contains alpha channel { if (surface->format->rmask == 0x000000ff) texture_format = gl_rgba; else texture_format = gl_bgra; } else if (nofcolors == 3) // no alpha channel { if (surface->format->rmask == 0x000000ff) texture_format = gl_rgb; else texture_format = gl_bgr; } else { printf(&

Java String array out of existing String array -

i have java string array: public static final string[] fields_names = { "albert", "berta", "carl" }; public static final string[] fields_numbers = { "123", "456", "789" }; and create third constant out of 1 have. repeating everything: public static final string[] fields_all = { "albert", "berta", "carl", "123", "456", "789" }; but want this: public static final string[] fields_all = {fields_names, fields_numbers}; any idea how in java? not want run loops shuffle things around... one way concatenate string arrays: string[] fields_all = arrayutils.addall(fields_names, fields_names); edit note: @malachi has mentioned, uses apache commons lang library edit without using external libs: you can use generic method so: string[] join(string[]... arrays) { // calculate size of target array int size = 0; (string[] array : arrays)

Windows .bat file, %~$PATH:1 quotes issue -

Image
i have which.bat on windows 7, @echo off rem bat searches file in path list see whether file can found. rem if found, shows file's full path. rem which.bat gcc.exe rem shows rem gcc.exe found: d:\gmu\mingw2\bin\gcc.exe rem rem note: filename extension significant in search. e.g. if run rem which.bat gcc rem gcc.exe not matched. if "%1" == "" goto end if "%~$path:1" == "" ( echo %1 not found in directories path env-var. ) else ( echo %1 found: %~$path:1 ) :end this bat works until find strange behavior today. there file o:\temp\pfiles (x86)\mystuff.txt , , path has content: path=o:\temp\pfiles (x86);d:\cmdutils running which mystuff.txt , got very strange output: \mystuff.txt unexpected @ time. after poking around, find (x86) in directory name causes problem. workaround, have add quotes echo , this: echo %1 found: "%~$path:1" the downside of such tweak obvious: quotes pri

ios - How to add a subview in drop-down style in a table below each row on row-click event? -

how add subview in drop-down style in table below each row on row-click event? ill add more details: when click on row, subview should appear in drop-down style below row can put more buttons , text-boxes. should happen every row in table. thanks. this might https://www.cocoacontrols.com/controls/vppdropdown it features you've described

graphite - Statsd + Graphie , showinglow fequency events -

i using stadard graphite + statsd stack. 10 sec statsd interval + 10s graphite retention schema. i have several events happen 1k - 10k times day. , show them in graph too. graph flat (24h range of statsd has 8640 slots). show graph measures event in events/min , or events/5min - default right events / 10s . possible wihouth changing default statsd interval , retention schemas in graphite. thanks i found answer built in function summarize in graphite that.

java - Run the program without error? -

when run below program getting errors messages public class saviodriver { public static void main(string[] args) { processengine processengine = processengineconfiguration .createstandaloneinmemprocessengineconfiguration() .buildprocessengine(); } } can 1 suggest jar files need include , run properly? processengine = processengineconfiguration .createprocessengineconfigurationfromresourcedefault() .buildprocessengine(); try may not error, provided have added required jar files in classpath.

codeigniter - Error 403: forbidden error -

i can't access controller using form in codeigniter 2.1. homepage has several links , can access. when want submint data in form display 403 forbidden error: forbidden don't have permission access /pruebas/application/controllers/valiar.php on server. the view: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>anuncios</title> <link rel="stylesheet" href="/pruebas/css/estilos.css" type="text/css" media="screen"/> <link rel="stylesheet" href="/pruebas/css/logestilos.css" type="text/css" media="screen"/> </head> <body> <div id="contenedor"> <div id="menu"> <label for="home" id="inicio"><a href="http://localhost/pruebas/index.php /cindice/">inicio</a></label> <label f

qt - How to get the text of a combobox in a tablewidget? -

i’m new qt, need getting value of combobox in table widget. i use “setcellwidget” add combobox(in case, name “settinga”) table widget (the name “tablewidget_4”): qcombobox* settinga = new qcombobox(); settinga->additem("100"); settinga->additem("200"); ui->tablewidget_4->setcolumncount(1); ui->tablewidget_4->setrowcount(3); ui->tablewidget_4->setcellwidget ( 0, 0, settinga ); what want here is: when button (its name “applycombobutton” in case) clicked, want value of combobox(settinga) can saved qstringlist(inputcombodata) , , how try this: void mainwindow::on_applycombobutton_clicked() { qstringlist inputcombodata; inputcombodata << ui->tablewidget_4->item(0,0)->text(); } and fails. how can value of combobox? you can use qtablewidget::cellwidget ( int row, int column ) function qcombobox widget. use qobject_cast cast qcombobox, , use currenttext() function text. qcombobox *mycb = qobjec

mysql - UNION 2 Tables, (combining them) -

i have products_a product_id product_name price quantity 11 milka 36 56 3 21 meatb 123 78 23 31 sugara 29 45 333 products_b product_id product_name price quantity 21 milkb 63 65 33 22 meatb 321 87 4345 23 sugarb 92 54 232 i want select query this product_id quantity quantity*price 11 36 21 123 31 29 21 63 22 321 23 92 i try select products_a.quantity, products_b.quantity, products_a.quantity * products_a.price, products_b.quantity*products_b.price products_a, products_b; but looks unformatted. details if want results both tables, can use union all. select a.product_id product_id, a.quantity, a.quantity * a.price total products_a union select b.product_id product_id, b.quantity, b.quantity * b.price total products_b b

grails - How to send Javascript code from Controller to GSP view? -

i want send js script controller gsp view . following attempt. controller(purchase.groovy) : def myaction={ flash.script= 'jquery("div#header").show(1000);' redirect(action:'edit') } in purchase/myaction.gsp file, try following code <g:if test="${flash.script !=null}"> <g:javascript> $(function() { ${flash.script} }) </g:javascript> </g:if> <g:else> <g:javascript> $(function() { alert('welcome') }) </g:javascript> </g:else> i try : jquery.getscript('${flash.script}') instead of '${flash.script}' however, gsp page renders second script(else statement) first of all, sure call function after dom loaded; u can use jquery like $( document ).ready(function() { call_function(); }); and can send js code form controller map, not through flash , redirecting action. see below: def myact

Output pyodbc cursor results as python dictionary -

how serialize pyodbc cursor output (from .fetchone , .fetchmany or .fetchall ) python dictionary? i'm using bottlepy , need return dict can return json. if don't know columns ahead of time, use cursor.description build list of column names , zip each row produce list of dictionaries. example assumes connection , query built: >>> cursor = connection.cursor().execute(sql) >>> columns = [column[0] column in cursor.description] >>> print columns ['name', 'create_date'] >>> results = [] >>> row in cursor.fetchall(): ... results.append(dict(zip(columns, row))) ... >>> print results [{'create_date': datetime.datetime(2003, 4, 8, 9, 13, 36, 390000), 'name': u'master'}, {'create_date': datetime.datetime(2013, 1, 30, 12, 31, 40, 340000), 'name': u'tempdb'}, {'create_date': datetime.datetime(2003, 4, 8, 9, 13, 36, 390000), 'name'

Retrieving string-encoded binary data from MongoDB in PHP -

i have stored binary data in mongodb string. how can retrieve php? this article describes how in perl, how can manage in php? the following doesn't work: $query = array('md5' => "00<Χtcwdrc"); $cursor = $collection->find($query); according documentaion : to access contents of mongobindata, use bin field. $obj['fieldname']->bin

php - jQuery resizable on image -

i have site develop in codeigniter, , want upload image ajax , make resizable. i'm able upload , show image isn't resizable. this upload script: public function ajaximage(){ $path = "uploads/tee/element/"; $session_id = $this->session->userdata('id'); $valid_formats = array("jpg", "png", "gif", "bmp","jpeg"); if(isset($_post) , $_server['request_method'] == "post") { $name = $_files['upload']['name']; $size = $_files['upload']['size']; if(strlen($name)) { list($txt, $ext) = explode(".", $name); if(in_array($ext,$valid_formats)) { if($size<(1024*1024)) // image size max 1 mb { $actual_image_name = time().$session_id.".".$ext; $tmp = $_files['upload']['tmp_name'

winforms - Out of memory exception in CreateGraphics (GdipCreateFromHWND) -

on machines vary in configuration (os, graphics card , memory) outofmemory exception. tests showed there no significant increase in virtual memory consumed. that's piece of code exception raised: public override size getpreferredsize(size proposedsize) { try { using (graphics g = this.creategraphics()) { sizef measured = g.measurestring(this.text, this.font); // <= outofmemoryexception measured += new sizef(1, 1); return measured.tosize(); } } catch (outofmemoryexception oom) { system.diagnostics.trace.writeline(oom.tostring()); } return proposedsize; } the class derived directly label. creategraphics() makes call gdi+ function gdipcreatefromhwnd in cases return status (3) raises outofmemoryexception face: [editorbrowsable(editorbrowsablestate.advanced), securitypermission(securityaction.linkdemand, flags=securitypermissionflag.unmanagedcode)] public static graphics fromhw

parsing - Find node in xml, despite how many nodes deep it might be -

this segment of extremely large xml. i'm super confused how results need it. <task id="269930118" name="name1" active="0" nexteid="65" tt="cos" ar="0"> <for id="12"> <if id="13"> <when> <criteria> <comp a="[origname]" test="mask" b="53_inbound_daily_account.txt"/> </criteria> <updorig action="d" id="45"/> </when> </if> </for> <if id="37"> <when> <criteria> <comp a="[taskstatus]" test="mask" b="success"/> </criteria> <email hostid="282198113" subject="[taskname] [taskstatus]" message="[taskname] [taskstatus]&quo