Posts

Showing posts from March, 2011

java - Mapping freeform XML/JSON to Moxy/JAXB annotated class -

i'm trying find way correctly map following xml/json document equivalent jaxb/moxy annotated class . note model element of document, in example describes person, freeform , i.e. might any kind of xml element/json object , not statically known. xml document: <form> <title>person form</title> <model> <person> <name>john</name> <surname>smith</surname> <address> <street>main st.</street> <city>ny</city> <country>usa</country> </address> <person> </model> </form> equivalent json document: { "title":"form title", "model":{ "person":{ "name":"john", "surname":"smith", "address":{ "street":"main st.&

oracle - Search for similar words using an index -

i need search on db table using kind of fuzzy search 1 oracle , using indexes since not want table scan(there lot of data). i want ignore case, language special stuff(ñ, ß, ...) , special characters _, (), -, etc... search "maria (cool)" should "maria- cool" , "maría_cool" matches. possible in oracle in way? about case, think can solved created index directly in lower case , searching lower-cased. not know how solve special chars stuff. thought storing data without special chars in separated column , searching on returning real one, not 100% sure perfect solution. any ideas? maybe utl_match can help. but can create function based index on, lets say, this: regexp_replace(your_column, '[^0-9a-za-z]+', ' ') and try match this: ... regexp_replace(your_column, '[^0-9a-za-z]+', ' ') = regexp_replace('maria (cool)' , '[^0-9a-za-z]+', ' ') here sqlfiddle demo it's

service - Trying to create a Android Soft Keyboard from an activity -

