Posts

Showing posts from March, 2012

ORD and CHAR in Scratch -

i coming across more , more situations in scratch have convert number acsii character or visa versa. there no built function in blocks this. my solution create list of size 26 , append letters a-z each sequence using variable called alphabet = "abcdefghijklmnopqrstuvwxyz" , iterating on repeat block , appending letter count of alphabet list.the result list data structure letters a_z between location 1 26.in effect creating own ascii table. to converson number 26 'z' have iterate on list correct char value. slows down program heavily dependent on chr() feature. there better or more efficient solution? my solution create list of size 26 , append letters a-z each sequence using variable called alphabet = "abcdefghijklmnopqrstuvwxyz" stop right there. don't need convert list. can directly string. to character index easy. use (letter () of []) block. to index of character more complex. unfortunately, scratch doesn't have buil

jersey 2.0 - How Can i pass the Basic Credentials while using REST API client Program -

client client = client.create(); client.addfilter(new httpbasicauthfilter("username", "password")); webresource resource = client.resource("https://server.location.path"); //webresource.builder builder=resource.getrequestbuilder().header("authorization", "basic base64value"); clientresponse response = resource.accept("application/json") .get(clientresponse.class); system.out.println(response); string output = response.getentity(string.class); system.out.println("output server .... \n"); system.out.println(output); here have been placed code , please let me know have suggestion please

java - Simple Algorithm complexity -

i have algorithm , need finding complexity of (tightest possible upper bound) for(int = 0; < n/2; i++) for(int j = 0; j < n/4; j++) for(int k = 0; k < n; k++) x++; my analysis if n not divided in each loop, o(n^3) . complexity still holds true, since each "for loop" reduce each operation o(log n) complexity since divides n every time loop executes, making smaller , smaller (smaller o(n) @ least). i answer between o(log n) , o(n^3) . me getting tightest possible bound? start inner loop : for(int k = 0; k < n; k++) x++; is o(n). now 1 layer above : for(int j = 0; j < n/4; j++) is o(n) because takes n/4 j reach n , know o(n/4) = o(n) and outer loop o(n).so complexity o(n^3) because have 3 nested loop each o(n) , non of them have effect on each other.

q lang - (kdb+/q) append to dictionary -

i trying programmatically construct arguments functional select call having form: ?[ `t; () ; groupby; ()] the problematic part groupby , should dictionary. suppose objective arrive @ parse tree in form: parse "select sym,month:`date$dt.month t" i start constructing by part with: groupby: enlist[`sym]!enlist(`sym) then try append month part of group statement (note periodicity parameterised): per: `month / monthly periodicity groupby,: {enlist[x]!enlist[ $[x = `day; `dt; $[x=`month; ((parse "select month:`date$dt.month x")@3)@`month ;` sv (`dt,x)] ]] }[per] however, throws type error. goes wrong? i think doesn't compound assignment groupby,:{...} try groupby:groupby,{...} the difference in first case it's trying directly alter data in memory with

iphone - Instagram filter integration my project but run my project then only normal filter call and other call then some issue (below mention) -

cgcontextdrawimage: invalid context 0x0. serious error. application, or library uses, using invalid context , thereby contributing overall degradation of system stability , reliability. notice courtesy: please fix problem. become fatal error in upcoming update. please me......

.net - Best way to parse command line arguments in C#? -

