Posts

Showing posts from August, 2015

cq5 - device simulator not working in AEM 6 -

the device simulator not working in aem 6 (mongo db persistence manager) installation. it's throwing error that's stopping page loading. i'm trying open demo geometrixx media site has required deice groups set. stack trace of exception *error* [0:0:0:0:0:0:0:1 [1410351155706] /content/geometrixx-media/en.html http/1.1] com.day.cq.wcm.tags.includetag error while executing script head.jsp org.apache.sling.api.scripting.scriptevaluationexception: org.apache.sling.scripting.jsp.jasper.jasperexception: unable compile class jsp: error occurred @ line: 103 in jsp file: /libs/wcm/mobile/components/simulator/simulator.jsp type java.lang.charsequence cannot resolved. indirectly referenced required .class files 100: }); 101: </script><% 102: } else { 103: log.warn("mobile page [{}]: no device groups, cannot initialize emulators.", currentpage.getpath()); 104: } 105: } 106: %> @ org.apache.sling.scripting.core.impl.defa

osx - How to a file uploading using Automator in apple script? -

i’m new automator. i’m trying achieve. i have code uploading file in safari using applescript ( upload file myfile points to): on run argv set myfile item 1 of argv activate application "safari" tell application "system events" tell process "safari" keystroke "g" using {command down, shift down} delay 2 key code 51 delay 2 keystroke myfile delay 30 key code 52 delay 10 key code 52 delay 5 end tell end run this applescript been called java , works fine. this working totally fine. want put in automator service, safari has directly access applescripts, rather java doing it. have 2 questions: many safari running , calling service. safari needs give file uploading process needs figured out. possible automator find process id of application called ? if so, how shall pass parameter (the file location uploaded) automator, when service called?

android - Want to restart service if application stopped by user from application manager. -

i'm using sticky android service using code snippet in service class @override public int onstartcommand(intent intent, int flags, int startid) { return start_sticky; } but restarts when app force closed android o/s, although when user force stop app application manager, service terminated. however, requirement want keep running service forever till app installed in device. 1 me on this? you can use forground service make service alive. @override public int onstartcommand(intent intent, int flags, int startid) { notification notification=new notification(r.drawable.icon,"the service running",system.currenttimemillis()); intent j=new intent(this, activity.class); pendingintent pi=pendingintent.getactivity(this, 0, j, 0); notification.setlatesteventinfo(this, "notification message", "runningservice", pi); notification.flags|=notification.flag_no_clear; startforeground(1, notification);

shell - How to read file names from a txt file in cmd prompt(script) and then combine a subset of the files into a PDF file using the cmd line in windows -

i have text file in following format: 2014-05-13 03:35 pm 48,841 sur2-**c01**-00-000-pce-1001-002.pdf 2014-05-13 03:36 pm 43,599 sur2-**c01**-00-000-pce-1002-001.pdf 2014-05-13 03:35 pm 51,900 sur2-**c02**-00-000-pce-1000-001.pdf 2014-05-13 03:35 pm 53,622 sur2-**c02**-00-000-pce-1000-002.pdf 2014-05-13 03:35 pm 52,145 sur2-**c02**-00-000-pce-1000-003.pdf 2014-05-13 03:35 pm 50,426 sur2-**c02**-00-000-pce-1000-004.pdf i need parse file, , pull out files match c01 or c02, , send these files combined pdf file, 1 c01 , 1 c02. how can parse file, , string match file names on c01 or c02? then, how can take above parse result, , using file names found, combine them pdf command line or in script? merge-c01.bat 1.use awk parse file array set list=($(awk '/c01/{print $5}' file.txt)) 2.use pdf merge tool (pdftk) merge files in array for %%i in %list% pdftk out.pdf %%i cat output out.pdf

css - Maintain aspect ratio and font size based on browser height and width? -

the code below attached window.onresize = resize; . basewidth , baseheight read on load basis calculations. main variable defined setting main html node. font set on block element cause of em based elements within resize in kind. when width or height of browser changed ratio recalculated. please see demo understand achieve js find pure css solution: http://codepen.io/anon/pen/nlauf i have been exploring options in css3 such calc . feel free suggest improvements js below also. function resize() { var height = 0, width = 0; if(window.innerwidth <= window.innerheight) { size = window.innerwidth / basewidth; height = baseheight * size; width = window.innerwidth; } else { size = window.innerheight / baseheight; height = window.innerheight; width = basewidth * size;

