Posts

Showing posts from March, 2011

javascript - FizzBuzz textContent issue -

i'm using old fizzbuzz exercise, , utilizing textcontent, trying load page each of values listed 1 after other, vertically. right i'm getting instead: 12fizz4buzzfizz78fizzbuzz11fizz1314fizzbuzz1617fizz19buzzfizz2223fizzbuzz26fizz2829fizzbuzz3132fizz34buzzfizz3738fizzbuzz41fizz4344fizzbuzz4647fizz49buzzfizz5253fizzbuzz56fizz5859fizzbuzz6162fizz64buzzfizz6768fizzbuzz71fizz7374fizzbuzz7677fizz79buzzfizz8283fizzbuzz86fizz8889fizzbuzz9192fizz94buzzfizz9798fizzbuzz here code: var n = 1, str = "" while (n <= 100) { if (n % 3 === 0 && n % 5 === 0) { str = str + "fizzbuzz" } else if (n % 3 === 0) { str = str + "fizz" } else if (n % 5 === 0) { str = str + "buzz" } else { str = str + n } n++ } document.queryselector(".container").textcontent = str <!doctype html> <html> <head> </head> <body> <p class="container"...

multithreading - Should implementations of java.util.Comparator.compare(T o1, T o2) be thread safe? -

or should care when used in parallel implementations java.util.arrays.parallelsort(t[] a, comparator<? super t> cmp) ? the comparison method nature pure function evaluated against objects may considered immutable @ least during sorting operation. mutating objects during sorting break essential assumption of sorting algorithm, order imposed comparator stable throughout operation. the above implies that, although comparator must thread-safe when used in parallel sort, given no special effort. on flip side, need make sure doesn't contain thread-unsafe code 1 reason or another, such using thread-unsafe collaborator instance shared across invocations of compare() .

Bukkit Java NullPointer when checking if something is null -

i using bukkit api 1.8.3 i have piece of code: for(string vey : main.getconfig().getconfigurationsection("shopitems."+key+".enchantments").getkeys(false)) { enchantment ench = enchantment.getbyname(vey); int level = main.getconfig().getint("shopitems."+key+".enchantments."+vey); meta.addenchant(ench, level, true); } this piece of code gives me nullpointer pointing line starts for-loop iteration. to try fix have null checker: if(main.getconfig().getconfigurationsection("shopitems."+key+".enchantments").getkeys(false)!=null) after null checker put code above inside if statement. however getting nullpointer on line testing if path null my question: why not working , how can fix it note: main.getconfig() returns fileconfiguration not null have tested debugged this if(main.getconfig().getconfigurationsection("shopitems."+key+".enchantments").getkeys(false)!=null) is ...

linker - Mac OSX ld report 32-bit RIP relative reference out of range error for Absolute symbol -

i'm trying combine objcopy clang toolchain. because objcopy of binutils 2.25 generates broken mach-o object file, edit generated object file using my shell script . $ objcopy-comp.sh -i binary -o mach-o-x86-64 test test.o $ nm test.o 000000000000000b d _binary_test_end 000000000000000b _binary_test_size 0000000000000000 d _binary_test_start however, link against c code fails error message. $ clang main.c test.o ld: 32-bit rip relative reference out of range (-4294971146 max +/-4gb): _main (0x100000ea0) _binary_test_size (0x0000000b) in '_main' main.o architecture x86_64 (newlines inserted readbility) here main.c. #include <stdio.h> #include <stdlib.h> #include <string.h> extern const unsigned char binary_test_start[]; extern const unsigned char binary_test_end[]; extern const unsigned char binary_test_size[]; int main(int argc, char *argv[]) { size_t len = binary_test_end - binary_test_start; char *data = calloc(len + 1, sizeo...

ios - Is there a way to verify if an email address is a valid Paypal email -

i'd verify email entered user if valid paypal email or not without taking customer paypal screen. want code , on backend if possible. i found some information related need don't know how use it. the information have found correct way verify paypal account. getverifiedstatus 1 of api of adaptive accounts. please refer link below details of adaptive accounts. https://developer.paypal.com/webapps/developer/docs/classic/adaptive-accounts/gs_adaptiveaccounts/ to use getverifiedstatus api, need go site below apply app id should used when call adaptive accounts apis. https://www.paypal-apps.com/user/my-account/applications go site above, login , click "new app", fill in form base on needs. make sure check "get verified status" checkbox under "adaptive accounts". after applied it, app review team review application, if update, leave message on site.

java - Count the correct score -