i wrote activity keyboard. moving class extends activity exteds inputmethodservice ... , missing findviewbyid create keyboard layout. because have not enough knoledge create softkeyboard include java code. next step modify androidmanifest.xml service, guess. package com.keyboard.mine; import android.app.activity; import android.os.bundle; import android.view.menu; import android.view.view; import android.widget.button; import android.widget.textview; public class mainactivity extends inputmethodservice /* activity */ { ... ... // @override // protected void oncreate(bundle savedinstancestate) { // super.oncreate(savedinstancestate); // setcontentview(r.layout.activity_main); // } // @override // public boolean oncreateoptionsmenu(menu menu) { // // inflate menu; adds items action bar if present. // getmenuinflater().inflate(r.menu.main, menu); // return true; // } private void nuevas_teclas (string [][] teclas

jquery - display value from database into HTML input tag -

i have drop down list (html select tag) , html form under it. below - select-> <select name="select-native-1" id="select-native-1" onchange="dbtoform(this)"> <option value="1">employee 1</option> <option value="2">employee 2</option> <option value="3">employee 3</option> <option value="4">employee 4</option> </select> form -> <form> <label for="e_name">name</label> <input name="e_name" id="e_name" value="" type="text" data-theme="a"> <label for="date">date</label> <input name="date" id="date" value="" type="date" data-theme="a"> <label for="gender">gender</label> &l

Display an alert error with php and javascript not working properly in FF and Chrome -

i use piece of code inform user fill field in way: ob_start(); $msg = $_session['erroruser']; if($msg !=""){ echo '<script type="text/javascript">alert(" ' . $msg . '");</script>'; } //echo $msg; $_session['erroruser'] = ""; ob_end_flush(); this works in internet explorer while in ff , chrome. msg displayed, have nothing in background, part of page showed (behind message alert). the problem you're facing outputting alert straight dom cause alert triggered while dom still loading. if you're using jquery should output alert box inside jquery(document).ready callback or otherwise bind load / domcontentready events of window object.

python - Simulate KeyboardInterrupt with fabric -

how fire ctrl + c fabric, in other words possible trigger keyboardinterrupt manually via bash? ctrl+c generates sigint signal. you can send signal kill -sigint pid pid process id. wish signal. kill bash built-in.

osx - How to block/unlock USB port in mac os x programatically without reboot -

is there way block/unblock usb mass storage device in macos x using script or i/o framework without reboot ? the same can done in window using system commands, wanted know if possible on os x. you can use apple's workgroup manager to configure removable media access without server . after you've disabled removable media access via workgroup manager, can use export menu command save policy file implements restrictions. can script enabling/disabling restrictions using dscl . -mcximport (you can read more in enterprise mac managed preferences ).

c# - .NET remoting exception ArgumentOutOfRange -

Image
i have .net smart card , using c# build card application , host application. smart card acts server in .net remoting. in smart card, have remote object (myclass) , call remote method : public int addperson (string name,string age) to add information object. public class myclass : marshalbyrefobject { private string text1; private string text2; private int noofperson = 0 ; private person[] list = new person [6]; public void settext1(string t) { text1= t; } public void settext2(string t) { text2= t } public string gettext1 () { return text1; } public string gettext1 () { return text1; } public int addperson (string name,string age) { person obj = new person (); obj.name = name; obj.age = age; list[noofperson] = obj; noofperson ++; return noofperson - 1 ; //index of current person return 1 ; } public personstruct getpesrson(int index) {

Semantics of adding an Object and an integer to each other, in PHP? -

class wat { public $a = 3.14; public $x = 9; public $y = 2; } $a = new wat(); var_dump(1000 + $a); var_dump($a + 1000); the output is: int(1001) int(1001) well, adding wat * object integer not right thing do, since php complains "object of class wat not converted int" , still, do? (i have practical reason asking this, want refactor function rid of "php notice", while still keeping behaviour unchanged.) *: http://img.youtube.com/vi/kxegk1hdze0/1.jpg addition ( + ) implicitly casts both operands float if either 1 of them float , otherwise both operands cast int ( see paragraph #2 .) it seems that, @ least now, object cast int results in value 1 , hence result 1000 + 1 = 1001 or 1 + 1000 = 1001 , however, per documentation , behavior undefined , should not relied upon. if you've turned on e_notice error reporting, notice should produced, saying object not converted int.

angularjs: checking url location change -

i'm watching $locationchangesuccess event. need clean way check whether url has changed or if parameters have changed. compare 'next' , 'current' parameters, maybe there's function doing ? set custom watch: function myctrl($scope, $location) { // watch parameters... $scope.$watch(function() { return $location.search(); }, function(newparams, oldparams) { console.log(newparams); console.log(oldparams); }, true); } note third argument true passed $scope.$watch() ; important ensure watch value, in case object, watched changes (and not referentially).

javascript - How to get x,y coordinates of text in paragraph (like Quora does) -

i want able x,y coordinates of end of text string has been highlighted in web browser. tried searching online similar , found quora want. code obsfucated/ compressed though can't work out did. to see example visit question on quora (such this: http://www.quora.com/job-interviews/whats-the-craziest-thing-you-ever-said-at-an-interview-and-still-got-the-job ) , highlight text in answer. little box pop-up says 'embed quote'. getting position of embedded quote want do. i've made little demo grabs mouse position - i'd more accurate if possible. there's jsfiddle of code here: http://jsfiddle.net/binarymoon/zy8hy/ $(function(){ $(document.body).bind('mouseup', function(e){ var selection; if (window.getselection) { selection = window.getselection(); } else if (document.selection) { selection = document.selection.createrange(); } if ( selection.tostring().length > 3 ) {

Javascript scopes in coffeescript for Google Analytics Code -

the codes google analytics use global _gaq object analytics commands. advise check if such object exists, this: var _gaq = _gaq || []; // command _gaq.push(['_trackpageview']); in coffeescript, this: _gaq = _gaq or [] which compiles this: (function() { var _gaq; _gaq = _gaq || []; }).call(this); how can write coffeescript code lead behaviour of above javascript? to make _gaq variable available in global scope write in coffeescript: _gaq = window._gaq ?= [] the javascript output: var _gaq, _ref; _gaq = (_ref = window._gaq) != null ? _ref : window._gaq = []; this way can latter call _gaq.push(['_trackpageview']); there another question in stackoverflow talks global variables in coffeescript might want check.

android - Requesting a ShowcaseView example -

i've been hearing lot espiandev showcaseview tutorial tool android apps, unfortunately couldn't find examples of implementation sample provided library. no matter tried, i not sample compile . i've installed library , dependencies on eclipse ide instructed here , looks installed fine. eclipse tells me import r (android) on both java files ( sampleactivity , actionitemssampleactivity ) , none of usual tricks work (like cleaning project, example). also, doesn't know strictmode is. styles.xml gives out compilation errors such no resource found matches name: attr 'text' , showcasebuttonstyle . using actionbarsherlock in workspace. please, can provide working example or point me step-by-step tutorial (or youtube)?

Android monitor.bat does not see processes on Samsung Galaxy S3 -

i developing against samsung galaxy s3 connected usb cable windows 7 laptop. i have installed recent version of samsung kies , usb drivers present. phone has debugging turned on , visible adb. android's monitor.bat (was called ddms) shows phone , logcat not processes. how monitor.bat see galaxy s3's processes?

html - stop scroll bar from covering div content with auto overflow -

i have div overflow-y:auto; can narrow , when scroll bar appears can cover or of div. scroll bar appear outside div overflow:scroll; don't want see faded scroll bar when there no overflow. don't want give div width width must variable. jsfiddle demonstrates issue, , here code: .auto { display:inline-block; border:1px solid green; height:70px; overflow-y:auto; } <div class = "auto"> <div> a<br> b<br> c<br> d<br> </div> </div> this solution: http://jsfiddle.net/zuyve/5/ basically, uses wrapper contain scrollbar <div class="scroll"> <div>a <br />b <br />c <br />d <br /> </div> </div> and leaves space on right side it: padding-right: 13px; however, since scrollbars may vary depending on os, i'd suggest use custom scrollbars this jque

actionscript 3 - AS3 - Preventing duplicates from being selected from an array -

this question has answer here: randomize or shuffle array 2 answers i've got array of 8 strings want place on stage (using textfields) in random order. i can select 8 of strings without problem, using math.random pick number between 0-7 , placing item @ index onto stage. but i'm struggling prevent duplicates being added. have suggestions? thank you shuffle array, loop through it. great examples can found here: http://bost.ocks.org/mike/shuffle/

Call javascript from code behind c# sharepoint 2010 -

i have code in .ascx.cs file calls new page on href. lblvideoassessment.text = "<a href='../sitepages/assessment.aspx?cat=" + cat + "' height='300px' width='300px' target='_blank' cssclass='icondisplaycss'><img src='~/_layouts/images/assessment.png' border='none'/></a><br/>" + cat; i want replace code javascript popup page change , feel.i want make page popup have written javascript method in .ascx file given below: <script type="text/javascript"> function opendialog(url) { var newpopup = sp.ui.$create_dialogoptions(); newpopup.url = url; newpopup.width = 700; newpopup.height = 350; sp.ui.modaldialog.showmodaldialog(newpopup); } </script> i have called javascript in code behind , not work: lblvideoassessment.text = "<a onclick='javascript:opendialog('../sitepages/quiz.aspx')' heig

Excel to PowerPoint VBA PasteSpecial Keep Source Formatting -

i'm trying copy , paste range excel document powerpoint slide using vba. seems work fine except it's copying range image rather keep source formatting. want keep source formatting when copy , pastes in. help! opptapp powerpoint.application dim opptfile powerpoint.presentation dim opptshape powerpoint.shape dim opptslide powerpoint.slide on error resume next set xlapp = getobject(, "excel.application") on error goto 0 windows("file1.xlsx").activate sheets("sheet1").select range("b3:n9").select selection.copy opptapp.activewindow.view.gotoslide (2) opptapp.activewindow.panes(2).activate opptapp.activewindow.view.pastespecial datatype:=pppasteoleobject opptapp.activewindow.selection.shaperange.left = 35 opptapp.activewindow.selection.shaperange.top = 150 have tried using opptapp.activewindow.view.pastespecial datatype:=pppastedefault

objective c - C++ Class inheritance in Xcode? -

i making simple example of inheritance in c++. using xcode , whenever create subclass obtain error: use of undeclared identifier rat. these classes: pet.h #include <iostream> #include <string> using namespace std; class pet { public: // constructors, destructors pet(): weight(1), food("pet chow") {} ~pet() {} //general methods void eat(); void speak(); protected: int weight; string food; }; rat.h #include <iostream> #include "pet.h" using namespace std; class rat::public pet { rat() {} ~rat() {} // other methods void sicken() { cout << "spreading plague" << endl; } } i think mean class rat : public pet

java - bad operand type string for unary operator '+' -

i'm working on module class several student objects , have been experiencing following issue - bad operand type string unary operator '+' i appreciate assistance, code follows. public class module { private string moduletitle; int percentagecoursework; int percentageexam; private student studentslist[] = new student[3]; public module (string moduletitle, int percentagecoursework, int percentageexam,string studentone, string studenttwo, string studentthree, string studentstitles[]) { this.moduletitle = moduletitle; this.percentagecoursework = percentagecoursework; this.percentageexam = percentageexam; this.studentslist[0].name = studentone; this.studentslist[1].name = studenttwo; this.studentslist[2].name = studentthree; } public void showdetails() { system.out.println("moduletitle : " + moduletitle + "\n percentagecoursework : " + percentagecoursework + "\n percentageexam : " + p

javascript - Popup on form submission -

i display popup when signs 1 of websites. there data writing external database (this works correctly) bit unsure parts of code can change , need remain. if of able advise on great! bit of noob when comes javascript! thanks in advance <form name="signup" id="signup" action="http://creationonline.co.uk/signup.ashx" method="post" onsubmit="return validate_signup(this)"> <input type="hidden" name="addressbookid" value="1232079"> <!-- userid - required field, not remove --> <input type="hidden" name="userid" value="81918"> <!-- returnurl - when user hits submit, they'll sent here --> <input type="hidden" name="returnurl" value=""> <!-- email - user's email address --> <table border="0" cellpadding="0"> <tr> <td> sign </td><td><input name="

php - How to call one javascript asset only in laravel? -

in base controller, added 2 asset inside: asset::script('jquery', 'js/jquery-2.0.0.min.js'); asset::script('test', 'js/test.js'); but when called : asset::script , these 2 .js files loaded. call jquery , not test , how can so? thanks. you use 2 containers. asset::script('name','path') add script default container. , output whole container later when call asset:scripts() in template file. you can add different container either test.js or jquery, this: asset::container('mycontainername')->add('test', 'js/test.js'); then later in template file can output scripts container named "mycontainername" this: echo asset::container('mycontainername')->scripts(); this isn't same outputting specific script single container, give desired result. read more containers in official documentation: http://laravel.com/docs/views/assets

linux - Run a C program automatically when i open Firefox? -

i have written c program, monitor communication taking place through firefox browser in linux. need execute program firefox starts. please suggest me how do so. write bash wrapper script #!/bin/bash my_c_program firefox name useful , place on path mentioned in $path . alternatively, can put in alias: alias firefox_starter='my_c_program; firefox' put line in startup program ( .bashrc )

javascript - Loading jQuery into the head -

i'm trying dynamically load jquery libraries document head. <head> <script src="../js/jquery.js"></script> <script src="../js/app.js"></script> </head> jquery.js looks this: (function() { /* * load jquery components * * @private */ var head = document.getelementsbytagname('head')[0]; var components = []; var jquery = document.createelement('script'); jquery.type = 'text/javascript'; jquery.src = 'http://' + location.host + '/js/jquery-1.8.2.min.js'; components.push(jquery); var jquerymobile = document.createelement('script'); jquerymobile.type = 'text/javascript'; jquerymobile.src = 'http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js'; components.push(jquerymobile); var jquerymobilecss = document.createelement('link'); jquerymobilecss.type = 'text/css'; jquerymobilecss.href =

ruby on rails - Activeadmin, polymorphic relationship and nested attributes -

i have 2 models. there provider , delivery. model note - polymorphic (belongs_to). model provider looks this: class provider < activerecord::base attr_accessible :name, :site_url, :brand_ids, :note_attributes validates :name, presence: true has_one :note accepts_nested_attributes_for :note, allow_destroy: true end form of creating new provider renders good. when try save unknown attribute: provider_id error. problem? the note model should have attr_accessible :provider_id

webgl - In Three.js, is it possible to replace a BufferGeometry's attribute arrays without creating a new geometry? -

after buffergeometry has been created , rendered @ least once, need increase size of geometry. since increasing size of attribute arrays not possible, can replace arrays new, larger ones? something mygeometry.attributes.position.array = newpositionarray; i've tried this, , set .*needsupdate fields on geometry, long string of webgl errors. there going on internally in three.js prevent me operating way? from documentation. "you can emulate resizing pre-allocating larger buffer , keeping unneeded vertices collapsed / hidden." https://github.com/mrdoob/three.js/wiki/updates#geometries

javascript - Adding CSS to iframe with no body -

i have iframe tag, wish change font-family. iframe linking not have body, it's text , pictures. javascript ways of accessing don't work. there way around it? if iframe not on same url / server, best way php instead. <div class="iframe"> <?php echo get_file_contents("http://www.google.com"); ?> </div> <style> .iframe { !! whatever styles !! } </style> obviously replacing !! whatever styles !! changes wish make font. hope helped - i'm quite new stack overflow, if i'm doing wrong please tell me :)

asp.net - ELMAH Logging in SQL Server -

i having elmah problem. think connection string can't figure out why. emailing me errors no problem, not logging them sql. if problem permissions, how catch error show me permission problem? here elmah relevant section of web.config: <configsections> <sectiongroup name="elmah"> <section name="security" requirepermission="false" type="elmah.securitysectionhandler, elmah" /> <section name="errorlog" requirepermission="false" type="elmah.errorlogsectionhandler, elmah" /> <section name="errormail" requirepermission="false" type="elmah.errormailsectionhandler, elmah" /> <section name="errorfilter" requirepermission="false" type="elmah.errorfiltersectionhandler, elmah" /> <section name="errortweet" requirepermission="false" type="elmah.errortweetsectionhandler, elmah" /> &l

Unix command for find number of lines code in iOS project -

this question has answer here: how find out how many lines of code there in xcode project? 14 answers i trying find total number of line code of .h , .m file.i dont know command please me. wc -l your_file give number of lines in file. take @ man wc

Laravel/OVH very slow response time for 5 simultaneous sencha requests -

i install empty laravel4 framework on pro ovh hosting. when, launch 5 simultaneous request on public 'hello world' page, 1 quick answer, 4 others can take more minute ! it works fine on local wamp system ! know if there ovh limiation or laravel pb ? regards edit : hello, find solution. new laravel4 'native' session driver causes slow response time simultaneous request ! changed 'cookies' driver works fine. i think you'll have create ticket ovh support, because it's not normal native session driver cause slow reactions. on dedicated server or shared hosting ?

function - Why JavaScript declared variable is in the global object before initialization? -

i've stumbled upon javascript variable behavior not explain. according js docs on var keyword : the scope of variable declared var enclosing function or, variables declared outside function, global scope (which bound global object). also known global variables become properties of global object - 'window' in browser environments , 'global' in node.js means if variable declared 'var' keyword inside function becomes local , not global object. this example proves it: (function(){ var t = 1; console.log(t in window, t); // outputs: false 1 }()); jsfiddle link so far good. if variable not initialized become property of window object despite fact in function scope. (function(){ var t; console.log(t in window, t); // outputs: true undefined }()); jsfiddle link why happen ? can learn details of behavior ? regular tutorials don't seem cover this. thanks in advance. [edit]: pointy clear scope works expected. had

ruby on rails - API authorization -

please forgive me if question has been asked/answered somewhere else. i've been researching while , haven't found answer yet. i have api needs serve (at least) 2 different types of consumers different needs , privileges. i'm of course talking concept of authorization, well-worn territory within web apps. but, strangely, googling "api authorization" or "api acl" doesn't bring find meaningful. so question is: how handle authorization (not authentication) when writing api? i think answer answered in technology-agnostic way, if helps, i'm using rails.

slice - Stripping unwanted data from an Array in php -

this code builds array: $size = sizeof($include_quotes); ($i=0; $i<$size; $i++) { $quotes = $globals[$include_quotes[$i]]->quote($method); if (is_array($quotes)) $quotes_array[] = $quotes; } } if print_r($quotes_array); i following: array ( [0] => array ( [id] => advshipper [methods] => array ( [0] => array ( [id] => 1-0-0 [title] => trade shipping [cost] => 20 [icon] => [shipping_ts] => [quote_i] => 0 ) [1] => array ( [id] => 2-0-0 [title] => 1-2 working days [cost] => 3.2916666666667 [icon] => [shipping_ts] => [quote_i] => 1 ) [2] => array ( [id] => 4-0-0 [title] => 2-3 working days [cost] => 2.4916666666667 [icon] => [shipping_ts] => [quote_i] => 2 ) [3] => array ( [id] => 8-0-0 [title] => click & collect [cost] => 0 [icon] => [shipping_ts] => [quote_i] => 3 ) ) [module] => shipping [tax] => 20 ) ) in circumstances, want data in field 0 passed

