Posts

Showing posts from January, 2011

java - Is it possible to prevent some attributes from being marshalled with JAXB? -

i need value changed via xml file. in other words, have like: <settings> <enabled>true</enabled> <property>something</property> </settings> and want enabled value manipulated in xml file. want values loaded file (unmarshalled), want jaxb leave original value in file , output (marshal) other values file. scenario can required example if while being processed, want modify xml file manually, , disable something, don't want jaxb later overwrite particular value, of course other values need written file after processing date. is possible achieve jaxb?

jquery - Get values from dynamically created fields and send them to PHP via Ajax -

i have page text field field name , 2 buttons (insert field, show fields) . the user inserts value inside of first text field that's going new field's name. when clicks on insert field value going send database , inserted table called tbl_fields . and when user clicks on show fields , page loads field names tbl_fields , creates n text fields it's placeholders containing names loaded. these fields shown inside of .fieldlist div contains button insert values , when user clicks on it, want values these dynamically created fields it's placeholders , insert them database table called tbl_values , table has 3 columns, id , field_name represents name (placeholder) of field , field_value represents value of field. so question is, how can values , placeholders these dynamically created fields , send them .php file via ajax? know can use .val() it's value , .attr('placeholder') placeholder that's not point, problem don't know how many fie...

How do I use RegEx to extract something ending in zipcode -

Image
if have text in format mail - {what want extract) 98012-2345 do? dont seem able regex termination ddddd-dddd so far have tried pattern of mail (.*) [ddddd]-[dddd] this using .net 4.6. regex share | improve question edited aug 29 '16 @ 2:50 cyrus mohammadian 2,182 2 12 32 asked aug 29 '16 @ 0:37 rahul chandran 1 1      ...

How to add multiple values to a key in a Python dictionary -

i trying create dictionary values in name_num dictionary length of list new key , name_num dictionary key , value value. so: name_num = {"bill": [1,2,3,4], "bob":[3,4,2], "mary": [5, 1], "jim":[6,17,4], "kim": [21,54,35]} i want create following dictionary: new_dict = {4:{"bill": [1,2,3,4]}, 3:{"bob":[3,4,2], "jim":[6,17,4], "kim": [21,54,35]}, 2:{"mary": [5, 1]}} i've tried many variations, code gets me closest: for mykey in name_num: new_dict[len(name_num[mykey])] = {mykey: name_num[mykey]} output: new_dict = {4:{"bill": [1,2,3,4]}, 3:{"jim":[6,17,4]}, 2:{"mary": [5, 1]}} i know need loop through code somehow can add other values key 3. dictionary , associative array or map (many names, same functionality) property keys unique. the keys wish have, integers, not unique if lengths same, that's why code doesn't...

Access variable from the block's scope inside a method call in Ruby -

i trying create minitest assertion similiar rails assert_difference checks differences not numeric one. here current implementation: minitest::assertions.module_eval def assert_changed(expression, &block) unless expression.respond_to?(:call) expression = lambda{ eval(expression, block.binding) } end old = expression.call block.call refute_equal old, expression.call end end now in test suite call doing following: # working username = 'jim' assert_changed lambda{ username } username = 'bob' end # not working username = 'jim' assert_changed 'username' username = 'bob' end the first call assert_changed using lambda (or proc) works fine. second call using string variable name not working. when hits line: expression = lambda{ eval(expression, block.binding) } keep getting error typeerror: no implicit conversion of proc string . can please explain me how work? note: got eval(expression, bloc...

javascript - Lodash - can you continue chaining after variable declaration? -

this bit of code: var foo = [1, 2, 3], bar = _.chain(foo) .map(number => number * 2); console.log(bar.value()); bar.tap(numbers => { numbers.push(10000); }); console.log(bar.value()); the 10000 won't added bar.value() . if move tap chain during actual variable chain, works fine. i'm has context of tap called, can explain? seems nice init chain , modify later. thanks! bin demonstration: http://jsbin.com/kidomeqalo/edit?html,js,console js bin on jsbin.com just adding bar.tap(); doesn't change anything. need include in chain: bar = bar.tap(numbers => { numbers.push(10000); }); console.log(bar.value()); or console.log(bar.tap(numbers => { numbers.push(10000); }).value()); on top of that, should not use tap executing side effects. rather use bar.concat(10000).value() or that, makes clear creates new result in functional way instead of mutating - becomes confusing sequences evaluated lazily.

android - how to open content shared by other apps? -

i want open links shared apps firefox or youtube in webview. whenever press share button, it launches app , never loads url- // url browsable intent filter textview uri = (textview) findviewbyid(r.id.urlfield); // url url = getintent().getstringextra(intent.extra_text); uri data = getintent().getdata(); if (data == null) { uri.settext(""); } else { uri.settext(getintent().getdata().tostring()); fadeout(); } // } webview = (webview) findviewbyid(r.id.webview); // load url browsable intent filter if there valid url pasted if (uri.length() > 0) webview.loadurl(url); else // dont load manifest <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> <intent-filter> <action android:name=...

node.js - How to authenticate/authorize express routes in loopback -