scala - access google cloud storage using java library gets '403 forbidden' -

i'm trying use google cloud storage java library in scala list items in bucket val credential = new googlecredential.builder() .settransport(googlenethttptransport.newtrustedtransport()) .setjsonfactory(jacksonfactory.getdefaultinstance()) .setserviceaccountid("xxx@developer.gserviceaccount.com") .setserviceaccountscopes(collections.singleton(storagescopes.devstorage_read_only)) .setserviceaccountprivatekeyfromp12file(new file("file.p12")) .build() val storage = new storage.builder( googlenethttptransport.newtrustedtransport(), jacksonfactory.getdefaultinstance(), credential) .sethttprequestinitializer(credential) .setapplicationname("app") .build() storage.objects.list("bucket").execute however got com.google.api.client.googleapis.json.googlejsonresponseexception: 403 forbidden { "code" : 403, "errors" : [ { "domain" : "global", "message" : "

m4a - android-aac-enc does not work on Samsung Star phone -

i need implement audio recording pause/resume functionality , output has m4a file format. implemented recording in pcm format. i'm using (for old android versions only) library found here - https://github.com/timsu/android-aac-enc the strange part is working lot of devices (like nexus 7) not work samsung star. there no crash, player after tries play there strange noise. i suspect architecture of processor don't know might , how fix it. please if have experience library me. (or if know better 1 integrate) thanks , kind regards ok, managed make working. in documentation written call multiple times encode method. implemented encoding on small chunks. problem seems @ end of each chunk puts , awful beep :-( so know not perfect solution manage make working load whole file in byte array , encode @ once... if finds better solution please let me know.

rest - Rails - best practice of handling restful update of a single attribute -

i have :users resource typical attributes (first name, last name, email...) user can update, have user attributes typical user can not change himself or can change in different way, example role or deactivated_at . a non-restful solution be: resources :users member put :change_role put :activate end end i writing api , goal stick rest constraints as possible. options see them are: send patch :update, , add more logic in controller action expose endpoints attributes , add new controllers such cases, example resources :users resource :role, only: :update end expose endpoints attributes , route them new action of existing controller resources :users resource :role, only: :update, to: 'users#update_role' end and still not sure :activate? is there other way, , recommended practice in situation?

jquery - Make image as background into an empty row in bootstrap -

i place image row using backstretch jquery plugin. here snippet: script $("#img-background").backstretch("/image.jpg"); .container-fluid .row #img-background nothing has placed row background image through above plugin unfortunately image not showed since row empty.beside image responsive. width image 1050px. if use background-size: cover unfortuntately image not responsive. suggest image responsive? example http://jsfiddle.net/wcqx8esx/

matlab 3d projection image -

i'm doing image 3d projection, when use iwarp function result multidimensional matrix, i'm using: color1 = imread('color1.jpg') % 480x640x3 image rbg %4x4 projection matrix mx = makehgtform('xrotate',-0.01970); = makehgtform('yrotate',0.01729); mz = makehgtform('zrotate',-0.00717); m = mx*my*mz; m(1,4) = -28.54007; m(2,4) = -2.00470; m(3,4) = 4.37353; t = affine3d(m); %do transform color_rectified = imwarp(color1,t); %485x644x24 at end, color_rectified size 485x644x24, idea image rotated/translated in x,y,z , rgb, how this?

linux - Python script not waiting for user input when ran from piped bash script -

i building interactive installer using nifty command line: curl -l http://install.example.com | bash the bash script rapidly delegates python script: # file: install.sh [...] echo "-=- welcome -=-" [...] /usr/bin/env python3 deploy_p3k.py and python script prompts user input: # file: deploy_py3k.py [...] input('====> confirm or enter installation directory [/srv/vhosts/project]: ') [...] input('====> confirm installation [y/n]: ') [...] problem : because python script ran bash script being pipe d curl, when prompt comes up, automatically "skipped" , ends so: $ curl -l http://install.example.com | bash -=- welcome ! -=- have detected have python3 installed. ====> confirm or enter installation directory [/srv/vhosts/project]: ====> confirm installation [y/n]: installation aborted. as can see, script doesn't wait user input, because of pipe ties input curl output. thus, have following problem: curl [stdout]=>[st

Waiting for X time in loop using JAVA/Android -

in code want check longitude , latitude value. if values empty, code check 15 seconds. if values received , while loop break , show "you win". if still empty, should show "error in gps" after 15 seconds. problem code waiting progress bar not showing in screen because screen got stuck during wait time. after 15 seconds screen free. please tell me how resolve issue. @override public void onclick(view arg0) { // todo auto-generated method stub toast.maketext(getbasecontext(), longitude.gettext(), toast.length_long).show(); toast.maketext(getbasecontext(), latitude.gettext(), toast.length_long).show(); pbar = new progressdialog(oproprietor.this); pbar.setcanceledontouchoutside(false); pbar.setprogressstyle(progressdialog.style_spinner); pbar.setmessage("waiting 15 seconds"); pbar.show();

android - ListView OnItemClickListener doesn't fire -

i'm @ loss. have listview being set via adapter in fragment. public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment_knowledgebase, container, false); // set adapter mlistview = (abslistview) view.findviewbyid(r.id.searchresultlist); // set onitemclicklistener can notified on item clicks mlistview.setonitemclicklistener(this); mlistview.setadapter(madapter); return view; } public void onitemclick(adapterview<?> parent, view view, int position, long id) { if (null != mcallback) { //call activity mcallback.onfragmentinteraction(position); } } the layout of list dead simple. 1 text view, no buttons or check boxes. <framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"

sql server - SQL: Must declare scalar variable -

when run following t-sql in sql server 2012 works fine, in sql server 2008 r2 error must declare scalar variable "@in" and must declare scalar variable "@out" code: declare @outids nvarchar(max); declare @in timelinereportlist; declare @out timelinereportlist; declare @startdate datetime; declare @enddate datetime; declare @assessmentid int; set @startdate ='2013-01-01t00:00:00.000' set @enddate ='2013-01-01t00:00:00.000' set @assessmentid = 14 set @outids ='3,9,10' insert @in select * dbo.udf_first_timeline_entries_of_status(@assessmentid) insert @out select * dbo.udf_first_timeline_entries_of_any_statuses(@outids) select * dbo.udf_generic_timelines(@startdate, @enddate, @in, @out,default) timelinereportlist user-defined table type exists in db edit i've tested first 2 queries running following , both return results: select * dbo.udf_first_timeline_entries_of_status(@assessmentid) select * dbo.udf

conditional - Shopify Custom Text box according to product collection -

im trying conditional if product in collection "personal" show text box. have in product.liquid page does't seem working. {% if collection.title == 'personal' %} <div> <p><input type="text" id="letter" placeholder="enter 6 letters" name="properties[letter]" /></p> </div> {% endif %} try this: {% collection in product.collections %} {% if collection.handle == 'personal' %} <div> <p><input type="text" id="letter" placeholder="enter 6 letters" name="properties[letter]" /></p> </div> {% endif %} {% endfor %} see shopify docs product.collections .

robocopy - do not copy source uncompressed file when zip file of same name present in destination directory -

i have batch file uses robocopy copy data files 1 location another. because of capacity problems on destination drive, have created script makes zip files of each individual data file , removed original data file system. how can modify batch file copies new '.dat' files destination when there isn't matching '.zip' file same file name? require new '.dat' files on destination drive processing before conversion '.zip' here's example of source , destination files: sourcedir\file1.dat sourcedir\file2.dat sourcedir\file3.dat sourcedir\file4.dat sourcedir\file5.dat sourcedir\subdir1\file1.dat sourcedir\subdir1\file2.dat sourcedir\subdir3\file22.dat destdir\file2.zip destdir\file3.zip destdir\file5.zip destdir\subdir1\file1.zip only sourcedir\file1.dat sourcedir\file4.dat sourcedir\subdir1\file2.dat sourcedir\subdir3\file22.dat should copied destdir thanks! erik the current robocopy script has following format: robocopy source

osx - Image picker or file chooser for OS X Cocoa -

in application need pick image filesystem. know how in ios no idea make in os x. there tool imagepicker or file chooser os x? need please. in ios use this: uiimagepickercontroller *imagepicker = [[uiimagepickercontroller alloc] init]; imagepicker.delegate = self; imagepicker.sourcetype = uiimagepickercontrollersourcetypephotolibrary; thanks in advance! on mac there ikpicturetaker works uiimagepickercontroller. https://developer.apple.com/library/mac/documentation/graphicsimaging/conceptual/imagekitprogrammingguide/ikimagepicker/ikimagepicker.html

javascript - How to make Mocha display correct line numbers in source files if a test fails? -

i'm using mocha nodejs tests, , when test fails due error thrown source code (for example " typeerror: cannot read property 'prop' of null "), line numbers in displayed stacktrace wrong (they don't match original source file, far bigger). 1) myapp should something: typeerror: cannot read property 'prop' of null @ myapp.<anonymous> (/path/to/my-project/lib/my-project.js:515:93) @ myapp.build (/path/to/my-project/lib/my-project.js:774:16) @ context.<anonymous> (/path/to/my-project/test/test.js:62:67) @ test.runnable.run (/path/to/my-project/node_modules/mocha/lib/runnable.js:216:15) @ runner.runtest (/path/to/my-project/node_modules/mocha/lib/runner.js:373:10) @ /path/to/my-project/node_modules/mocha/lib/runner.js:451:12 @ next (/path/to/my-project/node_modules/mocha/lib/runner.js:298:14) @ /path/to/my-project/node_modules/mocha/lib/runner.js:308:7 @ next (/path/to/my-project/

javascript - Where is the Token or SubscribeUrl inside the SubscriptionConfirmation request? -

i'm trying accept subscription confirmation sns using node.js. i type endpoint console , hit subscribe. the documentation says after subscribe http/https endpoint, amazon sns sends subscription confirmation message http/https endpoint. message contains subscribeurl value must visit confirm subscription (alternatively, can use token value confirmsubscription). so i'm doing preview request can find information need. if(req.headers['x-amz-sns-message-type'] === 'subscriptionconfirmation'){ console.log('subscription confirmation requested',req.headers); console.log('body:',req.body); var arn = req.headers['x-amz-sns-subscription-arn']; var topic = req.headers['x-amz-sns-topic-arn']; res.send(200); } i can't find subscribeurl or token in headers or in body. the console line containing req.body prints body: {} console line containing req.headers doesn't contain subscriptionurl or token

android - when alarm fires, start an activity if app active or send notification if app not active -

in app want schedule alarm associated activity a. when alarm fires, should happen depends on circumstances: 1. if app not opened @ time, display notification in notification bar , start activity next time app started 3. if app active, start activity a activity not background activity - requires user interaction. ideally, same behavior work more 1 alarm - i.e. if 2 alarms fired while app not in use, 2 activities queued start once user starts app. i read android docs on alarmmanager, pendingintents , notification - know how schedule alarm fires notification, don't know @ how go - "queueing" of activities after alarm fires - "conditional behavior" when alarm fires (based on whether app running or not). it seems plenty of apps need kind of behavior. hope can point me in right direction. found solution in "android programming: big nerd ranch guide" book (hardy & phillips). solution use intent service handles alarmmanager intents

css - Jquery UI tabs - Selected tab smaller line-height -> last tab breaks design -

Image
i having css problem jquery ui tabs. want show tab selected changing height of tab link: i changing line-height of anchor: .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { line-height: 10px; } unfortunately breaks layout whenever select last tab on row: when tried solve adding margin li element: .ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 14px; padding-bottom: 0px; } the problem fixed when last element selected, other tabs break layout when selected: so how solve this? issue seen in firefox, not 100% sure seems chrome unaffected. here minimum example: http://jsfiddle.net/gkt6bco6/3/ the issue caused because elements float left. if "clear:left" element wraps around, issue goes away. unfortunately, it's hard clear: left of element after selected 1 whenever selected 1 last on line in css. i found if take out float , change display inline-block, issue goes away. .ui-tabs .ui-tabs-nav li {