Testing a Rails ApplicationController method with rspec -

just having trouble figuring out how test action utilizes private applicationcontroller method. explain: a user has , belongs many organisations (through roles), , vice versa. organisation has bunch of related entities, in app user dealing single organisation @ time, of controller methods want scope current organisation. in applicationcontroller: private # returns organisation being operated on in session. def current_org # org id session. if doesn't exist, or org no longer operable current user, # find appropriate 1 , return that. if (!session[:current_organisation_id] || !current_user.organisations.where(['organisations.id = ?', session[:current_organisation_id]]).first) # if org doesn't exist user, hope lost, go home page redirect_to '/' if (!current_user.organisations.first) # otherwise set session new org session[:current_organisation_id] = current_user.organisations.first.id; end # return current org! current_user.organ

asp.net mvc 4 - Entity Framework only allow one query -

i making call sql database via entity framework, call takes 2 mins execute. want make sure call occurs once. once call made, place results in cache. notice if multiple users on site, can more 2 mins till data returned, whats best way approach this? should use mutex? or entity framework (version 4) have functionality built in handle type of situation. using mvc 4. thank you! public ienumerable<adlisting> allactiveads() { try { if (pullcache(constants.cachekeys.allactiveads) == null) { using (var db = new myentities()) { db.commandtimeout = 300; list<adlisting> results = (from in db.adlistings .include("adphotos") .include("tblocation") !a.deleted select a).tolist(); pushcache(results, constants.cachekeys.allactiveads); } } return (list<adlisting&

java ee - What's a good low-impact way for me to preserve this expensive data structure? -

i'm working mature production code written using java ee. deal unusual data condition, i've inserted sanity check works, adding unnecessary cost. architecture works this: on page 1, user selects item list , clicks go button. an ajax call page 1's view-scoped controller bean creates big expensive data object (bedo), sanity checks make sure it's valid. if bedo valid, page 1 forwards via javascript page 2. page 2's view-scoped backing bean creates new copy of bedo, identical 1 used sanity check. i'm creating same bedo twice, , throwing away first one. i'd figure out solution wastes fewer processing cycles. so question is, what's best low-impact way of getting bedo page 1's controller bean page 2's backing bean? giving page 1's controller access backing bean doesn't work; because page 2's backing bean view-scoped, gets created anew when user gets sent page 2. i change scope of page 2's backing bean, i'd rather

path - How to get FitNesse root or page folder in FitSharp -

recently encountered problem , have searched lot no solution now. know how can root directory or page folder of fitnesse in fitsharp fixture codes? 1 of troubles have lot of existing pages arranged in different suites , want add new features these pages requiring absolute path of fitnesse folder. using fixture environmental parameter in pages require lot of effort. trying use hard configuration in app.config example! big in advance! looking forward kind answer. the root path available fitnesse predefined variable. pass fixture can expose property. go in setup page. |rootpath| |load|${fitnesse_rootpath}| public class rootpath { public static string path; public void load(string value) { path = value;} }

loops - Iterate over C# dictionary's keys with index? -

how iterate on dictionary's keys while maintaining index of key. i've done merge foreach -loop local variable i gets incremented 1 every round of loop. here's code works: public iterateovermydict() { int i=-1; foreach (string key in mydict.keys) { i++; console.write(i.tostring() + " : " + key); } } however, seems low tech use local variable i . wondering if there's way don't have use "extra" variable? not saying bad way, there better one? there's no such concept "the index of key". should treat dictionary<tkey, tvalue> having unpredictable order - order happen when iterating on may change. (so in theory, add 1 new entry, , entries in different order next time iterated on them. in theory happen without changing data, that's less in normal implementations.) if really want numeric index happened observe time, use: foreach (var x in dictionary.select((entry, index) =&

dynamic - WPF WrapPanel, GroupBox height -

i've got few groupboxes containing different number of controls, textblocks , textboxes, , thereby of different heights. generate these groupboxes dynamically. when wrappanel quite narrow see groupboxes of different heights when wrappanel resized, wider, layout rearranged (as should) @ same time groupbox rearranged gets same height 1 left. is there way prevent this? what want achieve. ------------ ------------ | block #1 | | block #1 | ------------ | | ------------ | | | block #2 | | | | | | | ------------ ------------ thanks! //robert

javascript - prependTo closest specified Parent div from an iframe -

i'm trying use jquery inside iframe .prependto .class div inside parent. this has multiples of same .class. **edit , iframes everything on same domain. so, inside main document: <div class="newphotos"> **<!--put me here!-->** <div class="linephoto"> <a href="images/518279f07efd5.gif" target="_blank"> <img src="images/thumb_518279f07efd5.gif" width="50" height="50"> </a> </div> <iframe class="uploadlineid_55" width="800px" height="25px" src="../../uploads/uploadiframe.php" scrolling="no" seamless></iframe> </div> script inside iframe : $(document).on("click", '#test', function() { appendimagetoparent(); }); function appendimagetoparent() { var data = '<div class="linephoto"><a href="images/

android - How to use custom adpter with endless adapter -

i trying work endless adapter , followed example http://droidista.blogspot.com/2011/04/using-cwacs-endlessadapter-with-custom.html and i have tried code public class mainactivity extends activity { static int list_size; private int mlastoffset = 0; static final int batch_size = 10; private rotateanimation rotate = null; arraylist<string> templist = new arraylist<string>(); string[] product = new string[]{"p1" , "p2" , "p3" , "p4" , "p5" ,"p6" , "p7" , "p8" , "p9" , "p10" , "p11" ,"p12" , "p13" , "p14" , "p15" , "p16" , "p17" ,"p18" , "p19" , "p20" , "p21" , "p22" , "p23" ,"p24" , "p1" , "p2" , "p3&qu

knockout.js - Unable to format date with KendoUI Grid and Knockout-Kendo -

i having trouble getting date parse kendo grid. using knockout-kendo assist data-bindings. the date-string in json response attempting parse looks 2012-03-13t00:00:00 . the column definition kendo grid contains format: '{0:mm/dd/yyyy}' seems work on grid isn't using knockout-kendo parse exact same date string. i have created (well re-using separate question) jsfiddle demonstrates the issue here . i want stay away row-templates because haven't figured out how correctly set them in knockout binding, open alternative or "just correct" suggestions. it possible specify datasource in configuration. need still specify data key, binding know passing options , not data directly. can like: <div id="grid" data-bind="kendogrid: { data: undefined, datasource: { data: salesearchresults, schem

iphone - Name input like SMS or Facebook app -

i'm trying find library can handle autocompletion tokened (grouped) texts. there nice libraries out there autocompletion such as: https://github.com/eddyborja/mlpautocompletetextfield https://github.com/hoteltonight/htautocompletetextfield https://github.com/tarasroshko/trautocompleteview the problem here is, want make selection names tagging @ sms or facebook app. when user tries delete, should delete text. there jquery implementations, 1 of them this: http://loopj.com/jquery-tokeninput/ i couldn't find ios, perhaps keywords generic, google not show related results. there library or can provide code examples? what you're trying achieve can't done using public sdk. however, there exist nice third party solutions. found question, is there iphone equivalent nstokenfield control? , includes links controls use.

python - Preventing db.get() from returning outdated records -

i working on app has users taking turns put()-ing data datastore, has id broadcast user via channel. sometimes, when users get(), it'll show previous user's changes. how can prevent this? there way have put() block until it's written? take @ ancestor queries in docs. https://developers.google.com/appengine/docs/python/datastore/structuring_for_strong_consistency you seeing consistent results, although in case need consistent results.

android - Image in Widget -

i trying set image in image view in widget layout in onupdate, image not updating @override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { log.i(tag, "onupdate called"); (int appwidgetid : appwidgetids) { bitmap bitmap=imageutils.getbitmap(context, appwidgetid); remoteviews remoteview = new remoteviews(context.getpackagename(), r.layout.widget); remoteview.setimageviewbitmap(r.id.imgview,bitmap); appwidgetmanager.updateappwidget(appwidgetid, remoteview); } } xml layout widget <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <imageview android:id="@+id/imgview" android:layout_width="fill_pare

java - Running a batch file that's inside of a jar file -

i'm attempting call batch file packaged inside of jar file jar file itself. i'm not altogether sure possible, figured if knew how on here. import java.io.ioexception; import java.net.urisyntaxexception; public class filelocationfinder { public static void main(string[] args) throws ioexception, urisyntaxexception { string curdir = system.getproperty("user.dir"); system.out.println("the user.dir = " + curdir); file newfile = new file (filelocationfinder.class.getprotectiondomain().getcodesource().getlocation().touri().getpath()); string strnewfile = newfile.tostring(); system.out.println("the new path = " + strnewfile); string abpath = new file(".").getabsolutepath(); system.out.println("the absolutepath = " + abpath); string conpath = new file(".").getcanonicalpath(); system.out.println("the canonical path = " + conpath);

shell - Bash Parse CSV - Formating Datasets -

i have csv following format dataset1, … … dataset2, .. .. dataset3, all datasets seperated blank lines. bash script change formatting of file to dataset1 dataset2 dataset3 ... … … … … … … … … here's script, or guidance appreciated #!/bin/bash input="/path/to/csv/file/file.cvs" while ifs=',' read -r f1 f2 f3; if [ -z "$f1 $f2 $f3" ]; awk 'begin{getline to_add < "$f1 $f2 $f3"}{print $0,to_add}' f fi echo "$f1 $f2 $f3" done < "$input" the below pure shell (no embedded awk/perl) work. has limitations. works same number of records in each set. handle differnt numbers need mainting count of records in each set , embed emty records ,,,,,,, required. set -u row=0 set=1 maxrow=0 while read line if [ -z "$line" ] #

ios - My UIStepper is not animated -

i'm using uistepper added through storyboard. had iboulet reference uitableviewcell subclass , ibaction when stepper's value changed. my problem when touch uistepper , there no animation. i'm quite new in ios dev can't find out why. there header file: //cellsubclass.h @interface saproductcell : uitableviewcell @property (weak, nonatomic) iboutlet uistepper *quantitystepper; - (ibaction)steppervaluechanged:(id)sender; and implementation: //cellsubclass.m - (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring*)reuseidentifier { self = [super initwithstyle:style reuseidentifier:reuseidentifier]; if (self) { self.quantitystepper.minimumvalue = 0; self.quantitystepper.stepvalue = 0; self.quantitystepper.value = 1; } return self; } // ... - (ibaction)steppervaluechanged:(id)sender{ self.quantity = [[nsnumber alloc] initwithdouble:([self.quantitystepper value])] ; //[self refreshui]; --> works fin

oop - Need C# Class method that persists information already in Object -

i have created class in asp.net project called litholdmodifications. here's code: [serializable] public class litholdmodifications { private boolean _changed; private hashtable _added; private hashtable _deleted; public boolean changed { { return _changed; } set { _changed = value; } } public hashtable added { { return _added; } set { _added = value; } } public hashtable deleted { { return _deleted; } set { _deleted = value; } } public hashtable add(string item1, string item2) { added = new hashtable(); added.add(item1, item2); return added; } public hashtable delete(string item1, string item2) { deleted = new hashtable(); deleted.add(item1, item2); return deleted; } } the problem i'm having need able add multiple items instance of class. code have (in aspx page): public litholdmodifications affect

cocoa touch - How to detect if I'm using an undocumented api in iOS -

i'd figure out if i'm using undocumented api's in app. there hallmarks or patterns can out i.e., if use code in project website? before submitting app apple, can use xcode tools validate code. the apple documentation says: in ios 5 development tools, possible extract apis used application , have them checked use of private apis. option offered when validate application app submission. also, use deploymate detect unavailable api usage during development.

jquery - altering <a> tag for JavaScript -

how utilize javascript move active link state link? please see codepen: http://codepen.io/krish1980/pen/mgfed <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script> <script type="text/javascript"> $(function(){ $('#nav a').on('click',function(){ $('#nav li').removeclass('active'); $(this).parent().addclass('active'); }); }); </script> //wrap click handler in documentready handler //attached after elements have been loaded dom $(document).ready(function() { //attach click handler <li> elements under //the element id "nav" $("#nav li").click(function() { //whenever 1 of <li> elements clicked, remove //"active" class element has it. $(".active").removeclass("active"); //add "active" class element triggered function //(the <li&

python - Assigning a function (which is assigned dynamically) along with specific parameters, to a variable. -

ok, here's deal, have function( take_action ), calls function. don't know function take_action going call. i had part figured out this question , thing is, on question deal functions take no arguments, take_action take 1 of several different functions quite different each other, different actions taken, different arguments. now example code: def take_action(): action['action']() #does other stuff 'other_stuff_in_the_dic' def move(x,y): #stuff happens action = {'action': move, 'other_stuff_in_the_dic': 'stuff' } (in case 'action' move, said, that's assigned dynamically depending on user input) what do, this: action = { 'action': move(2,3), 'other_stuff': 'stuff' } (obviously calls function there, since has (), hence wouldn't work) i'm beginner programmer, , thing thought of using list, in key inside dic, pass 1 list argument, instead of each content of list being

java - Loading Properties File from Static Context -

i've found myself faced pretty interesting issue. have properties file in application, , attempting load static context. properties file loaded class image , static class. in eclipse works fine, when tried export jar, it's not worked. prop.load(new fileinputstream(new file(images.class. getclassloader(). getresource("config.properties"). tostring()))); this line i've tried use already, when try run program, throws error: exception in thread "main" java.lang.nullpointerexception @ controllers.images.loadimagefiles(images.java:47) @ views.world.<init>(world.java:55) @ views.world.main(world.java:40) i @ loss here, question is: how load resource static context, , more importantly, need register file resource before this? edit after searching, i've established getresource method returning null . big question now, guess, why!? file structure follows: project src controllers <-- images clas