i given assignment asks questions , calculate total score @ end. here code. tia scanner userinput = new scanner(system.in); int useranswer; system.out.print("q1.) main character in legend of zelda?\n" + "1.) link\n2.) princess zelda\n3.)super mario" + "\nanswer: "); useranswer = userinput.nextint(); if (useranswer == 1){ system.out.print("that correct! "); } else { system.out.print("i'm sorry wrong."); } system.out.print("\nq2.) main character in naruto?\n" + "1.) sasuke\n2.) naruto\n3.) sakura" + "\nanswer: "); useranswer = userinput.nextint(); if (useranswer == 2){ system.out.print("that correct! "); } else { system.out.print("i'm sorry wrong."); } system.out.print("q3.) main character in dragon balls??\n" + ...

Grails 3.0 / IntelliJ 14.1.4 creating controllers, services, domain classes not working -

when try create grails domain class, controller (anything, really) using intellij 14.1.4 results in failures gradle commands intellij calling, instance: 9:29:45 am: executing external task 'grails-create-domain-class -pgrailsargs="koos --non-interactive -plain-output"'... failure: build failed exception. * went wrong: task 'grails-create-domain-class' not found in root project 'koos'. * try: run gradle tasks list of available tasks. run --stacktrace option stack trace. run --info or --debug option more log output. build failed total time: 1.326 secs task 'grails-create-domain-class' not found in root project 'koos'. 9:29:47 am: external task execution finished 'grails-create-domain-class -pgrailsargs="koos --non-interactive -plain-output"'. the gradle project pulled in, grails view active on project. is intellij bug? doing wrong? if call directly on cli fails. these steps reproduce error: install grai...

python - Converting Text to CSV -

i have product reviews text file want convert csv data analysis. below part of how text file looks like: id: 1 asin: 0827229534 title: patterns of preaching: sermon sampler group: book salesrank: 396585 similar: 5 0804215715 156101074x 0687023955 0687074231 082721619x categories: 2 |books[283155]|subjects[1000]|religion & spirituality[22]|christianity[12290]|clergy[12360]|preaching[12368] |books[283155]|subjects[1000]|religion & spirituality[22]|christianity[12290]|clergy[12360]|sermons[12370] reviews: total: 2 downloaded: 2 avg rating: 5 2000-7-28 cutomer: a2jw67oy8u6hhk rating: 5 votes: 10 helpful: 9 2003-12-14 cutomer: a2ve83mzf98ity rating: 5 votes: 6 helpful: 5 id: 2 asin: 0738700797 title: candlemas: feast of flames group: book salesrank: 168596 similar: 5 0738700827 1567184960 1567182836 0738700525 0738700940 categories: 2 |books[283155]|subjects[1000]|religion & spirituality[22]|earth-based...

javascript - How do i render a html file in grails that has source files included in the html? -

i have project in grails i'm doing ui part in separate grails independent project. i'm calling html file in ui project grails controller in different project. how render html files controller? currently, i'm using render command convert htmlcontent text format , rendering text. released cant include relative source tags inside html , i'll need hardcode in html. render text: htmlcontent, contenttype:"text/html", encoding:"utf-8" any other effective way render html (from different project) grails controller? the following problem understand it: you have grails project containing controller. you have grails plugin project containing ui (html, css, etc). the controller project configured in grails-app/conf/build.groovy depend on ui plugin. you want render ui in ui plugin project controller in controller project. views rendered same way regardless of whether contained in same project or not. example, if ui project has vie...

android - Control the smartwatch via bluetooth -

i doing feasibility research project , not expert. control smartwatch via bluetooth low energy (ble) device not smartwatch. nothing fancy, no app running difficult tasks, no login/security, no external db, controlling like: turning screen on, swiping , forth, selecting , using basic functionalities embedded in every smartwatch let’s default (e.g. email, phone calls, sms, play music), , turning screen off. basically, instead of interacting smartwatch via touchscreen, want interact smartwatch via ble. instead of using smartwatch’s touchscreen source of inputs, want use device source of inputs. targeted os android (but other useful know!). 1) there smartwatch allows developing such functionalities in smartwatch itself, without developing in smartphone (i.e. deploy apis in smartwatch handle ble module , implement tasks above mentioned)? can pair smartwatch multiple devices not smartphones? know pebble time highly developable , solution 1 can (or able be) implemented, curious if th...

swift - defaultTracker is nil in Google Analytics for IOS -

i'm trying set google analytics in ios app following guide google analytics ios have completed steps when run app crashes , says defaulttracker nil. following code in viewcontroller: override func viewwillappear(animated: bool) { super.viewwillappear(animated) var tracker = gai.sharedinstance().defaulttracker tracker.set(kgaiscreenname, value: nil) var builder = gaidictionarybuilder.createscreenview() tracker.send(builder.build() [nsobject : anyobject]) } in appdelegate have code should initialize regarding tracker: func applicationdidfinishlaunching(application: uiapplication) { // configure tracker googleservice-info.plist. var configureerror:nserror? gglcontext.sharedinstance().configurewitherror(&configureerror) assert(configureerror == nil, "error configuring google services: \(configureerror)") // optional: configure gai options. var gai = gai.sharedinstance() gai.trackuncaughtexceptions = true // re...

android - How to avoid an activity to be paused when a transparent activity is created -

