Posts

Showing posts from August, 2015

python - Error: list indices must be integers, not Series -

i have grabbed column pandas data frame , made list rows. if print first 2 values of list, output: print dflist[0] print dflist[1] 0 0.00 1 0.00 2 0.00 3 0.00 4 0.00 5 0.11 6 0.84 7 1.00 8 0.27 9 0.00 10 0.52 11 0.55 12 0.92 13 0.00 14 0.00 ... 50 0.42 51 0.00 52 0.00 53 0.00 54 0.40 55 0.65 56 0.81 57 1.00 58 0.54 59 0.21 60 0.00 61 0.33 62 1.00 63 0.75 64 1.00 name: 9, length: 65, dtype: float64 65 1.00 66 1.00 67 1.00 68 1.00 69 1.00 70 1.00 71 0.55 72 0.00 73 0.39 74 0.51 75 0.70 76 0.83 77 0.87 78 0.85 79 0.53 ... 126 0.83 127 0.83 128 0.83 129 0.71 130 0.26 131 0.11 132 0.00 133 0.00 134 0.50 135 1.00 136 1.00 137 0.59 138 0.59 139 0.59 140 1.00 name: 9, length: 76, dtype: float64 when try iterate on list loop, error message: for in dflist: print dflist[i] traceback (most recen

javascript - How to add a class to "li" element using role="alter" as triger -

i have wp website , use plugin called "contact form 7" create form. provide shortcodes had use html in order work client's website. the form uses aria , role="alter" display error messages when validation fails. need change design of boxes failed validate, cannot find way add class. here's html: <div class="browser_gecko form_wrapper wpcf7" id="wpcf7-f46-p47-o1" lang="en-us" dir="ltr"> <div class="screen-reader-response"></div> <form action="/form/#wpcf7-f46-p47-o1" method="post" class="wpcf7-form" novalidate="novalidate"> <div style="display: none;"> <input type="hidden" name="_wpcf7" value="46" /> <input type="hidden" name="_wpcf7_version" value="4.1.1" /> <input type="hidden&qu

javascript - two polyline side-by-side between a pair of markers leaflet -

how can have 2 or more polylines side-by-side between pair of markers in leaflet.js? here code, don't see happening: http://jsfiddle.net/abarik/q9bxl1z6/1/ // html <div id="map" style="height:500px;"></div> //example user location var userlocation = new l.latlng(35.974, -83.496); var map = l.map('map', {center: userlocation, zoom: 1, worldcopyjump: true, }); l.tilelayer('http://{s}.tile.cloudmade.com/bc9a493b41014caabb98f0471d759707/997/256/{z}/{x}/{y}.png', { maxzoom: 18, attribution: 'map data &copy; <a href="http://openstreetmap.org">openstreetmap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">cc-by-sa</a>, imagery © <a href="http://cloudmade.com">cloudmade</a>' }).addto(map); var marker = new l.circlemarker(userlocation, {radius:10, fillcolor:'red'}); map.addlayer(mar

sorting - Enumerate rows alphabetized in Oracle -

i wonder if possible in oracle replace row number (we can use row_number() example digit) alfabetical numbering let's like no | name | surname ================ | john | doe b | | doe c | jim | wonder instead of no | name | surname | ================= 1 | john | doe 2 | | doe 3 | jim | wonder i have idea create variable "abcdefg" , convert row number correct substr , sounds little unstable temporary solution a-z use chr((row_number() on (partition somecolumn order 1))+64) i created function converts number characters: create or replace function num_to_char(p_number in number) return varchar2 v_tmp number; v_result varchar2(4000) := ''; begin v_result := chr(mod(p_number - 1, 26) + 65); if p_number > 26 v_result := num_to_char(trunc((p_number-1)/26)) || v_result; end if; return v_result; end num_to_char; / you can use in selects: select num_to_char(row_number() on (partition dummy order 1)) dual connect

ruby - respond_to?() from top level of script -

i can use respond_to?() main object in irb : irb(main):001:0> def foo irb(main):002:1> "hi" irb(main):003:1> end => nil irb(main):004:0> respond_to?(:foo) => true irb(main):005:0> self => main but when put script, doesn't seem work i'd expect: $ cat test.rb #! /usr/local/bin/ruby def foo "hi" end puts respond_to?(:foo) puts self $ ./test.rb false main what's going on here? edit: the irb behavior works me in 1.9.3, not in 2.2.0. regardless, possible use respond_to?() such script? as alternative, can catch nomethoderror call send() , catch such exceptions inside valid method well, makes error handling little convoluted. methods defined @ top level made private methods of object , default respond_to? returns true public methods. check private , protected methods, set include_all argument true: def foo "hi" end puts respond_to?(:foo, true) puts self now when script run, respond_

linux - Which line the program running on with a backtrace info? -

there backtrace info: ======= backtrace: ========= /lib64/libc.so.6(+0x7bc07)[0x7f959bba4c07] /lib64/libc.so.6(+0x7d23a)[0x7f959bba623a] /lib64/libspice-server.so.1(+0x2108e)[0x7f959c8d508e] /lib64/libspice-server.so.1(+0x227a3)[0x7f959c8d67a3] /usr/libexec/qemu-kvm(qemu_iohandler_poll+0xc6)[0x7f95a10571e6] /usr/libexec/qemu-kvm(main_loop_wait+0x188)[0x7f95a105b748] /usr/libexec/qemu-kvm(main+0x1240)[0x7f95a0f7ce30] /lib64/libc.so.6(__libc_start_main+0xf5)[0x7f959bb4aaf5] /usr/libexec/qemu-kvm(+0xb2ced)[0x7f95a0f80ced] i create kvm instance spice, crashed , got message log. now, want know line did make crash. no link symbol table /lib64/libspice-server.so.1 . i can address offset +0x2108e . way find out line did crash? btw, tutorial debug library? thanks. any way find out line did crash? your libc.so.6 , libspice-server.so.1 (apparently) fully-stripped. you'll want install debuginfo packages both libraries, , use addr2line translate addresses sy

c# - Structuring TextFixtures in nUnit -

upon unit testing of class, there need test same methods different combination of data in class. can achieved writing several textfixtures , repeating same test methods each one, below. [textfixture] public class whenbuildinglongfoo { private foo foo; [setup] public void creating() { foo = new foo(){height = new fooheight(200)}; } [test] public void returnsvalidheight() { assert.areequal(200, foo.height); } } [textfixture] public class whenbuildingshortfoo { private foo foo; [setup] public void creating() { foo = new foo(){height=newfooheight(2); } [test] public void returnsvalidheight() { assert.areequal(2, foo.height); } } what best way structure such fixtures, method returnsvalidheight written once? i came creating public static class utilities in common namespace, has method; please advise better? something create abstract class such method , derive fixture

ios - Xcode FPS Debug Gauge always show 0 FPS -

i have game in xcode 6.1.1 using opengl es 3.0, targeting ipad air. when capture opengl es frame, fps number , shader program time show 0. i have enabled "gpu frame capture" option in project scheme. frame rendering called cadisplaylink in non-main thread. how can correct fps nubmer , program time? i came across similar issue. if implement uiviewcontroller setting eaglcontext layer xcode not display measurements except memory , cpu performance,instead of should use glkviewcontroller implementation. for example: replace below line @interface myrenderingview : uiviewcontroller <...>{...} with @interface myrenderingview : glkviewcontroller <...>{...} this makes difference. another way: use "xcode->opendevelopertool->instruments->gpu driver" run app, tool displays fps , other gpu information needed.

ruby on rails - how to display timestamp without timezone -

@object.updated_at.localtime displays "2015-04-20 14:39:27 -0700". don't want display -0700, there method strip out timezone display purposes? @object.updated_at.localtime.strftime '%y-%m-%d %h:%m:%s'

python - Fabric import bug: "fab task" vs. "from fabfile import task; task()" -

this has python's import mechanism, , using import inside function. using python 2.7.9 , fabric 1.10.0, create following 3 files: fabfile.py: from import another_hello def hello(): print 'hello, world' another_hello() another.py: def another_hello(): secret import text print 'hello, world!' print 'text: ' + text secret/__init__.py: (also create folder secret/ ) text = 'secret' now try fab hello . complains: file "/home/sergey/projects/bask/service/t/fabfile.py", line 4, in hello another_hello() file "/home/sergey/projects/bask/service/t/another.py", line 2, in another_hello secret import text importerror: no module named secret at same time, can start interpreter , type from fab import hello; hello() . works perfectly: in [2]: fabfile import hello; hello() hello, world hello, world! text: secret why difference? now, have found hack makes work. add import secret begi

Scheme code for fermat's Factorization -

i trying learn scheme implementing few algorithms. fermatfactor(n): // n should odd ← ceil(sqrt(n)) b2 ← a*a - n while b2 isn't square: ← + 1 // equivalently: b2 ← b2 + 2*a + 1 b2 ← a*a - n // ← + 1 endwhile return - sqrt(b2) // or + sqrt(b2) i trying implement above algorithm in scheme. stuck on while loop. appreciated. thanks rather using while loop, in scheme, use recursion. scheme has tail recursion, recursion performant looping constructs in other languages. specifically, in case, use called "named let", makes creating inline recursion easy. direct translation of above code scheme result in this: (define (fermat-factor n) (let* ((a (ceiling (sqrt n))) (b (- (* a) n))) (let loop () (cond ((not (integer? (sqrt b))) (set! (+ 1)) (set! b (- (* a) n)) (loop)))) (- (sqrt b)))) this isn't idiomatic, though, since uses mutation (the calls set

javascript - Implement jQuery slidedown effect -

i have jquery slide down animation, implement paste section bellow. content smaller device every button need have slide down element attached on him self. can 1 show me how can this. mine jquery slidedown code: $(".squere").click(function(){ $(".content").hide(800); $(".squere").removeclass("active"); $(this).addclass("active"); $(this).next(".content").slidedown(1000); }); mine content: <div id="squere" class='container hidden-lg hidden-md '> <div class="row"> <div class="col-sm-4 col-xs-4"> <img class="img-responsive img-circle homepagegriddefault" src="img/circle/home-all-icon-off.png"> </div> <div class="col-sm-4 col-xs-4"> <img class="img-respons

javascript - How to use RxJs with Socket.IO on event -

i want use rxjs inside of socket.on('sense',function(data){}); . stuck , confused few documentation available , lack of understanding rxjs. here problem. i have distsensor.js has function pingend() function pingend(x){ socket.emit("sense", dist); //pingend fired when interrupt generated. } inside app.js have io.on('connection', function (socket) { socket.on('sense', function (data) { //console.log('sense app4 called ' + data); }); }); the sense function gets lots of sensor data want filter using rxjs , don't know should next use rxjs here. pointers right docs or sample help. i think can use rx.observable.fromevent ( https://github.com/reactive-extensions/rxjs/blob/master/doc/api/core/operators/fromevent.md ). here's how did similar thing using bacon.js, has similar api: https://github.com/raimohanska/bacon-minsk-2015/blob/gh-pages/server.js#l13 so in bacon.js go like io.on('connection&#

python - Can't upload image in django use MEDIA_ROOT and MEDIA_URL -

hello want make upload image in admin django when use media_root , media url image can not upload. model.py class product(models.model): category = models.foreignkey('category') userprofile = models.foreignkey('userprofile') title = models.charfield(max_length=50) price = models.integerfield() image = models.imagefield(upload_to=settings.media_root) description = models.textfield() created_date = models.datetimefield(auto_now_add=true) def __str__(self): return self.title; setting.py media_root = '/static/images/upload/' media_url = '/upload/' view.py def home(request): posts = product.objects.filter(created_date__isnull=false) return render(request, 'kerajinan/product_list.html', { 'posts' : posts, 'categories' : category.objects.all(), }) and tamplate product.html <img src="

Differentiate between admin login and user login in php -

i new php, trying create login page form as <form action="welcome.php" method="post"> login: <input type="text" name="name"><br> password: <input type="password" name="password"><br> <input type="submit" value="login admin user"> <input type="submit" value="logins student"> i want differentiate,which submit button user clicked , direct him corresponding page i.e if click login user should forward adminlogin.php or vise versa. just add status column database status=1 , status=0 if status 1 found admin , status 0 found user.

How to replace % with html tag in PHP -

i have following code in php: $fullstring = "a %sample% word go %here%"; and want replace % html tag ( <span style='color:red'> , </span> ). want after replacing: $fullstring ="a <span style='color:red'>sample</span> word go <span style='color:red'>here</span>"; what should accomplish result using php function str_replace, preg_replace etc.? thanks. you do.... $string = "a %sample% word go %here%"; echo preg_replace('~%(.*?)%~', '<span style="color:red">$1</span>', $string); that says replace between first % , next occurring % sign spans. () groups inside percents $1. output: a <span style="color:red">sample</span> word go <span style="color:red">here</span>

javascript - Draw kml layer on google map from a text area -

i'd draw kml layer on google map javascript api having kml code copied in textarea, in page: http://display-kml.appspot.com/ all examples found in documentation load kml layer file; example . uses geoxml3 third party kml parser , third party library adds ability edit kml (which doesn't sound need). working fiddle code snippet: var geocoder; var map; function initialize() { map = new google.maps.map( document.getelementbyid("map_canvas"), { center: new google.maps.latlng(37.4419, -122.1419), zoom: 13, maptypeid: google.maps.maptypeid.roadmap }); document.getelementbyid("kmlstring").value = '<kml><document><placemark id="tester"><styleurl>#transyellowpolyactive</styleurl><name>tester</name><polygon><outerboundaryis><linearring><tessellate>0</tessellate><coordinates>6.30889892578125,53.28820543193896 6.2

php - CakePHP 2.4 ignoring view -

i can't figure out @ moment why view not being displayed. controller: (/app/controller/eventscontroller.php) <?php class eventscontroller extends appcontroller { public $helpers = array('html', 'form'); function index() { $data = $this->event->find('all'); $this->set('data', $data); } } ?> view: (/app/view/events/index.ctp) <?php echo "<table border='1'>"; for($i=0; $i<count($data); $i++) { echo "<tr>"; echo "<td>" . $data[$i]['event']['id'] . "</td>"; echo "<td>" . $data[$i]['event']['start'] . "</td>"; echo "<tr>"; } echo "<table>"; //die; ?> however, if uncomment die; in last line content appears. it's not it's being skipped, it's more being ignored afterwards. not sure

sql - Implicit conversion between int and varchar -

below query show conversion error. select 'a' union select 1 to execute have explicitly convert it.. is there other way implicit conversion? may can convert integer varchar explicitily.but in implicit can convert alphabets convert using ascii values select ascii('a') union select 1 or select 'a' union select cast(1 varchar)

sqlite - How to use multiple databases like multiple languages in android -

i have 2 database support 2 languages application. i want change database when change language settings. is possible?? how can this? using ridcully solution, need add database name part, need add class extend. this example library mentioned: public class mydatabase extends sqliteassethelper { private static final int database_version = 1; public mydatabase(context context) { // here comes magic: string dbname = context.getstring(r.string.db_name); super(context, dbname , null, database_version); } } the other database class can be: public class mydatabase2 extends sqliteassethelper { private static final int database_version = 1; public mydatabase(context context) { // here comes magic: string dbname = context.getstring(r.string.db_name_2); super(context, dbname , null, database_version); } } note: use sqliteassethelper, u need create database yourself, , put in assets/databases f

c# - RegisterType with EventAggregator and ViewModel -

i not understand how register ieventaggregator instance can inject viewmodel . example: i define mainviewmodel : ... private ieventaggregator _eventaggregator; public mainviewmodel(ieventaggregator eventaggregator) { _eventaggregator = eventaggregator; ... } ... then, need somehow register class implements ieventaggregator want inject in viewmodel . in moduleinit class, have this: ... private iunitycontainer _container; public moduleinit(iunitycontainer _container) { _container = container; } ... public void initialize() { container.registertype<ieventaggregator, ___(something)___>(); ... } in mainviewmodel class, can implement _eventaggregator = servicelocator,current.getinstance<ieventaggregator>(); , don't understand conceptually i'm doing. program works... i understand servicelocator doing, , should doing appropriately register type container. don't define class implements ieventaggregator , servicelocator getting

php - Generating a random number not working on live server -

this has baffled me several hours now. below code in question. works totally fine on local server when migrated live server, problem i'm seeing random number generated , stored int type (the same on local) isn't random @ all. of entries have exact same number (2147483647). i don't know why works locally won't on live server. it's exact version of php. i've researched few hours , can't find thing. i'm sure simple oversight , figured posting here, 1 of brilliant minded developers point out? if($_server['request_method'] == 'post' && !empty($_post['submit'])) { date_default_timezone_set("america/new_york"); $first_name = ucwords(addslashes(strip_tags($_post['firstname']))); $last_name = ucwords(addslashes(strip_tags($_post['lastname']))); $age = addslashes(strip_tags($_post['age'])); $location = addslashes(strip_tags($_post['state'])); $description = addslashes(strip_tags($

jquery - setInterval and setTimeout stop togather on hover -

i have made radius progress bar on setinterval changing background-image. have pause interval circle text on highlighted on hover of circle. demo jsbin demo js code $(function(){ var timer = null; function startsetinterval() { var index = 0; var index2 = 0; var length = $("#opacityslider").children('div.fadebuy').length; var length2 = $(".rounder").children('div.rouline').length; function delaynext() { settimeout(function() { $("#opacityslider div.fadebuy:eq(" + index + ")").addclass("rollfade").siblings().removeclass("rollfade"); index++; if (index === length) index = 0; delaynext(); }, 7000); } function delaynext2() { settimeout(function() { $(".rounder div.rouline:eq(" + index2 + ")").addclass("drawlinecir").siblings().removeclass(&qu

php - Creating named session array from mysql fetch array -

i have database table called translations. has several columns, trying create session array house variale:translations named array. i've tried below code, must missing something... end goal populate of static verbiage of website using $_session['translations']['userboards'] example populate names of otherwise static content language supported based on database. $querylang = "select variable,translation translations left outer join languages on languages.abbrev = translations.fkabbrev languages.abbrev = 'en'"; $sqllang = mysql_query($querylang); while($reslang = mysql_fetch_array($sqllang)){ $_session['translations'][$reslang['variable']] = $reslang['translation']; }; the above code correct. reason didn't work separate issue. @epodax reminding me check errorlog!

c# - Different results in same elements that get text value from classes -

in site defined dictionary returns persian or english strings depending on session. here code dictionary: public static string find_term(string term) { var dictionary = new dictionary<string, string>(); dictionary.add("accommodation barges", "بارج اقامتی"); dictionary.add("bulk carriers", "فله بر"); dictionary.add("barge", "بارج"); dictionary.add("cable layers", "کابل گذار"); dictionary.add("cargo ships", "باربری"); dictionary.add("container ships", "کانتینر بر"); dictionary.add("crew boats", "پرسنل بر"); dictionary.add("cruise ships", "کروز"); dictionary.add("dive boats", "قایق قواصی"); dictionary.add("drilling rigs", "سکوی حفاری"); dictionary.add("fishing boat", "ماهیگیری"); dictionary.add("ferrie

PuTTY, Xming: Wrong encoding when open browser in lunux terminal -

Image
i use putty create ssh connection , want open firefox browser in terminal. download linux version firefox , xming . after that, go putty configuration , set enable x11 forwarding, run xlaunch. follow instructions here . then login terminal , run firefox. go right except cannot correct encoding in firefox. can solve problem? try : yum install dejavu-lgc-sans-fonts

ios - Can't add dictionaries with nil values to array in swift -

i trying create dictionary here: var dicitem = ["dataofchange": 21-01-2012, "item": nil, "orderer": nil, "song": 1, "itemid": 3447, "petro": nil] i create dicitem in loop , in loop when create dicitem want add array: array.append(serstatdicitemusjson) array: var data = [[string:anyobject]]() but getting following error when try add array: fatal error: attempt bridge implicitly unwrapped optional containing nil i think becouse of nil's can't figure how solve it. the item in dictionary needs object . nil not object, , that's why got error. there couple of solutions: use if statement check if value nil . add key/value pair dictionary when value not nil . use nsnull , object, instead of nil . write function converting nil empty string ("") , , calling function every time want add dictionary.

python - Django - how to override form template tag in html -

i working on project not in english language. have encountered little problem during registration. in registration html have : ... <form action="" style="text-align: center" method="post">{% csrf_token %} <ul style = "text-align: left"> {{user_form.as_p}} </ul> <input type="submit" value="užsiregistruoti" onclick="validateform()"/> </form> ... and text default in english. {{user_form.as_p}} takes values forms.py: ... fields = ('username', 'password1', 'password2') ... is there way leave forms values unchanged, , rewrite html part in own language? how do that? cant take generated parts of html , translate it, wont work way. you can use verbose_name in model this: field = models.charfield(max_length=200, verbose_name="your_language_here") more info see here if form didn't come 'model , can use label` instead this:

mongodb - Not finding documents using golang's mgo with partial attributes -

i'm trying remove bunch of documents have common attribute. document looks like: { _id : { attr1 : 'foo', attr2 : 'bar' }, attr3 : 'baz', } more 1 document have same 'foo' value in attr1 entry. i'm trying remove of those. i've got similar this: type docid struct { attr1 string `bson:"attr1,omitempty"` attr2 string `bson:"attr2,omitempty"` } type doc struct { id docid `bson:"_id,omitempty"` attr3 string `bson:"attr3,omitempty"` } doc := doc{ id : docid{ attr1 : 'foo' }, } collection := session.db("db").c("collection") collection.remove(doc) the problem here i'm getting not found error in remove call. can see odd in code? thanks lot! this consequence of way mongodb handles exact match , partial match. can demonstrated using mongo shell: # here documents > db.docs.find() { "_id" : { &q

eclipse - How can I customize partstack header in rcp application -

i trying customize partstack header of view in rcp application. goal customize coloring of header , add date , time , hide minimize , maximize buttons. buttons can hidden using css other goals give me hard time. @ moment looking use custom renderer overriding methods in stackrenderer class. right approach or there renderer shoud use? if don't want min/max buttons not include minmaxaddon in add on list in application.e4xmi. using custom renderer stackrenderer useful changing text of part tabs items. if want put text elsewhere on part stack line need @ minmaxaddon see how that.

php - Function always returns same value -

i created function in php searches [profile|title] , creates url profile... function profiletageplorer($message, $url) { $startlinktag = '<a href="' . $url .'">'; $endtag = '</a>'; $res = preg_replace('#(\[profile\|)([a-za-z0-9áčďéěíňóřšťůúýžÁČĎÉĚÍŇÓŘŠŤŮÚÝŽ\s]*)(\])#', $startlinktag . '$2' . $endtag, $message); return $res; } above in code have following cycle... foreach ($owners $owner) { // prepare header $ep = new emailprinter(); $ep->setreceiver($owner->email); $ep->setsubject($title); // message $message = profiletageplorer($message, $owner->url); $ep->settext($message); $res = $ep->sendmail(); } i've checked $owner->url contains unique url each iteration. profiletageplorer function returns same result in every iteration, no matter parameter changing. this same value equal url first iteration of cycle.

python - Scapy - insert packet layer between two other layers -

i doing little networking project using scapy library python. project involves sniffing in packets, , shimming new layer between layers 3 , 4. using guide, http://www.secdev.org/projects/scapy/doc/build_dissect.html i able create new packet layer. can add layer on top of existing packet doing like, packet = newlayer()/packet and newlayer() layer placed below ip layer. want, however, sandwich new layer between layers 3 , 4 (instead of below ip). can't seem figure out easy way accomplish this. i know can create new packet , like, packet = ether()/ip()/newlayer()/tcp() however since, want insert layer packets i've sniffed, i'd modify original packet instead of creating new packet scratch. any appreciated! here's example shows how inject dot1q() header between layer 1 , layer 2 (counting ether() layer 0): >>> pkt = ether() / dot1q() / ip() / tcp() >>> payload = pkt.getlayer(1).payload >>> payload <ip frag=0 pro

javascript - Grunt: issue with line endings -

i'm working on mean-stack project, , i'm 1 in team using windows (changing unix not option in case). i have problem windows's crlf line endings. every time run grunt serve, generates few files (index.html , .scss) our project. after make changes code, need commit changes git. the problem that, have unix lf line endings in every other file have edited except ones grunt has generated. how can change grunt generate files unix lf line endings in windows environment instead of crlf?

javascript - How to scroll to top before going to a different page, when a user clicks a link? -

i'm trying create smooth page transitions on website, user doesn't feel "page load" when he/she clicks link different page. 2 examples of want minimalissimo.com , defringe.com . when click link different article on page of these sites, page animates scroll top before next page starts loading. so far have following code: jquery(document).ready(function($){ $back_to_top = $('.link-to-article'); $back_to_top.on('click', function(){ $("html, body").animate({scrolltop:0},260); }); }); the above code doesn't work, no scroll occurs when click link class; however, if use prevent default page scroll top of course next page doesn't open link disabled preventdefault. please let me know if can help. thank you. you correct need use preventdefault , need manually redirect once animation complete: $back_to_top.on('click', function(){ var href = $(this).attr('href'); $(document.body).animate(

c - Is HINSTANCE valid across threads? -

in single .exe application winmain entry point has hinstance parameter should pseudo-handle (because equivalent getmodulehandle(null) returns pseudo-handle, according msdn). suppose it's pseudo because there both special values (such null mean entry-point module) , constants used return error (anything less 32). msdn explicitly describes pointer (nowadays equivalent hmodule ) module base address; know may have different meaning 16 bit applications in 32/64 bits world each process has own address space exact value useless, same each instance , absolutely meaningless outside process. all these said, first question : can (formally, despite msdn seems contradictory) assume hinstance pointer (even if don't see use this) or it's better assume it's (pseudo) handle (where value opaque )? let's assume it's value opaque, second question : value valid per-process or per-thread? we may think process handle valid per-process few (corner) cases make me th

Datepicker - disabled foreground color Windows Phone 8.1 RT -

how set foreground of datepicker disabled state? i have try set style res: <solidcolorbrush x:key="datepickerforegroundthemebrush" color="#444444" /> and: dpdate.isenabled = false; dpdate.foreground = new solidcolorbrush(colors.black); but still transparent. you need modify template of datepicker control in order change it's behavior when in disabled visual state; actually, there button inside datepicker , need change behavior of button. in designer, right click on datepicker , select edit template -> edit copy -> ok. designer has generated style control. perform step 1 again generate style button inside date picker. go xaml view. there 2 style elements under page.resources element: buttonstyle1 , datepickerstyle1. find , comment following part: xaml: <visualstate x:name="disabled"> <storyboard> <objectanimationusingkeyframes storyboard.targetproperty="foreground"

reactive programming - RxJava cache intermediate results -

i'm developing android client kaltura video platform, , develop uploading video. feature consists of following steps: create mediaentry params: name, description create uploadtoken params: filename , mediaentryid (which received @ step 1 ) addcontent - in other words bind mediaentry uploadtoken params: mediaentryid (which received @ step 1 ), uploadtokenid (which received @ step 2 ) uploadvideo params: uploadtokenid (which received @ step 2 ), videodata here code using rxjava: api.createmediaentry(name, description) .flatmap(mediaentry -> { mediaentryid = mediaentry.getid(); return api.createuploadtoken(this.videouri.getpath(), mediaentry.getid()); }) .flatmap(uploadtoken -> { uploadtokenid = uploadtoken.getid(); return api.addcontent(mediaentryid, uploadtoken.getid());

utf 8 - split utf-8 string into bytes in python -

i trying split utf-8 string bytes in python 3. problem is, when use bytearray, byte, encode etc functions array size of element 14 bytes, not 1 byte expected. need split text file sequence of bytes , send them byte after byte using sockets. tried this: infile = open (file, "r") str = infile.read() byte_str = bytes(str, 'utf-8') print("size of byte_str",sys.getsizeof(byte_str[0])) print gives me 14, need 1... suggestion? quoting official documentation : sys.getsizeof(object[, default]) return size of object in bytes. object can type of object. built-in objects return correct results, not have hold true third-party extensions implementation specific. only memory consumption directly attributed object accounted for, not memory consumption of objects refers to. if given, default returned if object not provide means retrieve size. otherwise typeerror raised. getsizeof() calls object’s __sizeof__ method , adds

Jquery, menu item highlighted too early on scroll -

i have page 2 divs. first 1 contains list of items, second 1 contains 1 section each item of list. when scrolling down second div, i'd correct li highlighted when corresponding section "active". problem hightlighted before reaching correct section. here's codepen made. , here's jquery function use: $('#event-details .content').on('scroll', function() { $('.event-title').each(function() { if($('#event-details .content').scrolltop() >= $(this).offset().top) { var id = $(this).attr('id'); console.log(id); $('.event-title').removeclass('active'); $('#' + id).addclass('active'); } }); }); i guess problem on conditions can't solve it. idea that? thank you! by comments the first li highlighted. that's because return 1 scrolltop greater first section offset. check section ends. top offset plus heigh

linux - UDP-Broadcast on all interfaces -

on linux system wired , wireless interface (e.g. 192.168.1.x , 192.168.2.x subnets) want send udp broadcast goes out via available interfaces (i.e. both through wired , wireless interface). currently sendto() inaddr_broadcast, seems broadcast sent through 1 of interfaces (not same , subsequent broadcasts may use other interface). is there way can send udp broadcast goes out through every single interface? first of all, should consider broadcast obsolete, specially inaddr_broadcast (255.255.255.255). question highlights 1 of reasons broadcast unsuitable. should die along ipv4 (hopefully). note ipv6 doesn't have concept of broadcast (multicast used, instead). inaddr_broadcast limited local link. nowadays, it's visible use dhcp auto-configuration, since @ such time, client not know yet in network connected to. with single sendto() , single packet generated, , outgoing interface determined operating system's routing table ( ip route on linux). can't

javascript - How to let DOM elements stack and overflow horizontally instead of vertically in HTML? -

do need container wide , set elements inline display or float or something? if have 2 rows, each taking 50% height? what if number of elements undetermined? how determine container width? it seems hard div. have use table? also, seems hard in pure css, it's confusing , hard control relative width , height @ same time. have use js? what easiest , elegant way of doing this? sounds want use css attribute: flexbox with flex box, can define max , min width , height , max/min number of elements before fall onto new line. the beauty of is, let browser calculate widths, define max, min, margins , padding. and css, no javascript required take @ examples @ css tricks , have play it. link relatively old of vendor prefixes may not needed more. hope helps! edit: additional info on flex attribute can found @ mozilla

c# - NServiceBus not creating RabbitMQ queues -

i have problem nservicebus not automatically create queues. if run of endpoints (excluding mvc web client) following error. (the endpoints have been generated using servicematrix) 2015-04-23 10:50:12.241 error nservicebus endpoint unable contact servicecontrol backend report endpoint information. have servicecont rol plugins installed in endpoint. however, please ensure particul ar servicecontrol service installed on machine, or if running servicecon trol on different machine, ensure endpoint's app.config / web.c onfig, appsettings has following key set appropriately: servicecontrol/queue . example: additional details: {0} nservicebus.unicast.queuing.queuenotfoundexception: exchange recipient d oes not exist ---> rabbitmq.client.exceptions.alreadyclosedexception: cl osed: amqp operation interrupted: amqp close-reason, initiated peer, code=404, text="not_found - no exchange 'particular.servicecontrol' in vhost '/' "

looping nested lists in R -

i have huge nested list of 15 levels. need replace empty lists occurring @ level chr "". tried lapply loop through list it's not working. there easy way this? nested_list<-list(a=list(x=list(),y=list(i=list(),j=list(p=list(),q=list()))),b=list()) lapply(nested_list,function(x) if(length(x)==0) "" else x) the lapply being applied first level, how recursively loop entire nested list , perform action? try following recursion. foo <- function(l){ lapply(l, function(x) if(length(x)==0) "" else foo(x)) } foo(nested_list) edit : better version foo <- function(l){ lapply(l, function(x) if(is.list(x) && length(x)==0) "" else if(is.list(x)) foo(x) else x) }

php - Disable Cash on Delivery for specific products -

i have website name shopeling.com running on magento v1.9.0.1. want disable cash on delivery specific products. have installed cod extension magento commerce. please me code can above mention solution problem. also, have search every on internet no 1 has ever provided code magento v1.9.0.1. please not provide me other links. create custom attribute attribute code cod , assign general of attribute sets. now per requirement change methods.phtml (if there no custom code included in this) follows. <?php $methods = $this->getmethods(); $onemethod = count($methods) <= 1; ?> <?php if (empty($methods)): ?> <dt> <?php echo $this->__('no payment methods') ?> </dt> <?php else: foreach ($methods $_method): $_code = $_method->getcode(); ?> <dt> <?php //cod verification starts $attr_cod = array(); $cartitems = mage::getsingleton('checkout/session')

ios - UISearchBar and UISearchDisplayController background color -

Image
i've added uisearchbar navigation bar it's visible when user taps button. also, i've linked programmatically uisearchdisplaycontroller . background color search bar transparent. my problem when black semi-transparent overlay it's tapped , uisearchdisplaycontroller becomes inactive, see ugly search bar animation: stretches full size (not showing cancel button anymore) , applying kind o grey background. when user taps cancel button in order uisearchdisplaycontroller become inactive it's fine. does have solution problem? thanks. you can make custom background images: [searchbar setbackgroundimage:[uiimage imagenamed:@"searchbarbackground"]]; [searchbar setscopebarbackgroundimage:[uiimage imagenamed:@"searchbarbackground"]]; [searchbar setsearchfieldbackgroundimage:[uiimage imagenamed:@"searchfieldbackgroundimage"] forstate:uicontrolstatenormal]; searchbarbackground setsearchfieldbackgroundimage - transparent

javascript - How to display json data in a div when json data is in array -

"data": [ { "name": "rehan", "location": "pune", "description": "hello hi", "created_by": 13692, "users_name": "xyz", }, { "name": "sameer", "location": "bangalore", "description": "how you", "created_by": 13543, "users_name": "abc", }, the api contain more 100 data, how can display these data in html page. this: name: rehan location: pune description: hello hi created by: 13692 user name: xyz how this? var data = [ { "name": "rehan", "location": "pune", "description": "hello hi", "created_by": 13692, "users_nam

python - CLEM Forecast Script in SPSS Modeler -

i'm struggling forecast script found in modeler cookbook, should easy solve away long ago did type of thing. error message: expected number in range '1' '0' found '1' the script determine number of rows forecast , read in local variable (num_recs) , iterate score neuralnet model, after each succesful scoring runs new row scored. result 7 day forcast. here script piece. appreciate if take @ asap, due short timeframe(that tomorrow, friday), appriated. var num_recs var idx execute rec_count_table > # count number of records forecast set num_recs = value rec_count_table.output @ 1 1 clear outputs idx 1 num_recs > # generate forecast 1 record @ time execute forecast_data_overwrite end i ran same issue. changed select_forecast_recs node 'power demand' = '$null$' vs. @null('power demand') . hope helps because @null('power demand') code did not work me. dale.