vbscript - VB Script to Delete Sub folders and files from a folder -

i have folder bunch of user folders , files in , need delete out of contents leave folders showing of names. the folder structure is: d:\users\aanderson\data\stuff d:\users\acarlson\data\stuff d:\users\banderson\data\stuff and want delete but: d:\users\aanderson\ d:\users\acarlson\ d:\users\banderson\ i tried couple different scripts pretty emptied entire folder (using test folders of course) from command line, easiest way is for /d %a in ("d:\users\*") (pushd "%~fa" && (rmdir . /s /q 2>nul & popd)) that is, each of subfolders, place lock in avoid removed. in case, lock pushd can not remove current working folder. so, same in vbscript option explicit dim shell, fso set shell = wscript.createobject("wscript.shell") set fso = wscript.createobject("scripting.filesystemobject") dim folder each folder in fso.getfolder("d:\users").subfolders shell.currentdirectory = fo

knockout.js - Knockout 3.2 applyBindings to new dom node -

i have searched, , found old answers this, , hacks manually clearing bidnigns, , calling applybindings... creating custom viewmodel isnt directly related anythign else , applying bindings after new dom nodes appear. my specific scenario bootstrap3 modal re-attaches after show called, , likewise none of items in modal still bound. i have model represents state/properties of dialog, i'd dialogviewmodel child of pageviewmodel. my question is, @ point in time, whats appropriate way this? there no way take node, attach viewmodel @ property? i using same tools (knockout , bootstrap3). how accomplish modals example: this div exists first element of body in index.html: <div class="modal fade" id="basemodal" tabindex="-1" role="dialog" aria-labelledby="basemodal" aria-hidden="true" data-backdrop="static" data-keyboard="false"> <div id="modalloading" class="ajax-