when building console applications take parameters, can use arguments passed main(string[] args) . in past i've indexed/looped array , done few regular expressions extract values. however, when commands more complicated, parsing can pretty ugly. so i'm interested in: libraries use patterns use assume commands adhere common standards such answered here . i suggest using ndesk.options ( documentation ) and/or mono.options (same api, different namespace). example documentation : bool show_help = false; list<string> names = new list<string> (); int repeat = 1; var p = new optionset () { { "n|name=", "the {name} of greet.", v => names.add (v) }, { "r|repeat=", "the number of {times} repeat greeting.\n" + "this must integer.", (int v) => repeat = v }, { "v", "increase debug message verbosity", v => { if (v != nu

javascript - Zepto greater than selector -

is possible in zepto selecting elements greater or less index: $( "td:gt(4)" ).css( "backgroundcolor", "yellow" ); $( "td:gt(-2)" ).css( "color", "red" ); as on https://api.jquery.com/gt-selector/ short answer: no longer answer: according zepto js jquery css extensions not supported . zepto has css extended selectors ( github ) not support functionality looking for.

javascript - Searching particular fields using AngularJS -

i have read angularjs documentation pertaining filters here find difficult understand. have list of airlines, including airline name, airline country, , flag indicate whether airline deleted. without filter rows being displayed expected. i need search on 3 fields , have inputs (yes using bootstrap): <div class="row"> <div class="col-sm-2" style="text-align: right"> <label for="airport-name-search" class="control-label">airline name</label> </div> <div class="col-sm-2"> <input ng-model="search.airlinenamesearch" type="text" class="form-control input-sm" id="airport-name-search"/> </div> <div class="col-sm-2" style="text-align: right"> <label for="country-name-search" class="control-label">country name</label> </div> &l

How to read Python package metadata without installation? -

i have python program sort of wrapper around pip use assist development of python packages. problem face how read metadata such name , version of package (generally '.tar.gz' , '.whl' archives) without installation. can distutils or other tool this? just few notes... code written python 3, working sorts of python packages such sdist , bdist_wheel both py2 , py3. i'm concerned local packages have path to, not theoretical packages available on pypi. what i'm doing works fine, seems pretty messy , i'm wondering if there better tool can abstract this. right reading metadata text file within archive , manually parsing out fields need. if fails, stripping name , version out of package's file name (really terrible) . there better way this? here 2 functions using parse package name , version . update simeon, thank suggestion use metadata.json file contained within wheel archives. i'm not familiar of files contained within archives had

Can login page can be tested in Jmeter -

can login page (where need enter credentials) tested? , url of website after login page can tested without login? jmeter able simulate login event , represent authenticated user. see i.e. asp.net login testing jmeter guide example configuration , associated correlations. if need simulate n authenticated users , x unauthenticated ones use throughput controller scenario distribution.

Address validation form API or Database on iOS? -

i'm working on ios app users can purchase products , them delivered home. before actual purchase, user have input delivery address in united kingdom. for example, user types in postcode "sw1a 2ab", , uipicker shows listing possible matches such "11 downing st". i know if there ressources or services online (free ideally) address lookup based on uk postcode user provide on form. since app launched in uk , products can delivered here, don't have worry other kinds of address formats. it sounds after postcode address lookup within uk involves using royal mail postcode address file (paf) comes cost, reliable source uk address data. can bought data file directly royal mail several apis exist, meaning don't need worry storing , updating on 29 million addresses. i work allies computing provide cloud hosted rest based api , uses royal mail's daily updates , can paid on per search basis. of course other providers exist offering similar api

json - Web API - Cannot de-serialize request object -

i trying create quick application try learn angularjs web api (i have worked asp.net mvc not had chance use web api) server-side, cannot seem object serialize when posting the web api method. my object simple user object inherits baseentity object: public class user : baseentity { /// <summary> /// gets or sets name. /// </summary> /// <value> /// name. /// </value> public string name { get; set; } /// <summary> /// gets or sets email. /// </summary> /// <value> /// email. /// </value> public string email { get; set; } /// <summary> /// gets or sets password. /// </summary> /// <value> /// password. /// </value> public string password { get; set; } } public class baseentity : mongorepository.entity, interfaces.ientity { /// <summary> /// gets or sets id object (the primary record entity).

ui-grid angularjs checkbox button not being resorted -

grid angularjs have checkbox column after check 1 column , sort other column example age active column not being resorted plunkr of pbm " http://plnkr.co/edit/q3fs3xirbpqkzkdzlgxw?p=preview " <!doctype html> you have problem cell template. not binding value isactive checkbox. change checkbox column { name: 'isactive', displayname: 'active', type: 'boolean',celltemplate: '<input type="checkbox" ng-model="row.entity.isactive">'} this plnkr works right. http://plnkr.co/edit/pl7hvk1fy2ycuorbbbta?p=preview

json - convert image 64X64 px after decoding base64 image in php -

hi retriving base64 encoded version of image , have stored cropping small size. not able crop image please me code follow.. please me in cropping base 64 image $data = str_replace('data:image/png;base64,', '', $note['file']); $data = str_replace(' ', '+', $data); $decodedfile = base64_decode($data); $file = fopen($destination , 'wb'); if(!fwrite($file, $decodedfile)){ //return("error: can't save file $destination"); return '-1'; } fclose($file); you can use gd library create image file binary code: function binarytofile($binary_imagen, $width, $height, $new_name, $url_destiny) { try{ //actual size $info = getimagesizefromstring($binary_imagen); $old_width = $info[0]; $old_height = $info[1]; //new resource $resource = imagecreatefromstring($binary_i

python - How to sort by two lines and print the line with the highest value -

i have input file, 1a traes_1as_6052071d9.1 99.01 101 99.0 1a traes_1ds_6ba87d1da.1 96.04 101 99.0 1a traes_1bs_480915ad0.1 94.06 101 99.0 1b traes_1as_49d585ba6.2 99.01 101 72.0 1b traes_1bs_47f027bbe.2 98.02 101 89.0 1b traes_1ds_3f816b920.1 97.03 101 92.0 1c traes_1as_3451447e0.1 99.01 101 97.0 1c traes_1bs_9f243cea6.2 92.93 99 97.0 1c traes_1ds_2a6443f45.1 89.90 99 97.0 i need to group , iterate inside each line[0] , sort line[4] lowest highest value , take highest value if similar, print results choosing 1 has highest value in line[2] , output file looks this: required output: 1a traes_1as_6052071d9.1 99.01 101 99.0 1b traes_1ds_3f816b920.1 97.03 101 92.0 1c traes_1as_3451447e0.1 99.01 101 97.0 this try, takes according highest line[4] : import csv itertools import groupby operator import itemgetter open('my_file','rb') f1: open('out_

c# - WCF service is working on dev server but on production it is not woking -

i have .net client , consuming wcf service , able sucessfully. when try post on our production not able consume same service. below web.config : <system.servicemodel> <behaviors> <servicebehaviors> <behavior name="mybehavior"> <userequestheadersformetadataaddress></userequestheadersformetadataaddress> <servicemetadata httpgetenabled="true"/> <servicedebug includeexceptiondetailinfaults="false"/> <servicecredentials> <usernameauthentication usernamepasswordvalidationmode="custom" customusernamepasswordvalidatortype="testproject.implementations.authenticateuser,testproject"/> <servicecertificate findvalue="localhost" x509findtype="findbysubjectname" storelocation="localmachine" storename="my"/> </servicecredentials> </behavior> </servicebehaviors> </b

youtube api - How to distinguish between published and unpublished Comments/Replies v3 -

is there way distinguish between comments approved , published , comments not yet approved? i have video option approved comments shown. call commentthreads route in youtube v3 data api option moderationstatus = heldforreview comments held review , waiting approval comments approved have @ least 1 reply not. my problem found no way distinguish between both.

android - infoWindow's image now showing on first click, but it works on second click -

my android using google map android api,infowindow's image not showing on first click, works on second click i customize infowindow using void setmapinfowindow(){ mmap.setinfowindowadapter(new googlemap.infowindowadapter() { @override public view getinfowindow(marker arg0) { return null; } @override public view getinfocontents(marker arg0) { view v = getlayoutinflater().inflate(r.layout.windowlayout, null); final imageview img = (imageview)v.findviewbyid(r.id.imageview3); //image picasso.with(context).load("http://imgurl").resize(140, } }); } here marker set process void setmarkers(){ ... (int = 0; < jsonarray.length(); i++) { jsonobject datas=jsonarray.getjsonobject(i); markeroptions tmp=new markeroptions() .title("name") .alpha(0.6f) .position(new latlng(12

javascript - Issue using Ajax to add to database -

i tried posting flagged php i'm hoping time ajax or jquery more responses. i've been having issue ajax add function week now. code using works in application no issues. i'm hoping can see if i've made mistakes or causing it. i've been able add items database via curl commands no issue isn't php code include 100% clarity. using slim framework php code $app->post('/additems/', 'additems'); function additems() { $request = \slim\slim::getinstance()->request(); $q = json_decode($request->getbody()); $sql = "insert items(item1, item2, item3, item4, item5, item6, item7, item8, item9) values (:item1, :item2, :item3, :item4, :item5, :item6, :item7, :item8, :item9)"; try{ $db = getconnection(); $stmt=$db->prepare($sql); $stmt->bindparam("item1", $q->item1); $stmt->bindparam("item2", $q->item2); $stmt->bindparam("item3", $q-&

Vertical Line in Visual Studio? -

Image
does visual studio provide functionality visualise vertical line among code? notepad++ has functionality. install addon in vs.net https://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30

java - NPE while testing -

i've got nullpointerexception on method teststartenbaledfeed on line of rssservicetest service.start(); , on line of rssservice job.addjobchangelistener(new jobchangeadapter() { the key problem seems job.addchangelistener method called real. know how solve it? rssservicetest , rssservice classes listed below: package org.eclipse.recommenders.internal.news.rcp; import static org.hamcrest.corematchers.*; import static org.junit.assert.assertthat; import static org.mockito.mockito.*; import org.eclipse.mylyn.commons.notifications.core.notificationenvironment; import org.junit.test; import org.junit.runner.runwith; import org.mockito.mockito; import org.mockito.runners.mockitojunitrunner; import com.google.common.collect.immutablelist; import com.google.common.eventbus.eventbus; @suppresswarnings("restriction") @runwith(mockitojunitrunner.class) public class rssservicetest { private static final string first_element = "first"; private static final stri

ms word - Reading a TXT File with VBA suddenly doesn't work anymore -

i in process of converting old macros word 2003 word 2013. thought have build fancy ribbon bar , done it, apparently not. the following code supposed read whole content of txt file , put clipboard. how create object , make call function: dim mydata dataobject set mydata = new dataobject mydata.settext loadtextfile("c:\testdocs\readthisfile.txt") mydata.putinclipboard and actual function: public function loadtextfile(sfile string) string dim ifile integer on local error resume next ifile = freefile open sfile input #ifile loadtextfile = input$(lof(ifile), ifile) close #ifile end function afterwards i'm getting following error: run-time error '-2147024809 (80070057)': dataobject:settext invalid argument. and said: code works fine in word 2003 same file. based on error, suggest read text file 1 line @ time, looping through till eof (end of file). give bit more flexibility. here how need modify loadtextfile me

angularjs - How can i make bar & pie charts in angular js -

i want make charts, bar chart , pie chart. has take inputs user , maps input chart on run time. chart has able make changes user changing on run time. great help. thanks you can use angular chart (using chart.js) angular charts using d3 angular-nvd3 you can use google charts also. can use angularjs

openerp - Odoo 8 error when trying to open product with multiple attributes -

our odoo version 8 , running on ubuntu. when try open product has multiple attributes (colours, sizes) keyerror: 57. other simple products ok. any idea can cause problem ? here complete traceback: odoo server error traceback (most recent call last): file "/opt/odoo/odoo/openerp/http.py", line 530, in _handle_exception return super(jsonrequest, self)._handle_exception(exception) file "/opt/odoo/odoo/openerp/http.py", line 567, in dispatch result = self._call_function(**self.params) file "/opt/odoo/odoo/openerp/http.py", line 303, in _call_function return checked_call(self.db, *args, **kwargs) file "/opt/odoo/odoo/openerp/service/model.py", line 113, in wrapper return f(dbname, *args, **kwargs) file "/opt/odoo/odoo/openerp/http.py", line 300, in checked_call return self.endpoint(*a, **kw) file "/opt/odoo/odoo/openerp/http.py", line 796, in __call__ return self.method(*args, **kw)

html - Can we include a stylesheet link with an API as href attribute? -

i dynamically add external css file. until here, ok. however, set href attribute url of api generate , return css file. is possible ? yes, long api serves document mime type text/css work. api needs send content-type: text/css response header along contents.

android - GoogleAnalytics custom dimension and metric values not updated -

i created custom dimension , metric , trying fill data android app. created new dashboard of table using custom dimension (user id declared @ user scope) , custom metric (bad attempts @ hit scope level), dashboard says there no values show. maybe i'm sending data in wrong way? this how it: public static enum customdimensions { user_id(1); private int value; customdimensions(int numval) { this.value = numval; } public int getvalue() { return value; } }; public static enum custommetrices { bad_attempts(1); private int value; custommetrices(int numval) { this.value = numval; } public int getvalue() { return value; } }; public static void sendcustomevent(activity act, customdimensions cd, string dimensionvalue, custommetrices cm, int metricvalue) { tracker tracker = getgoogleanalyticstracker(act); tracker.send(new hitbuilders.eventbuilder().setcustomdimension(

css - Stacking order of elements affected by opacity -

how z-index , opacity related when deciding stacking order of element in html? when keep opacity less 1 on element having z-index 999 . element going behind element having no z-index . $(function() { $("#checkbox1").on("change", function() { $("#green-parent").toggleclass("add-opacity", this.checked); }); }); .green, .blue { position: absolute; width: 100px; line-height: 100px; text-align: center; color: white; } .green { z-index: 999999999; top: 50px; left: 50px; background: green; } .blue { top: 60px; left: 90px; background: blue; } .add-opacity { opacity: 0.99; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <input id="checkbox1" type="checkbox" value="1"> <label for="checkbox1">add opacity green box parent</label> <div id="gre

encoding - how-to query mysql utf-8 table using ASCII -

i have created mysql 5.6 table column encoded in utf-8, characters in romanian, czech, hungarian, polish, french, german, scandinavian language(s) - i.e. european characters, quite non-ascii. however, query column using ascii characters - e.g. in clause- ă,î,â,ș,ț,ü,ä,ö etc. characters can (succesfully) queried using a,e,i,o,u,s,t etc. is possible ? there cheat sheet knowing letters map "equal" under collations in utf8 collations agrees Ł not mapped l collation. general_ci sorts after z ; utf8_unicode_520_ci sorts l ; rest sort before m . polish_ci treats Ę distinct rest of e -like characters. ditto Ą . baltic states tend keep accented consonants separate. in polish_ci , Ń (hex c584 ) collates after n , before o ; other collations treate equal n . utf8_unicode_520_ci best collation you. also, might consider "combining" accents -- 2 utf8 'characters' "combine" make single characters. utf8_unicode_ci collat

java - How to make BlockingQueue to accept multiple types? -

i have class x , class y , class z . if x or y perform specific conditions, should put blockingqueue . class z takes them queue. i know creating this: blockingqueue<x,y> bqueue=new arrayblockingqueue<x,y>(length); is illegal. how make properly? the simplest way allow blockingqueue accept object type: blockingqueue<object> q = new arrayblockingqueue<>(length); then, on take() operation, of particular class object is: object o = q.take(); if (o instanceof x) { x x = (x) o; // work x } else if (o instanceof y) { y y = (y) o; // work y } else { // o neither x nor y } if x , y inherited common class or implement common interface, make queue more specific: blockingqueue<xyinterface> q = new arrayblockingqueue<>(length);

javascript - HTML5 - resize image and keep EXIF in resized image -

how can resize image (using html5 canvas element) , keep exif information original image? can extract exif info from original image don't know how copy resized image. this how retrieve resized image data send server-side code: canvas.todataurl("image/jpeg", 0.7); for exif retrieval, i'm using exif.js library. working solution: exifrestorer.js usage html5 image resize: function datauritoblob(datauri) { var binary = atob(datauri.split(',')[1]); var array = []; for(var = 0; < binary.length; i++) { array.push(binary.charcodeat(i)); } return new blob([new uint8array(array)], {type: 'image/jpeg'}); } and main code, taken part of html5 resizer page: https://github.com/josefrichter/resize/blob/master/public/preprocess.js (but modified) var reader = new filereader(); //reader.readasarraybuffer(file); //load data ... old version reader.readasdataurl(file); //load data ... new version reader.onl

jquery - javascript get the value of checkbox if checked without button clicked -

javascript value of checkbox if checked without button clicked i struck in middle of project, please help.. how check box value class name or name or id through alert particular value can pass... i sorry ask..i new jquery , javascript.. this html ... <input type="checkbox" name='cbox' value="red" class="theclass"/>red <input type="checkbox" name='cbox' value="green" class="theclass"/>green <input type="checkbox" name='cbox' value="yer" class="theclass"/>yer <input type="checkbox" name='cbox' value="asdasd" class="theclass"/>asdasd <input type="checkbox" name='cbox' value="radgdfged" class="theclass"/>radgdfged $(function(){ $('input[type=checkbox]').on('change', function() { alert($(this).val()); console.log($(this).val()); }); });

c# - "async await " how to understand it -

the code : static void main(string[] args) { test(); console.writeline("main thread id :{0}", thread.currentthread.managedthreadid); console.read(); } static async void test() { console.writeline("before wait current thread id:{0}", thread.currentthread.managedthreadid); await getname(); console.writeline("after wait current thread id:{0}", thread.currentthread.managedthreadid); } static async task getname() { await task.run(() => { console.writeline("current thread id :{0}", thread.currentthread.managedthreadid); console.writeline("in antoher thread....."); }); } the result : before wait current thread id:9 current thread id :10 in antoher thread..... main thread id :9 after wait current thread id:10 or after wait current thread id:11 i dont kown why "main threa

image - Chromecast default receiver thumbnail size -

can tell me dimensions of thumbnail image rendered chromecast default receiver? can't find documented anywhere, , current images squashed. (i guess find out trial , error, if there's official answer i'd love have it.) cheers nic it in developer docs : note: video image art 96x143 pixels , first image resource associated media metadata selected display. images scaled fit expected dimensions

editor - vim - search current line equivalent to search current word -

is there equivalent search string in current line similar * or # search current word? no, it's easy make it. :nnoremap <silent> <leader>f :execute '/\v\^' . escape(getline('.'), '\\/') . '\$'<cr> this should give \f (or whatever remapped leader instead of backslash) should start search next instance of current line.

android - How can i open pdf from sdcard i can from asset folder -

i using pdf viewer library , able show pdf asset folder while trying sdcard showing progrss bar long time. i using below code showing asset assetmanager assetmanager = getassets(); inputstream in = null; outputstream out = null; file file = new file(getfilesdir(), "sample.pdf"); try { in = assetmanager.open("sample.pdf"); out = openfileoutput(file.getname(), context.mode_world_readable); copyfile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } catch (exception e) { log.e("tag", e.getmessage()); } intent intent = new intent(this, mypdfvieweractivity.class); intent.putextra(pdfvieweractivity.extra_pdffilename, getfilesdir() + "/sample.pdf"); startactivity(intent); } private void copyfile(inputstream in, outputstream out) throws ioexception { byte[] buffer = new byte[1024]; int read; whil

c# - Calling a method at the fastest possible interval (timers) -

i have method want run several thousands of times per second. i'm running @ rate of once every millisecond using dispatchertimer, interval property set 1ms. now, dispatchertimer isn't fastest, high-precision timer available , since tick event handler running on ui thread it's not going execute more that. code i'm calling doesn't need run on ui thread seems i'm limiting myself no real reason. what options if want higher frequency? should use system.threading.timer? there specific timer high-frequency, high-precision operations? should forego timers altogether , else? note although tried (but failed, due lack of reputation) tag windowsiot (because need run there , possibly new devices library has stuff this), applies .net applications in general well, wpf, winforms, winrt, etc... the underlying problem when yield cpu time, you're doing in os scheduling system. means operations thread.sleep , or indeed, waiting callback of system timer, limit

unit testing - Scala test cannot find any test to run -

i trying run test in scala play framework. here code have written package com.sentrana.mmcore.integrationtests import org.specs2.mutable._ import org.specs2.runner._ import org.junit.runner._ import play.api.test._ import play.api.test.helpers._ import play.api.libs.json._ class applicationspec extends specification tags { "application" should { "work" in new withapplication { route(fakerequest(get, "/boum")) must benone } } } this command using run test - test-only com.sentrana.mmcore.integrationtests.applicationspec i not getting error. showing me 0 tests have been. i hope have made question clear. if there confusion please ask. stuck months. please me. , in advance. if add test using intellijidea make sure file has .scala extension. ide not show errors activator cannot find test because searching scala files.

Regex in Notepad++ to move contents of an element to an attribute value -

i'm trying solve regex riddle. let's have rows of hrefs looking this: <a href="http://domain.com/5et46ffd5e3wr23">anchor1.in</a> <a href="http://domain.com/6utr4dghj6wfl">an3.php</a> <a href="http://domain.com/k543sk6k3f6hj">setup.exe</a> what want regex (or other solution) take href title , copy on actual url foward slash in front of it. a successful result become: <a href="http://domain.com/5et46ffd5e3wr23/anchor1.in">anchor1.in</a> <a href="http://domain.com/6utr4dghj6wfl/an3.php">an3.php</a> <a href="http://domain.com/k543sk6k3f6hj/setup.exe">setup.exe</a> if can solve please explain how did it. you can use following match: (<a\s+href=")(.*?)(">)(.*?)(<\/a>) and replace with: \1\2/\4\3\4\5 see demo , explanation

android - How to load array bitmap display in View Pager? -

i have array of bitmap in activity . want load array bitmap in viewpager . don't have nay idea concept. check link have change drawable bitmap.. here code.. step 1) after creating fresh project. change main.xml follow have 1 viewpager widget in it. <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <android.support.v4.view.viewpager android:id="@+id/myfivepanelpager" android:layout_width="match_parent" android:layout_height="match_parent" /> </linearlayout> step 2) our main concern bind data inside viewpager can swipe. pageradapter bind data viewpager , create view dynamically when needed. in pageradapter remove view use on can avoid memory wasta

ios - Get native size of iPhone (6, 6 Plus, 5 etc) even when only running in zoomed mode (iPhone 5 mode) -

an iphone 6 plus running in zoomed mode (ie not supporting iphone 6 plus native launch image) returns screen size of 320x568 points. i'd native point size @ runtime of current device. iphone 6 plus should 414x736 points. app must run in zoomed mode (iphone 5ish size). let's take again: create iphone app natively supporting iphone 5 (and 4...) launching app iphone 6 plus, @ uiscreen.mainscreen.bounds.size , 320x568. we want achieve native size of iphone 6 plus (once again, without adding launch image iphone 6 plus app). i'm stuck. there uiscreen.mainscreen.nativebounds.size , return size in pixels 834.78260869565224, 1481.7391304347827 . interesting numbers, if divide uiscreen.mainscreen.nativescale , 320x568. i hope asking how screen size. screen size can obtained cgsize screensize = [[[uiscreen mainscreen] bounds] size]; this return main screen size. sorry if mistaken.

ios - Posting photo on Facebook wall -

i trying post photo on facebook wall. using object graph api, not working successfully. if ([posttype isequal:@"photoalbum"]) { nsstring *imgstring=[nsstring stringwithformat:@"%@%@",imgurl,[jsonresponse valueforkey:@"imageurl"]]; nsurl *url = [nsurl urlwithstring:imgstring]; nsdata *data = [nsdata datawithcontentsofurl:url]; uiimage *image=[uiimage imagewithdata:data]; nsstring*postlink =[nsstring stringwithformat:@"%@",[jsonresponse valueforkey:@"postlink"]]; [dict setobject:posttitle forkey:@"message"]; [dict setobject:image forkey:@"image"]; [dict setobject:postlink forkey:@"postlink"]; [fbrequestconnection startwithgraphpath:@"me/photos" parameters:params httpmethod:@"post" completionhandler:^(fbrequestconnection *connection ,id result ,nserror *error){ if(!error){

php - read a part of variable $this -

i try debug function in magento, have big , complexe variable $this, inside find data need can't read search data in part named "html" $html=$this->*mage_core_block_abstract*_transportobject['_data["html"]']; the first problem * in name not reconized. in observers use: $transport = $observer->gettransport(); $html = $transport->gethtml(); this lead me believe modify 2 lines follows: $transport = $this->gettransport(); var_dump($transport); $html = $transport->gethtml(); then should able read whatever want.

java - How readonly entity get persisted for the first time -

if readonly entity cannot persisted , how persisted first time. thinking in matter lead me 3 choice persist of readonly entity: readonly entity included in 2 type of mapping @ not readyonly in 1 of type. readonly entity inserted database without use of jpa. legacy database what want know there other choice? first choice legal @ part of users/system can insert readyonly entity (configuration example) , major part of users read entity? is first choice legal @ part of users/system can insert readyonly entity (configuration example) , major part of users read entity? you can need in application, there no restriction on how many entities can map same table. have adjust cache usage account changes made in 1 entity not being shown or picked other entity caches until entities refreshed/reloaded.i.e.you need way cause other users see configuration changes. holds true different entities mapping same table data multiple instances of same jpa application though.

html - URLs with handlebars JS -

i'm trying use handlebars render url inside email html template sent user after registration confirmation step. the link assembled follows: var data = { user: { email: body.email, token: 'tmptoken', link: '/confirm?email=' + body.email + '&token=' + 'tmptoken' }, appname: 'xyz' }; the link used in following format: "/confirm?email=x&token=y" each time email sent, link tampered , becomes: "confirm/?email=y&token=y" , pretty annoying. i'm using handlebars in nodejs refer url inside html using handlebars <a href="{{{link_to}}}" style="border: 0;" target="_blank"> . i tried using handlebars helpers: handlebars.registerhelper('link_to', function() { return new handlebars.safestring(handlebars.utils.escapeexpression(data.user.l

python - django.core.exceptions.ImproperlyConfigured about setting TEMPLATES -

a question django.template here code: from django import template t = template.template('my name {{ name }}.') but when ran: traceback (most recent call last): file "f:/daima/qpython/123.py", line 2, in <module> t = template.template('my name {{ name }}.') file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\base.py", line 187, in __init__ engine = engine.get_default() file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\utils\lru_cache.py", line 125, in wrapper result = user_function(*args, **kwds) file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\engine.py", line 73, in get_default django_engines = [engine engine in engines.all() file "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\template\utils.py", line 108, in return [self[alias] alias in self] file "c:\python27\lib\s

ios - How can I found facebookSDK.framework on facebookSDK v4.0.1? -

so i've downloaded facebooksdk pkg, , installed on document folder. can't find facebooksdk.framework inside folder, need ios project. can find it? pretty sure framework after fbsdkcorekit.framework . if manually adding framework found in folder have installed in documents folder. includes ability see: - sharing - login facebook - app events - graph api calls information found on https://developers.facebook.com/docs/ios/getting-started

html - Python: Print list of unknown length? -

i'm trying use python print html file. is there way incorporate following print statement? perhaps using format method? current situation: foo = ['some_image1.com', 'some_image2.com'] print '''<img src="' + foo[0] + '"> <img src="' + foo[1] + '"> <img src="' + foo[2] + '">''' # desired behavior ignore foo[2] how can past this? should not use list? thank you! print ''.join(map('<img src="{}">'.format, foo)) or print '<img src="%s">' * len(foo) % tuple(foo) (if foo tuple, wouldn't need tuple(...) ). i wouldn't latter, though, except when code golfing (where did use this).

automation - C Programming - Accessing USB Data / Driver Specifics -

i writing simple test automation access usb port in ubuntu, , determine driver specific details, devices connected, , operating mode (usb 2 , 3 , etc ...). i have not done development in area, , looking advice on libraries / recommendations accomplish this. thank you help! dan. i've done using libusb. can get started here. http://libusb.sourceforge.net/api-1.0/ if you're looking @ seeing various usb devices, it's pretty easy. here examples can , running pretty quickly: http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/

python - Django ModelChoiceField to_field_name is not working -

i have following models , i'm trying use django modelform's modelchoicefield solve problem quickly class games(model): code = charfield() # gta, abc, etc.. name = charfield() # grand tourismo, bbb ccc , etc.. unique_together(code, name) class settings(model): gamecode = charfield(). #didn't use foreign key because of internal reasons can't use games model somewhere outside username = charfield() ... class gamecodechoicefield(modelchoicefield): def label_from_instance(self, obj): return obj.name class settingsform(forms.modelform): gamecode = gamecodechoicefield(queryset=none,required=false) class meta: model = settings fields = ['username'] def __init__(self, *args, **kwargs): super(settingsform, self).__init__(*args, **kwargs) self.fields['gamecode'].queryset = games.objects.filter(game=game, isactive=true) self.fields['gamecode'].to_field_name = '

angularjs - Padding offsets height with ng-hide CSS transition -

i have problem css transition of heights property when element has padding on it. .content { padding: 10px; border:1px solid black; overflow: hidden; -webkit-transition: linear 1s; transition: linear 1s; height: 16px; } .content.ng-hide-add { height: 16px; } .content.ng-hide-add.ng-hide-add-active { height: 0px; } .content.ng-hide-remove { height: 0px; } .content.ng-hide-remove.ng-hide-remove-active { height: 16px; } this plunker: http://plnkr.co/edit/pbyauht8w6zvzktr7etr?p=preview as can see, animation still covers 16px, offset total of 20px of padding. if change padding 0, animation works expected in plunker: http://plnkr.co/edit/50zfnnaoopx7hgl2tryi?p=preview i tried using box-sizing:border-box breaks animation. can me this? you can: 1) change padding-top in animation (text change position) .content.ng-hide-add.ng-hide-add-active { height: 0px; padding: 0px 10px;} .content.ng-hide-remove { height: 0px; padding: 0px 10px;} 2) put content conta