i have 1 activity keeps refreshing elements on based on responses our server, , created activity overlays 1st activity information need collect user if wants, when pop 2nd activity transparent , shows in background, objects getting refreshed stopped moving because activity went pause mode. still can see content on activity behind nothing moving anymore. how can 2nd activity working transparency , still able see content of background activity running? you don't. activity paused whenever no longer foreground activity- whenever activity launched on top of it. transparency doesn't matter. if don't want paused, don't make new functionality activity- make dialog, fragment, or overlay of sort.

jsp - Extending views in spring 4 -

i want create view file extends layout.jsp. used jstl , tags folder, layout /web-inf/tags/ looks this: <%@tag description="main layout" pageencoding="utf-8" %> <%@attribute name="head" fragment="true" %> <%@attribute name="footer" fragment="true" %> <!doctype> <html> <head> <jsp:include page="../partials/defaulthead.jsp"> <jsp:invoke fragment="head"/> </head> <body> <header> <jsp:include page="../partials/header.jsp"> </header> <main> <jsp:dobody> </main> <footer> <jsp:include page="../partials/footer.jsp"> </footer> </body> </html> and view: <%@page contenttype="text/html" pageencoding="utf-8"%> <%@taglib pref...

ios - Xcode reference a framework instead of link binary with libraries -

when developing cocoa touch framework, how can use code third party framework referencing other including in "link binary libraries" option? i dont want link binary in order prevent symbol conflicts between hosting project , framework (project use framework) additionally need framework code use hosting project reference third party framework, how can done? or should take different approach example static framework (i not familiar small differences of two) select target want modify , reveal build phases. expand link binary libraries build phase view frameworks linked target. if framework want weakly link listed in link binary libraries build phase, select it, , choose edit > delete remove it. can tell linker use weak linking framework. select target, open info window, , click build. to other linker flags build setting, add following command-line option specification, name of framework want weakly link to: -weak_framework <framework_name> ...

cordova - IntelliJ IDEA / Webstorm and AngularJS / Ionic -