sql - detete rows after fetching the data from them -

i have table named auditrtailreference fetching data running following query select t3.destinationid input, t1.sourceid raw, t1.outtime::text, t6.destinationid out_file, t4.outtime::text out_time, t1.bytes inbytes, t6.bytes outbyte, t5.cdrs inputcdrs, t6.cdrs outputcdrs, t6.partial_cdrs, t6.duplicate_cdrs, t6.discarded_cdrs, t6.created_cdrs, t6.corrupted_cdrs, t6.created_files, t6.duplicate_files, t6.corrupted_files, t6.partial_files, t6.discarded_files, t6.empty_files auditrtailreference t1 left join auditrtailreference t2 on t2.sourceid = t1.destinationid , t2.event = '80' , t2.innodename 'sdp%_sftp' left join auditrtailreference t3 on t3.sourceid = t2.destinationid , t3.event = '68' left join auditrtailreference t4 on t4.sourceid = t3.destinationid , t4.event = '67' , ( t4.innodename 'sdp%_collector' or t4.innodename 'sdp%

ios - How to change a Button action with Segmented Control -

i have button has action gives push view. goal make button open different views according selected segment. example: have button called "request" , have control segment 2 segments, called "pizza salt" , "sweet pizza." when selected, example, "pizza salt" in segment , click "request" button, want open view menu of "salt pizza.", , selected "sweet pizza" want button open view menu of "sweet pizza." note: have 2 controllers ready views. what code use? my code: - (ibaction)changebuttoncode:(id)sender { if (_firstsegmentsixthview.selectedsegmentindex == 0); } - (ibaction)pushtonextview:(id)sender { } upon pressing request button: if (_firstsegmentsixthview.selectedsegmentindex == 0) //salty { viewcontroller1 *vc1 = [[viewcontroller1 alloc] init]; [self.navigationcontroller pushviewcontroller:vc animated:yes]; } else if (_firstsegmentsixthview.selectedsegmentindex == 1) //swe

apache - Chef set DocumentRoot in httpd recipe -

using https://community.opscode.com/cookbooks/httpd/versions/0.1.5 does know how set documentroot ? property ? i'm using httpd_service "default" listen_ports ['81'] action :create end which produces servername centos65x64 serverroot /etc/httpd pidfile /var/run/httpd/httpd.pid user apache group apache timeout 400 errorlog /var/log/httpd/error_log loglevel warn keepalive on maxkeepaliverequests 100 keepalivetimeout 5 defaulttype none hostnamelookups off listen 0.0.0.0:81 include conf.d/*.conf include conf.d/*.load in httpd.conf, i'm not sure how set docroot. the httpd_config resource included in cookbook deploy httpd config file template httpd instance's config directory, included when httpd run. can configure virtualhosts or main server these templates opposed say, setting node attribute cookbook picks , generates virtualhost you. this means can create erubis template virtualhost config. there of such config in cookbook t

Asp.net MVC: upload multiple image files? -

is there example of how upload multiple image files in asp.net mvc? know can use httppostedfilebase upload 1 file. there way upload multiple files clicking 1 button? i used file upload in ajaxtoolbox in webform before , how works. there similar way in mvc? or, there existing control can well? free control better, ok costs $. thanks use jquery plugin just include plugin js files, create tag: <input type='file' multiple id='fileupload' name="files[]" data-url="@url.action("upload","home")" /> (except ie9 not allowing select multiple files in select dialog) add javascript: $(function () { $('#fileupload').fileupload({ datatype: 'json', done: function (e, data) { $.each(data.result.files, function (index, file) { $('<p/>').text(file.name).appendto(document.body); }); } }); }); in controller action ch

sql - Android: SQLite query with multiple OR wildcard operators -

i working on app pulling data sql server using stored procedure in webservice. i'm dumping data sqlite database , running queries on database display in different list views in app. applying filter these views users have option of searching lists. field using primary key field contains ids not need views. therefore, using queries not display particular records when required. most of ids in categories , have similar names beginning letters can include in wildcard queries. way can include wildcard in query using not , or operators , not have include specific id names make query pretty long. code have below. the first method filter method ( public cursor fetchschedulebydate(string inputtext, string newconfdate) ). second method called when view displayed ( public cursor getallschedulesbyconfdate(string newconfdate) ). using multiple not , or operators in queries not working , results set indicates these statements being ignored. if use 1 not operator works. can't figure ou

control structure - Regular expression handling in elsif block in perl -

gmf file: tstartcustevsummrow_gprs custevsummrow_gprs gprs - subscriber package (paygo)|93452|mb|240|33952 custevsummrow_gprs gprs - mbb plan (paygo)|93452|mb|160|20128 tendcustevsummrow_gprs tstartcustevsummrow_gprs_simple custevsummrow_gprs_simple gprs - lte roam package|1529551|mb|85|260536 custevsummrow_gprs_simple gprs - lte roam package|65461|mb|20000|1309252 tendcustevsummrow_gprs_simple code: if ( $line =~ m/^(custevsummrow_simple|custevsummrow_gprs_simple|custevsummrow_gprs|custevsummrow|custprodsummrow)\s(.*?)\|.*\|(.*?)$/) { $tag = $1; $linetxt = $2; $amt = $3; if ( $tag =~ m/^(custevsummrow|custevsummrow_simple)/ ) { print "processing validations"; } else { print " mapping failed"; } elsif ( $tag =~ m/^(custevsummrow_gprs|custevsummrow_gprs_simple)/ ) { if () { #it has validations. } else { #failed; } } } when try process elseif condition

javascript - How to start plugin FullPage.js when browser window is resized from mobile to tablet and up? -

using fullpage.js, disabled plugin when window size lower 767px code below. works, when resize below 767px 960px, plugin doesn't work. can restart plugin after resizing? js: function fullpagescroll() { $('#main').fullpage({ navigation: true }); } var $win = $(window).width(); if ( $win > 767 ) { fullpagescroll(); } else { fullpagescroll(); $.fn.fullpage.destroy('all'); } because need apply on resize event: //first call when loading site doneresizing() var resizeid; //calling function again on resize can new width $(window).resize(function () { //in order call functions when resize finished cleartimeout(resizeid); resizeid = settimeout(doneresizing, 500); }); //your original code function doneresizing() { var $win = $(window).width(); if ($win > 767) { fullpagescroll(); } else { fullpagescroll(); $.fn.fullpage.destroy('all'); } }

python - Template doesn't exist on heroku, but does locally -

so tested project locally, , seems work perfectly. although, when pushed project heroku server, except 1 link didn't seem work. when requesting page, got templatedoesnotexist @ /locations/add/ error. once again, page works locally, how can page doesn't exist? here urls.py snippet: urlpatterns = patterns( '', url(r'^add/$', login_required(addlocation.as_view()), name="add_location"), ) the view: class addlocation(view): template_name = "dash/addlocation.html" form = locationform() def get(self, request, *args, **kwargs): user = user.objects.get(username=request.user.username) self.form.fields['existing_regions'].queryset = region.objects.filter(location__manager=user) return render(request, self.template_name, {'form': self.form}) and full traceback: traceback: file "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py"

ruby on rails - rspec `with` must have at least one argument. error after upgrade to 3.1.0 -

i upgrading our code base use rspec 3.1.0 , following docs here: https://relishapp.com/rspec/docs/upgrade one of existing tests following error after running transpec. " with must have @ least 1 argument. use no_args matcher set expectation of receiving no arguments." here test. 'does something' expect(my_method).to receive(:resource) .with { |path| path.include? 'test' }.and_return({}) end does new synatx not receive block anymore? this deprecated in version 2.99 , removed in rspec 3. can see details here: https://github.com/rspec/rspec-mocks/issues/377 . you can accomplish same test with: it 'does something' expect(my_object).to receive(:resource).with(/test/).and_return({}) end

java - How to solve coin change task when order does matters? -

as found in here , coin change problem of finding number of ways of making changes particular amount of cents, n, using given set of denominations d_1....d_m. general case of integer partition, , can solved dynamic programming. the problem typically asked as: if want make change n cents, , have infinite supply of each of s = { s_1, s_2,....., s_m } valued coins, how many ways can make change? (for simplicity's sake, order not matter.) i tried , works fine. how can modify find possible coin combinations when order of different coins matter . i.e. : before for example, n = 4,s = {1,2,3}, there 4 solutions: {1,1,1,1},{1,1,2},{2,2},{1,3}. now : for n = 4,s = {1,2,3}, there 7 solutions: {1,1,1,1},{1,1,2},{1,2,1},{2,1,1},{2,2},{1,3},{3,1} here {1,1,1,1} though 1 can pick 4 '1's in different order has considered 1 final combination. rather considering 4 coins different. order of different coins has different count separate combination. ex: {1,1,3} won't

logging - Suppress nginx access denied error log -

i have rules setup in nginx deny access ips. works great, each request denied ip, error starts following gets logged: [error] 7325#0: *5761 access forbidden rule, client... is there way suppress these "errors" being logged? you can set error_log less strict level, can lost important alerts in case. core functionality - error_log error_log filename crit;

c++ - Variadic Template Dispatcher -

i use variadic templates solve issue using va-args. basically, want call singular function, pass function "command" along variable list of arguments, dispatch arguments function. i've implemented using tried , true (but not type safe) va_list. here's attempt made @ doing using variadic templates. example doesn't compile below find out why... #include <iostream> using namespace std; typedef enum cmd_t { cmd_zero, cmd_one, cmd_two, } commands; int cmd0(double a, double b, double c) { cout << "cmd0 " << << ", " << b << ", " << c << endl; return 0; } int cmd1(int a, int b, int c) { cout << "cmd1 " << << ", " << b << ", " << c << endl; return 1; } template<typename... args> int dispatchcommand(commands cmd, args... args) { int stat = 0; switch (cmd) { case

html5 - box-api override embedded viewer to view html -

is there way share complex html file box? when share html5 file opens in embedded viewer , not rendered correctly. great if share file responsively rendered on devices without need on hosting site. for paid box.com accounts only, can use direct link outlined here: https://support.box.com/hc/en-us/articles/200519908-direct-linking unfortunately, complex html file you're describing, may not render anyway depending on browser/device, since file downloaded attachment , not viewed in browser via box.com.

javascript - Circle progress bar keeps looping -

i have circle progress script found here: http://www.jqueryscript.net/demo/animated-circular-progress-bar-with-jquery-canvas-circle-progress/ i added website, thing have these element around middle of page (not in view when page loads). intention show animation once user scrolls down position, effect keeps looping on every scroll. how can make run once when element gets on view , prevent looping and/or restart? here's code far: http://jsfiddle.net/1f58u1o5/1/ css .progressbar { display: inline-block; width: 100px; margin: 25px; } .circle { width: 100%; margin: 0 auto; margin-top: 10px; display: inline-block; position: relative; text-align: center; } .circle canvas { vertical-align: middle; } .circle div { position: absolute; top: 30px; left: 0; width: 100%; text-align: center; line-height: 40px; font-size: 20px; } .circle strong { font-style: normal; font-size: 0.6em; font-weight: normal; }

Django Python does not display the correct PDF file -

i have pdf files stored on server. writing code prompts users download pdf file. used following code: filename ="somepdf.pdf" filedir = "media/" filepath = os.path.join( filedir, filename ) pdf=open(filepath) response = httpresponse(pdf.read(),content_type='application/pdf') response['content-disposition'] = 'attachment;filename=%s' % filename return response for reason, rechecked pdf file prompted. pdf file not readable (corrupted file perhaps). do know happen? you have missed media_root: from settings import media_root ... filepath = os.path.join(media_root, filedir, filename)

Use a string (representing a logical operator) in a Python expression -

is possible somehow cast string of, say, or or and form recognizable logical operator? for example, possible this: l = [1, 2, 3, 4, 5] o = {item1:'or'} in l: if > 4 o[item1] < 0: print where o[item1] recognized valid or logical operator? you may use operator package: import operator o = {item1: operator.or_} if o[item1](i>4, i<0): ... note or_ not short-circuit, or does. if need short-circuit behaviour, can use eval (but in general not recommended).

ansible - Shutdown Current Vagrant Image inside the box -

i know can use vagrant up , vagrant destroy / vagrant halt start , stop box. however, have job running on vagrant take long time. , want add code @ end of python script totally blow away vagrant image running on after job finishes. i tried adding sudo shutdown now command end of code box still running can see virtualbox gui. can point me right direction how can terminate virtual machine totally within virtualmachine. (worst scenario, need write simple http service on host machine that, maybe when finishes, send terminate myself command route , host machine kill virtualbox outiside.) here post might gave more information trying do. thanks! --- # filename.yml - hosts: 127.0.0.1 connection: local gather_facts: no tasks: - name: shutdown localhost sudo: yes shell: "shutdown now" you can run file using ansible-playbook filename.yml , work )))

c# - Xamarin won't deploy app without crashing -

i've tested deployment test app hello world application , nothing deploy devices or vm. here output. app launches crashes. i'm not sure if i'm missing libraries or happening first day xamarin. help. forwarding debugger port 8891 detecting existing process loaded assembly: /storage/emulated/0/android/data/moodtracker_.moodtracker_/files/.__override__/moodtracker+.dll loaded assembly: mono.android.dll [external] [monodroid-debug] trying initialize debugger options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8891,server=y,embedding=1 [libc] warning: generic atexit() called legacy shared library [mono] image addref mscorlib[0x66ff49d8] -> mscorlib.dll[0x66ff4018]: 1 [mono] aot module 'mscorlib.dll.so' not found: dlopen failed: library "/data/data/moodtracker_.moodtracker_/lib/mscorlib.dll.so" not found [mono] assembly mscorlib[0x66ff49d8] added domain rootdomain, ref_count=1 [mono] assembly loader probing location: '/storage

java - Jetty.xml access static content -

i'm trying access static content on server war deployed using jetty.xml configuration. used resourcehandler, worked can't access website content anymore. tried adding defaulthandler still can't access content on "/". have add specific handler other requests? here's jetty.xml: <?xml version="1.0"?> <!doctype configure public "-//jetty//configure//en" "http://www.eclipse.org/jetty/configure.dtd"> <configure id="server" class="org.eclipse.jetty.server.server"> <set name="threadpool"> <new class="org.eclipse.jetty.util.thread.queuedthreadpool"> <set name="minthreads">10</set> <set name="maxthreads">200</set> <set name="detaileddump">false</set> </new> </set> <new id="sslcontextfactory" class="org.eclipse.jetty.http.

c# - How can I use Await Task.Delay without labeling all methods Async? -

i'm working on replacing old code uses threads .net 4.5 task based system. i've replaced threads tasks, next i'm working on replacing thread.sleep calls await task.delay. problems i'm having await can't called within synclock section , every method uses await task.delay instead needs labeled async. i can around synclock issue have few blocks of , can replaced better code. however, having label each method async causing problems. means have label method calls method async , on down chain. methods going async. is how should done when using task based approach or doing wrong? edit 1: posting example code public async function delay(milliseconds integer, optional initial boolean = false, optional silent boolean = false, optional modifier double = 0.3, _ optional task task = nothing, optional exitontaskstop boolean = true) tasks.task(of boolean) dim outputbufferkey string = nothing if task isnot nothing if task.s