i've created loopback app , extended user model user authentication/authorization. i'm trying check if user logged in or not express route redirect user /login if user not logged in. so far seems loopback authenticates/authorizes exposed model methods /user/update . i'm not able find on how loopback authenticate/authorize express routes i've defined. thanks in advance here's thing, i'm not @ loopback know little expressjs. in express, if wanna auth, can use middleware of own , use before other routes handle request. you might want consider express-session login status storage. when log in : route.post('/login',function(req,res,next){ //login here req.session.user = user }) and own middleware: function auth(req,res,next){ if(!req.session.user){ res.redirect('/login') } } https://github.com/expressjs/session

java - EOFexception caused by empty file -

i created new file roomchecker empty. when read it, throws me eofexception undesirable. instead want see that, if file empty run other 2 functions in if(roomfeed.size() == 0) condition. write statement in eofexception catch clause; that's not want because every time when file read , reaches end of file execute functions. instead when file has data should specified in else. file filechecker = new file("roomchecker.ser"); if(!filechecker.exists()) { try { filechecker.createnewfile(); } catch (ioexception e) { e.printstacktrace(); system.out.println("unable create new file"); } } try(fileinputstream fis = new fileinputstream("roomchecker.ser"); objectinputstream ois = new objectinputstream(fis)) { roomfeed = (list<roomchecker>) ois.readobject(); system.out.println("end of read"); if(roomfeed.size() == 0) { system.out.println("your in null if statement"); def...

javascript - Access an array item in its definition, relative index -

i trying define array: postlists = [ [ [46276,76235,78128], postlists[0][0].length, 1100 ], [ [], postlists[1][0].length, 0 ] ]; however, undefined error postlists[x][0].length lines. how access array being defined itself? there way relatively select item without referencing entire "path" folders? example in case, [0].length [46276,76235,78128] 's length, or ..[1] (parent) select postlists[1] . postlists[x][0] hold hundreds of thousands of integers, performance need considered. postlists[x][1] original length needs accessed every few seconds, because of size of postlists[x][0] , cannot accessed on fly without harming performance. postlists[x][2] index keep track (and store) items processed, in postlists[0][2] 1100 used skip 1100 first items have been processed. i using in greasemonkey script, reason sub-arrays in postlists plan use script on multiple tabs running @ same time. the sta...

showing listview JSON AsyncTask value on android -

i use listview final arrayadapter<string> adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1); adapter.add("json result value"); adapter.add("json result value"); adapter.add("json result value"); listview listview = (listview) findviewbyid(r.id.listview); listview.setadapter(adapter); xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <listview android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </linearlayout> and json source. private textview textview; string strdata = ""; @override protected void oncreate(bundle sa...

sql - Two group by tables stich another table -

i have 3 tables need put together. first table main transaction table need distinct transaction id numbers , company id. has important keys. transaction ids not unique. second table has item info linked transaction id numbers not unique , need pull items. third table has company info has company id. now i've sold of these first 1 through group id. second through subquery creates unique ids , joins onto first one. issue i'm having third 1 company. cannot seem create query works in above combinations. ideas? as suggested here code. works that's because company used count doesn't give correct number. how else can company number come out correct? select dep.itemidapk, dep.totalone, dep.company, company.vendname, appd.itemidapk, appd.itemname ( select csi.itemidapk, sum(f.totalone) totalone, count(f.dimcurrentcompanyid) company dbo.reportone f (nolock) inner join dbo.dsaleitem csi (nolock) on f...

xml - How to move two row values to column and respective row in xquery -

below xml output have extract values details fields- 1st value column name , 2nd value value in row. example: column name - renamedcount , row value 64 column name -successupdatecount , row value 64 , on.. <root> <details> <values>renamedcount</values> <values>64</values> <values>successupdatecount</values> <values>64</values> <values>totalcreatecount</values> <values>0</values> <values>successrowcount</values> <values>64</values> <values>invalidcount</values> <values>0</values> <values>totalupdatecount</values> <values>4211</values> <values>failedcount</values> <values>64</values> <values>totalrowcount</values> <values>0</values> <values>4275</values> <o...

php - WordPress get_the_post_thumbnail - get the custom size image? -

i have set featured image/ thumbnail 600x530 in functions.php: if (function_exists('add_theme_support')) { add_theme_support('post-thumbnails'); set_post_thumbnail_size(600, 530, true); // default post thumbnail dimensions (cropped) } but can't retrieve size via: echo get_the_post_thumbnail($post->id, array(600, 530), array('class' => 'img-responsive')); the image 169x300 or large un-cropped original size . want 600x530 . any ideas? this explain here : you can specify additional custom sizes! here’s code: functions.php add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 50, 50, true ); // normal post thumbnails add_image_size( 'single-post-thumbnail', 400, 9999 ); // permalink thumbnail size home.php or index.php , depending on theme structure (in loop) <?php the_post_thumbnail(); ?> single.php (in loop): <?php the_post_thumbnail( 'single-post-thumbnail...

javascript - Set timeout while loading image in Div Background -

i loading image background url div:- <div style="background-image: url('image.jpg'),url('fallback.jpg');"></div> as understand, fallback image shown if there error while calling image.jpg . :- will handle timeout errors when calling image.jpg? if yes, timeout duration? how control timeout duration? edit: understood comments above not fallback, loading 1 on another. need set timeout , show alternate image after original not loaded in timeout. you won't able find out time taken image loaded after set timeout, since might take little longer think depending on size of image. have worry order in assigning css properties fallback image. like, setting "no-repeat" first one, , opposite second on. her, can refer https://css-tricks.com/stacking-order-of-multiple-backgrounds/

javascript - Nested map and filter methods -

i trying wrap head around functional programming in javascript. goal retrieve object boxarts items width=150 , height=200 . console.log(arr) displays [ [ [ [object] ], [ [object] ] ], [ [ [object] ], [ [object] ] ] ] i not sure why unable print actual values. concatall method used flatten arrays. working through reactivex.io tutorial on functional programming. array.prototype.concatall = function() { var results = []; this.foreach(function(subarray) { subarray.foreach(function(item){ results.push(item); }); }); return results; }; var movielists = [ { name: "instant queue", videos : [ { "id": 70111470, "title": "die hard", "boxarts": [ { width: 150, height: 200, url: "http://cdn-0.nflximg.com/images/2891/diehard150.jpg" }, { width: 200, height: 200, url: "http://cdn-0.nflximg.com/images/2891/diehard200.jpg" } ], "ur...

Plone restart after buildout fails. How to find the error -

lately have been trying customize plone adding helpful addons via eggs section of buildout.cfg, running buildout , restarting zeocluster plonectl restart . have succesfully installed several addons way. stop plone working. example trying add plone.app.ldap : buildout works fine , restart of server works initially, when accessing plone in browser doesn't load , plonectl status tells me 2 clients have lost connection zeoserver. events log tells same story, other not see error caused problem. when remove addon works fine again. is way handling addons correct? did miss something? can find additional information crashes zeocluster? some problems swallowed on startup. can see them starting client on foreground bin/zeoclient fg . see http://docs.plone.org/manage/troubleshooting/basic.html note: zeoclient script may called client, or client1 or instance or that, depending on how named in buildout. this show python traceback. maybe add-on missing dependency. problem r...

expand first div when second div or third div collapsed using jquery -

i have 3 divs. here code. <div class="div1">div1 content</div> <div class="div2">div2 content</div> <div class="div3">div3 content</div> using jquery how can expand div1 if div2 or div3 collapsed? i think looking for. please check fiddle html <div id="accordion"> <h3>div1</h3> <div><p>div1 content</p></div> <h3>div2</h3> <div><p>div2 content</p></div> <h3>div3</h3> <div><p>div3 content</p></div> </div> js $(document).ready(function(){ $( "#accordion" ).accordion({ collapsible: true }); $('.ui-accordion-header').click(function(){ if ($("#accordion").find(".ui-accordion-header-active").length == 0 ) { $("#accordion").find(".ui-accordion-header").eq(0).click(); } }); })...

linux - DAPM routing in ALSA -

i need clarification on alsa layer. audio codec driver has dapm widgets , dapm routes. used while registering codec. machine driver has different set of dapm widgets , dapm routes. used while registering card. can tell me whether audio codec driver , machine driver dapm widgets , routes need same ? thanks mp i have got answer... dapm routing can placed either in dt (machine driver use) or codec driver. need not configured in both codec driver , machine driver.

vb.net - .Net Windows Form Arabic Encoding issue at Runtime -

Image
i created vb.net windows forms project under vs2008 , windows vista, when take code other pc having vs2015 , windows 10 faced encoding problem, application has arabic captions in it, visual studio able read captions when click start (f5) compile , run app see arabic text not encoded. knowing when took compiled version of app old pc , run in new pc behave expected , arabic texts displayed well, problem here on compile time of vs2015 under windows 10. i searched around issue advises try open files code editor , use compatible encoding, don't have problem reading code content, problem when compiling code not encode arabic text. the following code of frmwelcome.designer.vb <global.microsoft.visualbasic.compilerservices.designergenerated()> _ partial class frmwelcome inherits system.windows.forms.form 'form overrides dispose clean component list. <system.diagnostics.debuggernonusercode()> _ protected overrides sub dispose(byval disposing boolea...

How to save the edited canvas to image as original image size in android -

i trying draw on image , save image. can succesfully draw on image. facing 2 problems. when draw on image allow draw out side of image also. want draw on image only. second issue when save image getting struched. want save image original size. please me resolve problems. here post entire code. public class drawingpaint extends view implements view.ontouchlistener { private canvas mcanvas; private path mpath; private paint mpaint, mbitmappaint; public arraylist<pathpoints> paths = new arraylist<pathpoints>(); private arraylist<pathpoints> undonepaths = new arraylist<pathpoints>(); private bitmap mbitmap; private int color; private int x, y; private string texttodraw = null; private boolean istextmodeon = false; int lastcolor = 0xffff0000; static final float stroke_width = 15f; public drawingpaint(context context/*, int color*/) { super(context); //this.color = color; setfocu...