Posts

shell - keep expanding a bash variable -

imagine have n months, here n=3 i keep adding integer 1, 2, 3 shell variable called $test: so when do cat $test it return 1 2 3 any idea? just find solution: for ((i=1;i<=3; i++)); test1="${i}" test+="$test1 " done

matlab - Struggling to index into a column vector produced using the eval function -

i have several tables, each massive amount of data (20mb each). let's call them table_1, table_2, table_3, etc. structure of these tables similar, identical column headers (but varying number of rows). let's attribute_a, attribute_b, etc. i interested in performing calculations on attribute_b each table. these calculations involve looping through attribute_b. i start creating master list of table names. table_list = [table_1, table_2, ... table 10]; now can iterate through , perform calculations. doing single calculations works fine using eval , concatentation of column vector name function of value of current_table: for current_table = table_list peak_value = max(eval(strcat(current_table,"attribute_c"))); i run trouble when perform calculations require iterating through column vectors. instance, following fails. for current_table = table_list = 1:length(eval(strcat(current_table,".attribute_b") x = x + eval(strcat(current_...

python - An external increment? -

i trying create file "varstore.dat" (that not exist prior running this) should contain value 0. every time execute script, want increment value 1. so trying create file 1 time, read file, , rewrite(or overwrite) file upon each execution. however, problem each time run program, initialize 0 , output 1. trying rewrite varstore.dat , new value become old value next time execute script. def get_var_value(filename="varstore.dat"): open(filename, "a+") f: val = int(f.read() or 0) + 1 f.seek(0) f.truncate() f.write(str(val)) return val your_counter = get_var_value() print("this script has been run {} times.".format(your_counter)) you need f.seek(0) before val . def get_var_value(filename="varstore.dat"): open(filename, "a+") f: f.seek(0) val = int(f.read() or 0) + 1 f.seek(0) f.truncate() f.write(str(val)) return val the...

python - How to redirect in django while using django-hosts? -

i'm using django-hosts package manage content that's supposed set in various different subdomains. started making view in form used change something. once form validated , processed, user supposed redirected other page. looking through documentation there's easy way render(): settings_url = reverse('settings', host='dashboard') return render(request, 'dashboard/settings.html', {'settings_url': settings_url}) however, there's no mention of redirect(). how go redirecting somewhere else, instead of usual return redirect("dashboard:settings") myapp/hosts.py : host_patterns = patterns('', host(r'www', settings.root_urlconf, name='www'), host(r'dashboard\.myapp\.com', 'dashboard.urls', name='dashboard'), ) dashboard/urls.py from .views import home, websitesettings urlpatterns = [ url(r'^$', home, name='home'), url(r'^settings/$',...

scala - How can I queue REST requests using Apache Livy and Apache Spark? -

i have remote process sends thousands requests humble spark standalone cluster : 3 worker-nodes 4 cores , 8gb identical master-node driver runs that hosts simple data processing service developed in scala. requests sent via curl command parameters .jar, through rest apache livy interface this: curl -s -x post -h "content-type: application/json" remote_ip:8998/batches -d '{"file":"file://path_to_jar/target/my_jar-1.0.0-jar-with-dependencies.jar","classname":"project.update.my_jar","args":["c1:1","c2:2","c3:3"]}' this triggers spark job each time, the resource scheduling cluster dynamic can serve @ 3 requests @ time, when worker goes idle, queued request served. at point in time, requests kills master node memory if in waiting state (because spark register jobs served), hangs master node , workers loose connection it. is there way can queue requests preventing spark...

javascript - How to dynamically generate different google maps -

here issue have. have many businesses , want show google maps each business (all in 1 html page). for each business have: the latitude , longitude (always). the address not street number. question. how can insert google map each business using lat/long or business using google map api? difficulties -using id each business not ideal. -how can pass latitude/longitude javascript function insert map? here general idea of want do. assume have array of businesses contains information each business. foreach($businesseslist $businessname =>binfo) { list($about, addresstext, $lat, $long) = $binfo <div> $businessname</div> <div> $about</div> <div class='map'> //insert google maps inside div each business using $lat, $long , google maps api. </div> } i dont experience javascript , jquery work php i can set array containing google maps embed code , embedded code each busines...

ios - do you want to add a stub? SwiftWebViewProgress 0.3 in Xcode 8.3.3 -

i have build error swiftwebviewprogress 0.3 in xcode 8.3.3 protocol requires function 'webviewprogress(_:updateprogress:)' type '(webviewprogress, float) -> ()'; want add stub? when click fix-it, xcode write code below, don't know hot next class browserviewcontroller: uiviewcontroller, uitextfielddelegate, uiwebviewdelegate, actionviewcontrollerdelegate, webviewprogressdelegate { func webviewprogress(_ webviewprogress: webviewprogress, updateprogress progress: float) { <#code#> } i have found solution this. class browserviewcontroller: uiviewcontroller, uitextfielddelegate, uiwebviewdelegate, actionviewcontrollerdelegate, webviewprogressdelegate { func webviewprogress(_ webviewprogress: webviewprogress, updateprogress progress: float) { progressview.setprogress(progress, animated: true) }