i love when multiple technologies come produce doozy... the following angularjs template squawks error in ide ("can't resolve file"). find inspection wildly convenient , don't want turn off. /my_project/www/templates/logo.html ... <img src="img/logo.png"/> <<< file @ /my_project/www/img/logo.png ... question: how can allow ide intellij idea or webstorm play nice ionic/angularjs/cordova in situation? note: cannot mark www folder "resources root" , use absolute references because ionic needs relative refs... or it? there way fix on cordova side of things allow absolute refs? i.e., doesn't break when deploying android (because need prefix file://android_asset/www/) inspired this answer , ended creating recursive search/replace script in build process. made cordova hook "after_prepare" , used node replace package . can use absolute refs , full benefit of ide... , @ build-time converted re...

php - script error for elasticsearch Version 1.2.1 -

i getting error when try run script. {"error":"remotetransportexception[[fin][inet[/192.168.1.127:9300]][update]]; nested: elasticsearchillegalargumentexception[failed execute script]; nested: scriptexception[scripts of type [inline], operation [update] , lang [groovy] disabled]; ","status":400} i find in elasticsearch.yml , have configure disable, if use version 1.4.3 or more, using elasticsearch version 1.2.1, automatically enabled. script.disable_dynamic: false so how can fix issue. know how solve problem? in es 1.6, need use following config parameters : script.inline: on script.indexed: on try out. ps: not use versions prior 1.3 anymore. if can upgrade 1.6 @ minimum.

javascript - jQuery toggle function fails after a while -

i've written jquery toggling function looks this: // category filter $.fn.clicktoggle = function(a, b) { var ab = [b, a]; function cb(){ ab[this._tog^=1].call(this); } return this.on('click', cb); }; $.fn.swapclass = function(oldclass, newclass) { return $(this).removeclass(oldclass) .addclass(newclass) .fadein('fast'); }; $('.category-filter').clicktoggle(function() { // clear old $('.category-filter').each(function() { $(this).fadeto('fast', 1.0); $(this).swapclass('label-success', 'label-default'); }) // new var category = $(this).attr('data-category'); $(this).swapclass('label-default', 'label-success'); // apply new $('.category-filter').each(function() { if (!($(this).attr('data-category').indexof(category) >= 0)) { $(this).fadeto('fast', 0.5); } }) $('.article_container')...

Matplotlab .exe file for Python 3.4 cannot find path to Python34 -

i running windows , beginner python user trying install few modules run python script. have python 2.7.9 , 3.4.2 both installed c:\ directory. downloaded matplotlib-1.4.3.win-amd64-py3.4.exe , corresponding .exe python 2.7 matplotlib website, when run py3.4 exe program cannot find python 3.4 update (cannot install: python version 3.4 required, not found in registry). python 2.7 installer works perfectly. there misset path variable in windows can modify .exe can function properly? in cmd 'python --version' returns python 3.4, unsure how fix issue. installed these months ago, , may have put them in downloads before transferring both c:\ clarity, may problem unsure how fix it. also, if answer involves pip in way please clarify how use pip in windows. lot of websites run eg. 'pip setup.py install' in 'terminal' not specify if mean windows cmd terminal, idle gui, or python.exe command-line interface. lot! not answer actual question, clarification on ...

c# - Do I neet Unity of Work and Repository patterns when working with Entity Framework? -

Image
so @ job pointed http://www.codeproject.com/articles/990492/restful-day-sharp-enterprise-level-application#_toc418969121 , told learn these patterns , implement them in solution. what confused me these things before entity framework 6 , understood, unity of work used optimize database performance grouping queries together. since ef6 has these optimizations, should still implement these layers? layerness helps modularization , switching of data source. mean ef6 complex implement these patterns , should ado.net used directly or that? edit: i've noticed added layer allows usage of mock data sources. not sure how useful because of need add layer of apstraction "unit of work used optimize database performance grouping queries together." - not correct. unit of work there collect related operations single transaction committed or rolled whole. tracks changes made objects required database operations can deduced automatically , performed on behalf. when work...

android - Status bar not changing color in lollipop -

Image
i trying status bar color changed lollipop. believe happens automatically giving style in xml <item name="colorprimarydark">@color/colorprimarydark</item> but not happening in nexus 5? not sure wrong? can me this? here style.xml file v21: <style name="theme.default" parent="theme.appcompat.light.noactionbar"> <item name="md_widget_color">@color/bluetext</item> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="colorprimary">@color/colorprimary</item> <item name="android:windowcontentoverlay">@drawable/toolbar_dropshadow</item> <item name="android:windowbackground">@android:color/white</item> <item name="android:edittextcolor">@android:color/background_dark</item> <item name="android:textcolor">@android:...

ios - Add objects to NSMutableArray that don't reference each other -

first question: i'm attempting add nsmutabledictionary objects nsmutablearray using method additem. -(void)additem:(id)obid name:(id)obname description:(id)obdesc menuname:(id)obmname menuid:(id)obmid mid:(id)obmid pod:(id)pod type:(id)obtype price:(id)price { nsmutabledictionary *itemtoadd = [[nsmutabledictionary alloc]init]; [itemtoadd setvalue:obid forkey:@"id"]; [itemtoadd setvalue:obname forkey:@"name"]; [itemtoadd setvalue:obdesc forkey:@"description"]; [itemtoadd setvalue:obmname forkey:@"mname"]; [itemtoadd setvalue:obmid forkey:@"menu_id"]; [itemtoadd setvalue:obmid forkey:@"mid"]; [itemtoadd setvalue:pod forkey:@"pod"]; [itemtoadd setvalue:obtype forkey:@"type"]; [itemtoadd setvalue:price forkey:@"price"]; [itemtoadd setvalue:@"1" forkey:@"amount"]; [items addobject:itemtoadd]; } however when method called a...

Get Sap Hana server version -

does 1 know hana equivalent or similar query to select serverproperty('productversion'), serverproperty('productlevel'), serverproperty('edition'), @@version the closest find is select * m_databases for completeness here answer scn: well, 1 thing here ms sql server uses different scheme indicate software version. so, wouldn't same semantics here anyhow. for logging purposes, want capture used software version, it's definitively precise do: select version m_database. technically it's possible have multiple sap hana installations on same machine different sps , revision levels. so, asking "machine-level" or "server-level" version doesn't make sense here. instead, what's relevant software you're using; , m_database provides you. if feel need separate different components of version string (major.minor.patch.build) that's trivial too: select version, substr_before (version, '.') ma...

.htaccess - How to redirect requests to files with .xml extension -

on site want block access xml files for example, when following files requested http://example.com/a_file.xml or http://example.com/some_file.xml i want browser redirect different page http://example.com/different_page.html . here have in .htaccess far: setenvif request_uri "\.xml$" blocked rewriteengine on rewritecond %{env:blocked} ^blocked rewriterule (.*) 404.php [r=301] it not stop it, still can view xml file. use setenvifnocase directive match against request_uri string in case-insenstive manner : setenvifnocase request_uri "\.xml$" blocked rewriteengine on rewritecond %{env:blocked} 1 rewriterule ^(.*)$ 404.php [nc,l,r=301]

How to get rid off 'index.php' in my laravel 5.1 links on Virtual Host -

i'm making link controller's function resides in sub directory of controller directory named 'admin'. when make link in menu bar using following code: {!! html::link('/admin', 'admin') !!} // www.property.com/admin it doesn't work, if prefix '/admin' 'index.php/admin' this: {!! html::link('index.php/admin', 'admin') !!} // www.property.com/index.php/admin it works fine. problem? how can rid off adding 'index.php' before each of link 'admini'? note i'm using virtual host named 'www.property.com' on ubuntu 15.04. here admincontroller ``` <?php namespace app\http\controllers\admin; use illuminate\http\request; use app\http\requests; use app\http\controllers\controller; class admincontroller extends controller { /** * display listing of resource. * * @return response */ public function index() { return view('admin.index'); ...

java - Usage of interceptor in spring -

Image
this situation : why using interceptor ? i want write module stores data requests being served @ server. data me in doing data visualizations. how using currently? @component public class mycustominterceptor extends handlerinterceptoradapter{ public boolean prehandle(httpservletrequest request, httpservletresponse response, object handler) throws exception { system.out.println("in interceptor"); return true; } public void posthandle( httpservletrequest request, httpservletresponse response, object handler, modelandview modelandview) throws exception { system.out.println("in post handler"); } public void aftercompletion( httpservletrequest request, httpservletresponse response, object handler, exception ex) throws exception { system.out.println("after completion"); } } and registering...

android - ValueAnimator does not reach maximum value when using reverse mode -

i'm trying animate value 0 100 0. figured valueanimator best. i'm doing this valueanimato animator = valueanimator.ofint(0, 100); animator.setinterpolator(interpolator); animator.setrepeatmode(valueanimator.reverse); animator.setrepeatcount(valueanimator.infinite); animator.addupdatelistener(listener); intepolator linearinterpolator , lister logs value. logs see goes 0 range near 100 reverses. reaches 100 few times. question is, shouldn't reach value 100. if not, there way behaviour? edit trying when target value reached. i've used animation listener now. still keeping question open understand behaviour of animator better. first thing - animator framework designed animate ui components. therefore not make sense animate every possible value in range if user's eye won't catch anyway. boundaries of repeating animation not different value within range - if won't see value of 100 on next frame, what's point animator go trough it? so, ...

datagridview - Replacing an auto generated column with a hyper link column in C# -

i trying replace autogenerated column new datagridhyperlinkcolumn , code private void dgv_university_autogeneratingcolumns(object sender, datagridautogeneratingcolumneventargs e) { if (e.propertyname=="web address") { datagridhyperlinkcolumn col1 = new datagridhyperlinkcolumn(); col1.header = "web address"; e.column =col1; } } but can't seem generate same contents of column, can please tell me how this? create column in datagridview before setting datasource or in designer set datapropertyname = "web address"; datagridview use column displaying data of web address column of datasource , other columns generated well

html - How to put "No file chosen" text under a button -

i need under not next button. there easy way that? <input type="file" size="45"> how solution this <input type="file" id="selectedfile" style="display: none;" onchange="document.getelementsbytagname('p')[0].innerhtml=this.value;"/> <input type="button" value="browse..." onclick="document.getelementbyid('selectedfile').click();" /> <p>no file chosen</p> an example: https://jsfiddle.net/366tjfvn/1/ ref: how hide text field in html file upload updated to: ismael miguel

c++ - Image processing using Python and OpenCV on a Raspberry PI -

i planning on doing image processing opencv , python on rpi. easy of use of pi camera python (picamera module) tempting. know c++ going faster python when doing significant processing there isn't easy way of accessing camera. question: performance hit of using python image processing application opposed implementing same in c++ ? my question focused on way opencv libraries called within cv2 module in python ? there ton of overhead associated that? all computationally expensive stuff can done in opencv. using python wrapper won't cost computationally.

Passing javascript variables to another php page -

i have select list in using javascript selected values want selected values pass through php file init.php can use variables in mysql query. javascript code follows: $(document).ready(function(){ var e = document.getelementbyid("product"); var pro = e.options[e.selectedindex].text; alert(pro); }); $('select').change(function(){ var e = document.getelementbyid("city"); var cit = e.options[e.selectedindex].text; alert(cit); i have used ajax send variables init.php. ajax code below not working,can tell whats issue in code: $.ajax({ url: 'init.php', type: 'post', data: { x:'cit',y:'pro' }, success: function(data) { ...

javascript - How to setup a RequestHandler for images with VaadinServlet -

i want have requesthandler able dynamically create images @ mydomain/images/id8938748.jpg , @ same handle other traffic through standard vaadinservlet . understand need put requesthandler in vaadinservlet explained here extending such as: public class mycustomservlet extends vaadinservlet { @override protected void service(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { getservice().addsessioninitlistener(new sessioninitlistener() { @override public void sessioninit(sessioninitevent event) throws serviceexception { event.getsession().addrequesthandler(mycustomrequesthandlerforimages); } }); } } my problem how register new mycustomservlet ? looked @ doing in web.xml can't seem right. my requesthandler simply: @override public boolean handlerequest(vaadinsession s...

javascript - How do I implement a delay on jQuery keyup? -

i'm making list filter , want delay in case user fast typer. looking @ different solutions similar questions hasn't helped me , don't understand logic implement. this current code: $.fn.filterlist = function(){ var inputfilter = $(this); var list = $('#' + inputfilter.data('list')); var listitems = list.children('li'); inputfilter.keyup(function(){ settimeout(function () { var term = inputfilter.val().tolowercase(); listitems.each(function(i, e){ var city = ($(e).text()).tolowercase(); if(city.startswith(term)){ console.log(city); } }); }, 800); }); }; $('.my-input').filterlist(); the problem trigger on each keyup, no matter how fast user types. how can implement delay not trigger each keyup ? on each successive keypress need clear previous timer function fires x ...

python - Search all drives for a file -

i have name of file , want find on whatever drive is. can use recursive search, need root directory start with. computers, root "c:\". there have changed letter, or have more 1 (eg. c,d...). so, need find way know drives in computer, can search through each one. need find letters programmatically without user input. i know can use "diskpart", requires administrator access, code not have. there "wmic", don't know if computer has right folder in path. so, question how can recursive search in computer don't know letters of drives or how many there? or there way find path of file in computer? i have solution requires run administrator, not require install other tools. have alternative, messy solution can run without of these privileges. i'll start cleaner one. this script find drives: import subprocess drivestr = subprocess.check_output("fsutil fsinfo drives") drivestr = drivestr.strip().lstrip('drives: ') ...

Iterate through list and assign a value to the variable in Python -

so i'm working on code, solves simple differentials. code looks that: deff diff(): coeffs = [] #checking rank of function lvl = int(raw_input("tell me rank of function: ")) if lvl == 0: print "\nif rank 0, differential of function 0" #asking user write coefficients (like 4x^2 - writes 4) in range(0, lvl): coeff = int(raw_input("tell me coefficient: ")) coeffs.append(coeff) #printing coefficients print "\nso coefficients are: " item in coeffs: print item and want next? have every coefficient in coeffs[] list. want take every single 1 there , assign different variable, make use of it. , how can it? suppose have use loop, tried hours - nothing helped me. sooo, how can this? : a=coeff[0], b = coeff[1], ..., x = coeff[lvl] . just access coefficients directly list via indices. if wanting use values in different context entails making changes values want keep original list unchanged copy list new list, import ...

Move files to HDFS using Spring XD -

how move files local disk hdfs using spring xd. i not want contents , move whole file archival saves file original name , content. here have tried stream create --name fileapple --definition "file --mode=ref --dir=/users/dev/code/open/learnspringxd/input --pattern=apple*.txt | whattodohere" i can see reference file names full path made available , how move hdfs. you might want check this imports data files hdfs batch job , check if fits requirement. can check file | hdfs stream if works you.

some problems with my eclipse when create an new project from existing android code -

the problem ,when want create android project stemp: file->new->project->android-android project existing code->next import projects dialog opened, when click browse,the file browser points home folder in case "administrator". can change make point local drive c:\ example ? in browser dialog can choose folder want or type directly in file location bar ( located on top )

encryption - java DES encrypt code convert to ruby -

hi have java android encrypt method, , want convert ruby code. ivparameterspec localivparameterspec = new ivparameterspec(new byte[] { 12, 34, 34, 11, 64, 23, 89, 27 }); deskeyspec localdeskeyspec = new deskeyspec(paramstring2.getbytes()); secretkey localsecretkey = secretkeyfactory.getinstance("des").generatesecret(localdeskeyspec); cipher localcipher = cipher.getinstance("des/cbc/pkcs5padding"); localcipher.init(1, localsecretkey, localivparameterspec); return new string(base64.encode(localcipher.dofinal(paramstring1.getbytes()), 0)); and google useful articles, still not same output. know ruby code above java code? thx! des = openssl::cipher::cipher.new("des-cbc") des.encrypt des.key = "xxxx" des.iv = "xxxx" cipher = des.update(str) + des.final base64.strict_encode64(cipher)

html - Is it possible to have a website, like a text-based document? -

when view source code of website - text-based document: view-source:http://example.com/ i suppose, asking is: possible have: ' http://example.com/index.txt ', , remove the: '/index.txt' (using .htaccess) - website acts text document. you need create .htaccess file in root directory , set directory index so: directoryindex index.txt .htaccess guide - directoryindex uses in cases, advise against cannot use form of code or formatting within document. means no hyperlinking, no images, nothing apart plain text.

objective c - IOS voip app with Push kit -

i working voip app using push kit framework. have issues related delivery of remote notification. issues 1) notification messages send when device turned off lost permenantly 2) after restarting device, no push notification messages recieved unless application started again i have enabled voip on ip, background fetch, remote notification capabilities , checks notification available on - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { nsdictionary* payload = [launchoptions objectforkey:uiapplicationlaunchoptionsremotenotificationkey]; if (payload) { // process payload here nslog(@"there notifications available processing"); } } i have overrided following methods //pushkit notification alerts methods - (void)pushregistry:(pkpushregistry *)registry didupdatepushcredentials:(pkpushcredentials *)credentials fortype:(nsstring *)type{ if([credentials.token length] == 0) { ...

joomla - Web page alignment changes when Android keyboard open -

on website in mobile, responsive layout broken when android keyboard open. using joomla framework. how fix it? you haven't provided information guess keyboard messing breakpoints in css. here place read more breakpoints , how people using them: common css media queries break points . in future need provide lot more information in order people you.

cloud - Microsoft HPC pack / MPI , scheduler not regrowing task in job? -

i have job composed 3 tasks: task 1 : min 1, max 4 nodes task 2 : min 1, max 1 node task 3 : min 1, max 4 nodes my scheduler set queued, graceful preemption , adjust resources automatically. jobs scheduled via service on target machine, same priority. here question: 1 job queued, sometimes, scheduler allocates 1 node task 3, if there no other jobs queued. working intended? trial , error can see if task 1 + 2 doesn't take time, task3 have 4 nodes allocated. otherwise, if task1+2 takes little longer (20 mins or so) task3 gets allocated 1 node only. i'm not sure if working intended or if should write kind of service periodically checks queue status , if needs be, changes task3 minimum nodes requirement before task2 finishes course of action. any insight appreciated, thanks!

jquery - Ajax - security breach? - PHP -

i build system in php, have page name x.php , in page create variable name $accountid , acocunt id sesstion. now have others varibles in php @ same page calls functions in other page called functions.php, , deliver accountid, function return info account (for example name of user..) is security breach? i mean user can call in ajax function other accountid , can info other account? here code example: <?php include "includs/config.php"; if(!isset($_session[get("session_name")])) { header("location: index.php"); } $accountid = getaccountid($_session[get("session_name")]); $e = getecategorys($accountid); ?> function gete($accountid){ $query = mysql_query("select * `x` `accountid` = $accountid"); while($result = mysql_fetch_assoc($query)){ // info account.. } } yes right. user can information passing accountid function. solution: can check session vari...

javascript - Handling WebSocket connections in Jasmine tests -

i have test.login.js : it('calls login when there\'s username present', () => { react.finddomnode(loginelement.refs.username).value = 'foo'; testutils.simulate.submit(form); expect(loginelement.state.errored).toequal(false); }); by submitting form, calls login method: login() { let typedusername = react.finddomnode(this.refs.username).value; if (!typedusername) { return this.setstate({ errored: true }); } // don't send request here, set username on authmodel , call `login` method below authmodel.set('username', typedusername); authmodel.login(); }, so i'm trying test functionality of login.jsx , not authmodel.js , calling authmodel.login() , sends message on websocket. however, issue in actual app, don't load until websocket has connected (i fire event render react app), in jasmine test, don't wait event, receive: error: null, domexception{stack: 'error: fail...

linux - C Web Browser Download File -

webkitgtk+ api reference what i'm trying run html5 app on linux way & users can still use app without relying on internet connection. my problem when go download zip file. download doesn't execute because there isn't adequate url file save (like desktop). therefore doesn't download. thus question relies onto how suppose adequate url download file when it's executed dynamically via jszip . (it works fine in chrome, not in app). terminal says... source.c:35:3: warning: ‘return’ value, in function returning void [enabled default] return true; ^ any appreciated. here's code: /* save file main.c , compile using command (those backticks, not single quotes): gcc -wall -g -o source source.c `pkg-config --cflags --libs gtk+-2.0 webkit-1.0` -export-dynamic execute using: ./source if can't compile chances don't have gcc installed. install gcc/c following terminal command. (this command debian based linux distros) ...

c# - To bind Usercontrol in aspx using ajax -

in below code have usercontrol control.ascx have textbox , dropdown , want check db whether field textbox or dropdown , want display in sample.aspx using ajax. pls me this. control.ascx <table width="100%"> <tr> <td> <input type="text" id="btnfield" value="val" /> </td> <td> <select id="cbb" style="width:75%"></select> </td> </tr> </table> sample.aspx <table> <tr> <td> <uc1:ucreport id="ucreport" runat="server" /> </td> </tr> </table> function loadusercontrol() { $.ajax({ type: "post", url: "sample.aspx/loadcontrols", data: "", contenttype: "application/j...

magento - downloadable item product selling cart with filter -

i want sell downloadable product like: video files, pdf files, word documents, text documents etc. and storefront should have filtering feature. i have option following cart in hosting control panel: abantecart, opencart 1.5, prestashop etc. accessing mochahost cpanel. to make storefront of downloadable products filtering feature, free cart product should choose? big, proven, free, plus easy customization: woocommerce. it's classic reason. the real issue is: how rest of website managed? software languages intending? server? # of hits projected / day? want tools integrate, , have active feedback , improvement system. (open source on github?) php or java content management system? (symphony, laravel, wordpress? dotcms, magnolia, hippo, jahia, opencms?) i'd pick 1 of first, choose storefront integrates nicely. if starting out, , don't expect more 5k 10k hits day, wordpress / woocommerce way easy. if bigger growth that, i'd think i'd looking @ ja...

mysql - PHP Mysqli request Url after a query is finished -

i trying request url or api in php after fetch query completed unable as below api follows 1.url 2. username default not change 3. password same username 4. sender id same username , password but every things matter url should wait till php result fetched 5. phone number php fetch result $numstr 6. text of our own 7. priority & smstype of our own not change $query="select num euser userid in (select id master aa='aa' , cc='cc')" ; $data=mysqli_query($mysqli,$query)or die(mysqli_error()); $num = array(); while($row=mysqli_fetch_array($data)){ if($row['num'] != '' && $row['num'] != null){ $num[] = $row['num']; } } $numstr = implode(',', $num); echo $numstr; mysqli_close($mysqli); api http://test.forsms.com/api/sendmsg.php user=*******&pass=********&sender=*****&phone=&text=test sms&priori...

sql - Add a default value in group by select in case a specific value is not present -

i have following table: code | value | req_date and following query: select code, sum(value) sums, req_date table group code,req_date normally codes "0" , "30" should present, anyway i'd make that, if not present, following default records "0" | 0 | <date> "30"| 0 | <date> appear. possible? if after default value 0 , 30, unioning table additional rows default data , grouping whole lot should work: select code ,sum(value) sums ,req_date ( select code ,value ,req_date table union select '30' code ,0 value ,sysdate req_date --default date here union select '0' code ,0 value ,sysdate req_date --default date here ) uniontable group code ,req_date

php createFromFormat fails with datepicker -

i have below datepicker in form: $( '.datepicker' ).datepicker({ dateformat: 'dd-mm-yy' }); then in php code processes form have: $campaigndate = datetime::createfromformat('d-m-y', $formdata['campaign']['campaign_date'] ); if ($campaigndate) { $campaignunixdate = $campaigndate->gettimestamp(); } else { $response = array( 'status' => 'failed', 'message' => 'failed create campaign date', 'redirect' => '' ); echo json_encode($response); return; } $campaigndate seems false, assume have wrong format createfrom cant work out issue. solution use uppercase y instead of lowercase y $campaigndate = datetime::createfromformat( 'd-m-y', $formdata['campaign']['campaign_date'] ); explanation the date f...

cassandra - jmx is not enabled to receive remote connections -

i not sure why 7199 listening on 127.0.0.1,how can make 7199 listen hostip address. my cassandra-env.sh config below jvm jmx_port="7199" jvm_opts="$jvm_opts -djava.net.preferipv4stack=true" jvm_opts="$jvm_opts -djava.rmi.server.hostname=192.68.0.45" local_jmx=no if [ "$local_jmx" = "yes" ]; then jvm_opts="$jvm_opts -dcassandra.jmx.local.port=$jmx_port -xx:+disableexplicitgc" else jvm_opts="$jvm_opts -dcom.sun.management.jmxremote.port=$jmx_port" jvm_opts="$jvm_opts -dcom.sun.management.jmxremote.rmi.port=$jmx_port" jvm_opts="$jvm_opts -dcom.sun.management.jmxremote.ssl=false" jvm_opts="$jvm_opts -dcom.sun.management.jmxremote.authenticate=true" jvm_opts="$jvm_opts -dcom.sun.management.jmxremote.password.file=/etc/cassandra/jmxremote.password" i have been fighting issue too. been not easy shown on tutorials. i solved issue this: add envir...

javascript - In iOS UIWebView how to get html DOM content before it finished loading? -

i getting url , i'd present in uiwebview this: request = [nsurlrequest requestwithurl:[nsurl urlwithstring:url]]; [_webview loadrequest:request]; but due network restriction in china, cannot access google services page url using: <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> so have wait long time expire since not able js file ajax.googleapis.com , i'd exchange script source local js file in order enable javascript calls in future. i think if can dom before finished loading, can add script source this: <script src="//code.jquery.com/jquery-1.11.3.min.js"></script> but how can that? i tried load local html file params dynamic server side. i tried call [_webview stringbyevaluatingjavascriptfromstring:url] in uiwebview delegate methods didn't work. my solution/workaround is: set timer after sending url timer wait try detect received dom check if <head> has ...

C++: string = NULL gives SEGFAULT 11? -

i modified project today allow save files in different folders, , found program crashed when startup: segmentation fault: 11 because introduced many changes before testing program, started comment out functions added, no help. put cout << "hello world" << endl; return 0; as first 2 lines in int main() , still crashed without showing anything. finally, took me 1 hour figure out error. modification includes declaring global variable string foldername = null; the line above seems innocence, declaring global variable. then tried simple program: #include <string> std::string = null; int main(){ return 0; } and crashed @ startup. why declaring string global variable null make program silently crashed without info? the std::string - opposite inherited c char* strings - holds valid string. may empty, cannot null. if try initialise std::string null try blindly copy c-like string null address, undefined behaviour. just use...

MySQL Join AND EXISTS in combination -

case got following query: select * `parking_parking` join `parking_address` on `parking_parking`.`parking_address` = `parking_address`.`address_id` `parking_id` = 3 this query selects information parking (address , data parking itself) and in general.. works! problem there small problem though.. whenever address has been deleted database , parking still exists. entire query returns 0. because looks , a , b linked. if 1 not found second won't returned either. now there solution.. exists however not know how use it. i tried: exists join join exists join `parking_address` on exists but no avail. i hope (and guess) have overlooked small thing. note !! not use in real life! !! select * i did 1 when still @ veeeery basics , found out hard way simplest pages took ages load. solution : goleztrol select * `parking_parking` left join `parking_address` on `parking_parking`.`parking_address` = `parking_address`.`address_id` `parking_id` ...