Posts

Showing posts from February, 2010

matlab - plot dates on x-axis with gap of 6 months -

i have cell of shape 1 x 1358 contains dates in string format. daily data on approx 5 years. i have simple plot. on x-axis have dates not number or number of observations. want year , month shown , want label shown every 6 months. how do this? below have tried ax1 = figure(1); ax1.xtick = pdates; datetick(ax1,'x','yy-mmm','keepticks'); here error message error using datetick>parseinputs (line 325) incorrect arguments error in datetick (line 109) [axh,nin,ax,dateform,keep_ticks,keep_limits] = parseinputs(varargin); error in plot_variables (line 27) datetick(ax1,'x','yy-mmm','keepticks'); try may be ax1 = gca; %// obtain current axis-handle ax1.xtick = pdates; datetick(ax1,'x','yy-mmm','keepticks');

debian - Python multiprocessing behaves differently on several linux distributions -

i wrote scientific simulation environment using python 2.7. i start several instances of simulation @ same time directly using process interface: for in range(nr_cores): p = process(target=worker, args=(i, nr_cores, scheduler, job, nr_iter, return_values, extremes, parameters,)) processes.append(p) p.start() process in processes: process.join() this works flawlessly on my fedora 21 machine running python 2.7.8 (kernel 3.19.3) my osx machine running python 2.7.6 now tried install on debian 7.8 (kernel 3.2.63) machine python 2.7.3 , odd things started happen: the number of processes listed in top greater spawn (14 instead of 2) of these fourteen 2 running, rest sleeping the 2 running processes share 1 core. other cores idle i downloaded , compiled python 2.7.9 behavior same. i remember seeing similar issue on debian machine, unfortunately can't remember version was. has encountered before? thanks ok, found it. after poking aro

javascript - Tabs with dropdowns angular ui -

i trying create application angularjs, angular ui , bootstrap 3. need create new tabs on fly adding object array. <div ng-controller="personctrl"> <button ng-click="addperson()">add person</button> <button ng-click="removeperson()">remove person</button> <tabset> <tab ng-repeat="p in persons" heading="{{[p.name}}"> </div> </tab> </tabset> </div> instead of buttons add , remove want add dropdown tab end. see plunk... http://plnkr.co/edit/gtug3ucs2wzvezposiaj?p=preview look @ this example in plunker. may you. <div class="bs-example"> <ul class="nav nav-pills"> <li ng-repeat="p in persons"><a href="#">{{p.name}}</a></li> <li class="dropdown"> <a href="#" data-toggle="dropdown" class="dropdown-t

How to connect an android app with database? -

i beginner in android app development i'm planning bring website android app want connect app mysql database of website.tell me how that?? best way tat?? here have info topic: how connect android app mysql database? http://www.trustingeeks.com/connect-android-app-to-mysql-database/ using jdbc driver connect db: android + mysql using com.mysql.jdbc.driver not can find useful tips topic exact files changes.

agents jade - how to change java listening interface from localhost to IP address? -

as title mention, how can change java listening interface localhost ip address. since command netstat -tulpn shows: tcp 0 0 127.0.0.1:7778 0.0.0.0:* listen 23958/java i want change 127.0.0.1 example 192.168.1.1 without using sockets, example specify in java configuration files or in jade files. i want in order make port reachable allow migration of mobile agent remote machine machine. for have listener address other loopback/localhost address, there has available network interface listen on. if don't have additional network adapters on machine don't see how you're going accomplish task. if have additional network adapters, use networkinterface.getnetworkinterfaces() available adapters machine has offer , pick want want set listener to. this thread should give insight on getting available network adapters. how enumerate ip addresses of enabled nic cards java? if you're wanting use localhost listener, because have apps on

python 2.7 - replacing global variables with class -

hi beginner question here. i have written script works uses global variables (set input network, , used in different function change state) allow me change , acces content of variables several functions. understand global variables questionable looking replacing them class. is idea? is example of how can done in "correct" way?: class values1(object): def __init__(self): self.__height = 2.85 def set_height(self,height): self.__height =height def get_height(self): return self.__height val = values1() def print1(): print (val.get_height()) val.set_height(3.45) def print2(): print val.get_height() print1() print2()

c# - Unit testing DAL that requires authenticated user -

essentially, trying test action if particular user signed in , doing it. have interface implement on entities required auditing such public interface iauditableentity { datetime createddate { get; set; } string createdbyid{ get; set; } datetime updateddate { get; set; } string updatedbyid { get; set; } } in mvc project, i've overwritten savechanges() function in order automatically fill in fields above: public override int savechanges() { var modifiedentries = changetracker.entries() .where(x => x.entity iauditableentity && (x.state == system.data.entity.entitystate.added || x.state == system.data.entity.entitystate.modified)); foreach (var entry in modifiedentries) { iauditableentity entity = entry.entity iauditableentity; if (entity != null) { var identityname = (thread.currentprincipal claimsprincipal).findfirst(claimtypes.nameiden

How to get path to file under vendor in Symfony 2 -

i want parse ini file placed under vendor directory. how can path file? for example: in src/acme/testbundle/repository/userrepository.php have $file = parse_ini_file(file_path); how set file_path reach vendor/test/lib/conf.ini ? the other solution correct can shorter (plus should way go in current symfony version) : public function setup() { $rootdir = $this->container->getparameter('kernel.root_dir'); $filepath = $rootdir.'/../vendor/test/lib/conf.ini'; $file = parse_ini_file($filepath); ... }

symfony - Symfony2 ESI fragments add multiple session cookies -

i have page cached symfony gateway cache renders controllers using esi-tags. works fine except every rendered fragment seems add set-cookie header session id. seems session written several times, see lines write securitycontext in session [] [] populated securitycontext anonymous token [] [] several times (once per cookie) in log. using fosuserbundle , memcached session storage. since cookie stored in memcached, symfony opens connection every time quite annoying. any idea how around problem?

java - Find and use XML Configuration file with spring -

so have requirement spring filter there urls not need redirected, because introduced responsive design. i want have xml config this: <config> <pages> <url>/some/responsive/url/1</url> <url>/some/responsive/url/2</url> ... </pages> </config> and filter this: protected void dofilterinternal(httpservletrequest request, httpservletresponse response, filterchain filterchain) throws servletexception, ioexception { if(!isresponsiveurl(request.getservletpath())) { response.sendredirect(externalurl); //redirecto 3th party provide responsiveness return; } filterchain.dofilter(request, response); } i have resources folder want put xml, can me find way of reading xml , getting url list implement isresponsiveurl ? can spring find config file automatically, , how? i don't mind if file isn't xml, .properties file! the goal this, if need add more pages

python - Sort dict alphabetically -

this question has answer here: how sort dictionary key in numerical order python 3 answers my program can output every student's name , 3 scores dict in file, need sort data alphabetical order. how can sort names , scores alphabetically according surname? this code far: import pickle def clssa(): filename="friendlist.data" f=open('class6a.txt','rb') storedlist = pickle.load(f) key, value in storedlist.items(): sorted (key), value in storedlist.items() print (("{} --> {}").format(key, value)) use sorted keyword. for key, value in sorted(storedlist.items()): # etc how sort dictionary key in numerical order python https://wiki.python.org/moin/howto/sorting

.htaccess - Automatically redirect subdomain to folder path? -

is possible automatically redirect subdomains folder (structure)? want change setup of site subdomain folder , there lot of redirects done, wondering if there automatic solution. what want i.e.: subfolder1.domain.com to redirected (internal redirect, same top-level domain) www.domain.com/folder/subfolder1 where 'subfolder1' relative (not static). there general htaccess code can use? thanks you can put code in htaccess (which has in document root folder) rewriteengine on rewritecond %{http_host} ^((?!www\.).+?)\.(domain\.com)$ [nc] rewriterule ^(.*)$ http://www.%2/folder/%1/$1 [r=301,l] note: redirect in question, understood external redirect. if that's not case, i'll update answer edit (internal rewrite) rewriteengine on rewritecond %{http_host} ^((?!www\.).+?)\.domain\.com$ [nc] rewriterule ^((?!folder/).*)$ /folder/%1/$1 [l]

jsf - Updating column values in PrimeFaces datatable -

i have datatable contains items quoted on, , has columns quantity, unit price, etc , want display total price item when unit price entered. code looks this: <p:column styleclass="tdasheader" style="text-align:center" width="80" headertext="unit price"> <pe:inputnumber id="unitprice" value="#{quoteditem.quotedprice}" minvalue="0.01" maxvalue="999999999.99" decimalplaces="2" style="text-align: right;" size="10"> <p:ajax event="change" listener="#{supplierquotationbean.onamountchange}" process="@this" update="totalprice" /> <f:attribute name="quoteditem" value="#{quoteditem}" /> </pe:inputnumber> </p:column> <p:column styleclass="tdasheader" style="text-align:center" width="60" heade

In jQuery, what does "find('> span')" do? -

i don't understand find('> span') does. could please explain it? html code <button>ibis<span class="bg"><span>ibis</span></span></button> jquery code $(this).find('> span').animate( { width: '100%' } ); $(this).find('> span') finds span immediate child of this in example, finds <span class="bg"> , not <span> within <span class="bg"> jquery selectors work css selectors. writing button > span in css. gives immediate child span only. without > , writing button span in css, effect spans within <button> hth :) , welcome stackoverflow

java - Why does the JVM allow to set the "high" value for the IntegerCache, but not the "low"? -

we know java has cache integer (and other types) number in range [-128, 127] considered "commonly used". the cache designed follow : private static class integercache { static final int low = -128; static final int high; static final integer cache[]; static { // high value may configured property int h = 127; string integercachehighpropvalue = sun.misc.vm.getsavedproperty("java.lang.integer.integercache.high"); if (integercachehighpropvalue != null) { try { int = parseint(integercachehighpropvalue); = math.max(i, 127); // maximum array size integer.max_value h = math.min(i, integer.max_value - (-low) -1); } catch( numberformatexception nfe) { // if property cannot parsed int, ignore it. } } high = h; cache = new integer[(high - low) + 1]; int j = low

Excel VBA: Filter and copy from top 5 rows/cells -

Image
i have data table sorted on descending order in column f. need copy top 5 rows, data column a, b, d, , f (not headers). see pictures. sub top5() sheets("sheet1").select if (activesheet.autofiltermode , activesheet.filtermode) or activesheet.filtermode activesheet.showalldata end if activesheet.range("$a$4:$t$321").autofilter field:=3, criteria1:="dave" activeworkbook.worksheets("sheet1").autofilter.sort.sortfields. _ clear activeworkbook.worksheets("sheet1").autofilter.sort.sortfields.add _ key:=range("f4:f321"), sorton:=xlsortonvalues, order:=xldescending, _ dataoption:=xlsorttextasnumbers activeworkbook.worksheets("sheet1").autofilter.sort .header = xlyes .matchcase = false .orientation = xltoptobottom .sortmethod = xlpinyin .apply end ' copy-paste part supposed to, specific ' cells. not generalised , have repeat operation ' several times different people s

android - Where do I go to run this code -

i'm trying integrate mopub(ad network) android studio , i'm told run code. $my_project_dir $ mkdir mopub-sdk $my_project_dir $ cp -r $mopub_dir/mopub-android-sdk/mopub-sdk mopub-sdk i have no idea i'm suppose put this. can tell me? signing fabric isn't requirement. sounds you're following instructions https://dev.twitter.com/mopub/android/getting-started . open terminal, , execute commands in project directory: mkdir mopub-sdk cp -r $mopub_dir/mopub-android-sdk/mopub-sdk mopub-sdk

Error when attempting to pass bundle, Android -

i attempting pass selected items on list new activity. i declared arrayadapter arrayadapter madapter before oncreate; in onresume, collect data; , assign madapter //variable madapter //new arrayadapter string madapter = new arrayadapter<string>( searchingmidwife.this, android.r.layout.simple_list_item_checked, locations); //set list display madapter and have this, should allow for, when listitem clicked, selected items variable, , pass new activity protected void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); //in checked, in listview item positions checked items sparsebooleanarray checked = l.getcheckeditempositions(); //assign selected items new string arraylist arraylist<string> selecteditems = new arraylist<string>(); //determine size of items c

How to keep Android Button view in the buttom of the screen? -

Image
i have activity contains 2 components: scroll view , button. want place button @ buttom of screen, fixed. i tried many things cannot keep button location fixed @ button of screen, bacause content of scroll view increases, button pushed outside activity screen. i want achieve this: can tell me how achieve this? my xml file clean ( all custom views programmatically written, can't shared! ): <scrollview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/scrollview" android:layout_gravity="center_horizontal"> <linearlayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/editableviewgroup"></linearlayout> </scrollview> <button android:layout_width="fill_parent" android:layout_height=&q

ios - Weird Error when setting detailItem in DetailViewController from MasterViewController -

i started getting error randomly (may due updating swift) when reach, didset in detailitem, call configureview. in configureview check see if detailitem indeed set , start assigning values outlets. if let detail: posting = self.detailitem { print("detail title ") println(detail.title) // title self.titlelabel.text = detail.title however crashes output: detail title skiing in vail fatal error: unexpectedly found nil while unwrapping optional value the error on line: self.titlelabel.text = detail.title i don't understand why crashing when is set... note doesn't happen if call configureview within viewdidload. this happens when call var detailitem: posting? { didset { self.configureview() } } something i'm missing? working asynchronously or something? referencing comment on how implement this, there few trains of thought. first, reason can modify directly mastervc because iboutlet hasn't been i

python - Selenium element was not scrolled into the viewport when the element is "huge" -

Image
i'm doing unit test selenium webdriver python. when tried test clicking element on webpage, there error: ie: 11, windows-7 elementnotvisibleexception: message: point @ driver attempting click on element not scrolled viewport. even if tried move element vertically , horizontally in view. there still , error when click on element e.click() . searched online , found this, , changed e.click() webdriver.actionchains(driver).move_to_element(e).click(e).perform() . goes through, doesn't click, seems skip line. here code snippet: e = elems.find_element_by_xpath("//*[@id='scheditem_10262']/div[2]") # find sub-element elems xpath self.scroll_element_into_view(e) e.click() #webdriver.actionchains(driver).move_to_element(e).click(e).perform() def scroll_element_into_view(self, element): """scroll element view""" x = element.location['x'] self.driver.execute_script('window.scrollto({0}, 0)'.format(x))

actionscript 3 - Can't transfer to another frame after initial gotoAndStop(); -

Image
hello i'm trying make flash website that has menus. problem gotoandstop(); doesn't work after transferring frame making impossible select items in sub menu. here's i'm talking about. let's picked flash works, , goes frame, after can't select of items in second image though have event listener it. first image: second image: can't click on part. appears when click flash works. here's code. //this flash works button flashworks_btn.addeventlistener(mouseevent.click, goflashworks); function goflashworks(event:mouseevent):void{ gotoandstop(2); } //let's picked basic animation basicanimation_btn.addeventlistener(mouseevent.click, gobasicanimation); function gobasicanimation(event:mouseevent):void{ gotoandstop(10); } edit import flash.events.mouseevent; stop(); //homepage home_btn.addeventlistener(mouseevent.click, gohome); flashworks_btn.addeventlistener(mouseevent.click, goflashworks); aboutdev_btn.addeventlistener(mouseevent.

php - Facebook login request permission not now button -

in facebook api when have user login site using facebook sdk requests permissions user, depending on doing email, or users_friends requested. if user hits "not now" far can tell same hitting decline. there way make ask again if user hits not option? right user logs facebook, if hit not return nothing site (which fine handle that) if user hits login facebook again automatically fails them rather prompting accept or not again. anyway bypass this? or @ least alert user what's going on? as mentioned @cbroe, per documentation : it's ok ask person once grant app permissions they've declined. should have screen of education on why think should grant permission , re-ask. if use method described in previous section login dialog won't ask permission. this because once has declined permission, login dialog not re-ask them unless explicitly tell dialog you're re-asking declined permission. you can achieve passing auth_type: re

asp.net - Type or namespace could not be found AFTER Package is restored -

we struggling error our nuget packages when using tfs. team member add package , inevitably not found when pull it. in past, we've manually added packages stumbled upon package restore! awesome tool doesn't seem work expect. these steps have been taking when simple "enable package restore" , rebuilding doesn't fix it. delete nuget , packages folder solution. restart visual studio clean solution rebuild solution now, gets me there 90% of packages there still won't resolve. weird part is, i've looked in packages folder , see missing package installed after build/rebuild though still shows missing. so, barring better method these automatically restored, there way can force @ package location? i have seen too, long ago don't remember how solved. i check specific version listed in project matches version pulled down packages. no hint path or other magic applied assemblies, overridden in way in web/application config somewhere

java - android studio resourcebundle missingresourceexception -

i'm trying migrate eclipse android studio. after work got app build missingresourcefileexception. i have achievements.properties file in src folder of app. runs fine when build , run in eclipse. in android studio following exception: 04-14 21:02:09.657 16105-16152/com.bla e/androidruntime﹕ fatal exception: glthread 37579 process: com.streefgames.rotatris.android, pid: 16105 java.util.missingresourceexception: can't find resource bundle 'achievements_en', key '' @ java.util.resourcebundle.missingresourceexception(resourcebundle.java:238) @ java.util.resourcebundle.getbundle(resourcebundle.java:230) @ java.util.resourcebundle.getbundle(resourcebundle.java:159) @ com.streefgames.rotatris.helpers.stringresourcemanager.<init>(stringresourcemanager.java:18) i have tried moving resource file around, adding resource files make bundle, different locales , other things found. still not working. idea what's wrong?

javascript - how to use a Modal in my simple AngularJs controller -

i'm not able load modal service simple rookie angular controller example, i've included plunker below. can suggest i'm doing wrong? appreciated! thanks http://plnkr.co/edit/vvymsrmvg5dzeqpnvwsq?p=preview code snippet app.controller('maincontroller', ['$scope', 'fservice', 'angularmodalservice', function($scope, fservice, angularmodalservice) { $scope.show = function() { angularmodalservice.showmodal({ templateurl: 'modal.html', controller: "modalcontroller" }).then(function(modal) { modal.element.modal(); modal.close.then(function(result) { $scope.message = "you said " + result; }); }); }; } i found helpful. hope too. http://weblogs.asp.net/dwahlin/building-an-angularjs-modal-service

php - Codeigniter - adding multiple custom validation -

is possible add 2 or more custom validation functions using same field? $this->form_validation->set_rules('myfield', 'my field','required|my_method1|my_method2'); eg. my_method1 check string format , my_method2 check existence of string in database. seems first method works , second 1 ignored. because i'm using same parameter both functions? thanks. you can! in each my_method_n($x) function, must inform them prefix name callback_ , instance: callback_my_function1|callback_my_function2 . take @ question explains how can use multiple callback functions , syntax in manual. codeigniter form validation multiple callbacks http://www.codeigniter.com/user_guide/libraries/form_validation.html?highlight=form_validation#callbacks-your-own-validation-methods

Import Java library in Frege -

i'm trying out frege, , i'm struggling try use native java libraries. i'm trying out leiningen plugin, , joda time. apparently lein plugin doesn't take care of correctly seeting classpath fregec, or maybe it's related difference: java -jar ~/downloads/frege3.22.524-gcc99d7e.jar -fp ~/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar src/hello.fr will able find joda, expected, while java -cp ~/.m2/repository/joda-time/joda-time/2.7/joda-time-2.7.jar -jar ~/downloads/frege3.22.524-gcc99d7e.jar src/hello.fr will fail `org.joda.time.years` not known java class this shouldn't happen since, according the wiki the current class path of running jvm plus target directory on class path. still, after manually setting -fp , code fails compile: module hello data jodayears = native org.joda.time.years pure native years :: int -> jodayears pure native getyears org.joda.time.years.getyears :: jodayears -> int --

python - Sanitize input in Django Rest Framework -

if send like { "description": "hello world <script>alert('hacked');</script>" } to django rest framework view, want rid of the script tags. is there convenient way this, not involve overwriting things , add strip_tags ? what else sanitize input? did overread section in drf docs or isn't covered? ignore answers here, terrible. use bleach . won't every edge case. the situation use library in. client has control of client side definition.

Basic php Login form with defined Name and Password -

i beginner in php programming . have been trying create basic login form fixed username , password in if loop , first time run program warning if-else loop cant figure out runs perfectly. want show error below submit when enter wrong password or username . cant figure out how . <html> <head> <style> #login { position:absolute; top: 30%; bottom: 30%; left:30%; right:30%; margin: 0px auto; width:auto; height:600px; } </style> </head> <body> <?php echo"<center>"; echo"<div id=\"login\">"; echo"<form method=\"post\">"; echo"<b>username</b> <input type =\"text\" name=\"username\">"; echo"<br/><br/>"; echo"<b>password</b>&nbsp;<input type =\"password\" name=\"password\">"; echo"<br/><br/>"; echo"&l

Trim contour lines over map plot in Matlab -

i plotted set of contour lines , on them, shapefile map shape similar ones found here . f = triscatteredinterp(x,y,z); [qx, qy] = meshgrid(1:.01:10,1:.01:10); qz = f(qx, qy); contour(qx, qy, qz, 10); hold on; plot([shp.x],[shp.y],'k'); axis equal however, since countour defined on square region goes outside limits of map (shapefile), doesn't nice. is there way can cut/trim/hide contour lines fall outside limits of map have contour lines contained within map? thanks! you can use axis keyword constrain limits of contour plot. if these limits shape data ought let crop image required: xmin = min(min(shp.x)); xmax = max(max(shp.x); ymin = min(min(shp.y)); ymax = max(max(shp.y)); axis([xmin, xmax, ymin, ymax]); alternatively may find clipping option contour sufficient. update: above clip contour plot bounding box of shapefile, if want contours show inside shape it's touch more complicated. you'd want create rectangular patch size of desired

Is there a limit to the number of @extend i can use in Sass? -

i have encountered strange problem, use @extend .opensans-light; on class , refused extend class .opensans-light. no error occurred when inspected element check if extended or not noticed not added list of elements in .opensans-light class. .opensans-light { font-family: 'open sans', arial, sans-serif; font-weight: 300; } the @extend working till when noticed use @extend on same class on 100 times. question is, there limit number of times can use @extend or have different problem ?

java - Attempting to reference non-static field with non-static method results in error -

i have created class, obstacle, obstacle constructor , function. package environment; import static java.lang.system.out; import environment.worldenvironment; public class obstacle { private string obstacletype, setobstacletype; private int obstaclesize, obstaclexcoord, obstacleycoord, setobstaclesize, setobstaclexcoord, setobstacleycoord; public obstacle(string gettype, int getsize, int getxcoord, int getycoord){ obstacletype = gettype; obstaclesize = getsize; obstaclexcoord = getxcoord; obstacleycoord = getycoord; } public void generateobstacle(int getplayercurrentxcoord, int getplayercurrentycoord){//code in generateobstacle} in main method, call generateobstacle() different class (note both class , obstacle class within same package). import environment.obstacle; public void main(string[] args){ spawnplayer(); while(rungame){ //one example of calling obstacle member variables , calling generateobstacle() switc

javascript - Linking to chrome://history through extension -

i'm working on chrome extension injects few buttons onto page via content script , , have button links history page (chrome://history). this opens blank tab no url: window.open("chrome://history", "_blank"); and having hyperlink history page directly give me error: <a href="chrome://history" target="_blank">...</a> not allowed load local resource: chrome://history/ chrome's extension api doesn't have chrome://* listed supported scheme extension pages, explains error, want provide link history page. there way this, if it's little (or lot) convoluted? thanks! edit: added done through content script, didn't clarify in initial post. wolf war's answer correct, however, content script additional step needed. you need background (or better, event ) page process request, since content scripts can't call api. need use messaging : // content script // element dom element element.a

multithreading - Implementing the calculator program using lisp -

i'm implementing calculator program using concurrent lisp programming language..everything working fine..but want print thread executing , particular function..however i'm able list of thread using list-all-threads function...please suggest me how it.. following code output:: (defvar a) // defines var not initialises (defvar b) (defvar c) (defvar d) (write-line " enter 2 numbers in binary format prefix #b : ") // gives newline afterwords (setf (read)) /* setf macro uses setq internally, has more possibilities. in way it's more general assignment operator.*/ (setf b(read)) (sb-thread:make-thread(lambda()(progn (sleep 4)(setf c(+ b)) (print "addition in binary: ") (format t " ~b" c ) (print "addition in decimal: ") (print c) ) ) ) (sb-thread:make-thread(lambda()(progn(sleep 2)(setf

Remove end of filename using PowerShell -

is possible use powershell remove end of filename of files in folder? examples: moira_by_kr0npr1nz-d8poqdb.jpg shining_eye___step_by_step_by_ryky-d8pp6xh.jpg redemption___the_hunters_by_danluvisiart-d8oy1ef.jpg so want remove "by" ".jpg". how using regex replace so: get-childitem -filter "*.jpg" | % { rename-item $_.fullname -newname ($_.fullname -replace '_by_.*\.jpg$', '') } if regex doesn't find match file name left unchanged.

java - Window type can not be changed after the window is added -

i'm trying make custom lock screen. so, there need not allow user press home button. in beginning write public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.lock_screen); getwindow().addflags(windowmanager.layoutparams.flag_keep_screen_on |windowmanager.layoutparams.flag_show_when_locked); then override onkeydown @override public boolean onkeydown(int keycode, android.view.keyevent event) { if ((keycode == keyevent.keycode_volume_down)||(keycode == keyevent.keycode_power)||(keycode == keyevent.keycode_volume_up)||(keycode == keyevent.keycode_camera)) { //this can stuff return true; //because handled event } if((keycode == keyevent.keycode_home)){ return true; } return false; } here override onattachetowindow @override public void onattachedtowindow() { this.getwindow().settype(windowmanager.layoutparams.type_keyguard_dialog); super.onattachedtowindow(); } but

python - Class function not accepting self. variable -

i trying create function in class rotating rotors in enigma machine. however, when try tell rotor use not accept it, demonstrated in code below: from collections import deque class rotors: def __init__(self): self.a = deque("abcdefghijklmnopqrstuvwxyz") self.vi = deque("jpgvoumfyqbenhzrdkasxlictw") self.vii = deque("nzjhgrcxmyswboufaivlpekqdt") self.viii = deque("fkqhtlxocbjspdzramewniuygv") self.rotor_vi = [self.a, self.vi] self.rotor_vii = [self.a, self.vii] self.rotor_viii = [self.a, self.viii] self.rotors = [self.rotor_vi, self.rotor_vii, self.rotor_viii] self.reflector = deque("fvpjiaoyedrzxwgctkuqsbnmhl") def rotate_rotor(self, rotor): rotor.rotate(1) x = rotors() x.rotate_rotor(self.vi) which gives output of: traceback (most recent call last): file "c:\users\aaron\documents\programs\enigma.py", line 20, i

image - Sitefinity cannot add RelatedMedia with content type -

i having issues adding relatedmedia field type content type inside module. issue isn't when add field, when try , edit/create content , says: content type cannot selected because module or source providing content deleted or deactivated. there field called profileimage of type media seems working fine. i've read media pre sitefinity 7.0 , relatedmedia 7.0 , above. i looked through of other sites on setup, , of other content types have relatedmedia field types set , working. have looked @ this g+ page not sure if culprit. we running sitefinity 7.2.5310.0. when set related media had choice provider if didn't select "default site source" see why wouldn't able find media items. make sure set "default site source" provider if want access sites media, or select proper provider site if using on 1 multisite, make sure enable module on site well

python - Generating a list with foating point values -

this question has answer here: is floating point math broken? 20 answers i wish generate list these value: [0,0.01,0.02...0.49] and though correct way it: [0.01*i in range(50)] but horror observed following: >>> 35*0.01 0.35000000000000003 >>> float("0.35") 0.35 what doing wrong? if understand correctly seems 35*0.01 not give closest floating point representation of 0.35 float("0.35") does. to guarantee nearest valid floating point number, need start values exact. 0.01 isn't exact, 100.0 is. [i/100.0 in range(50)]

javascript - jQuery function which fires dialog not being found -

below fiddle attempts fire dialog truncated text when href selected : <a href='javascript:void(0)' id="truncatedtext" onclick='fnopennormaldialog("this text truncate");return false'></a> $(function(){ $("#truncatedtext").text(truncatetext('truncate text')); }) function truncatetext(text) { var shorttext = jquery.trim(text).substring(0, 20) .split(" ").slice(0, -1).join(" ") + "..."; console.log(shorttext) return shorttext } function fnopennormaldialog(text) { $("#dialog-confirm").html("confirm dialog box"); // define dialog , properties. $("#dialog-confirm").dialog({ resizable: false, modal: true, title: "modal", height: 250, width: 400, buttons: { "yes": function () { $(this).dialog('close'); callback(true);

PostScript: Fixing rounding error in floating point number -

i trying make axis tick marks labeled numbers. working fine except last number generated axis 0.099999 instead of 0.01. have removed line drawing parts code below, left part generates numbers. these numbers below code: 1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.09999999 (should 0.01). there anyway round numbers or calculate numbers different way avoid rounding error? /str 10 string def /count 0 def /totalunits 1 def /ticks 0.1 def totalunits ticks neg 0 { /loopnum exch def loopnum 10 str cvrs /stringnumber exch def % string representing number /count count 0.1 add def } as commented, can use integers avoid quirk of floating-point numbers. /str 10 string def /count 0 def /scaling .1 def 10 -1 1{ scaling mul 10 string cvs %dup = /stringnumber exch def /count count 1 add def } this same rounding issue affects languages use binary floating-point representation numbers since fraction 1/10 has repeatinging pattern in binary representation.

sql server - TSQL Select Clause with Case Statement -

i have basic select statement getting me list of types stored in database: select tetype bs_trainingevent_types source = @source xml path ('options'), type, elements, root ('types') my table contains type column , source column. there record in table need include 2 separate sources can't create separate record it. **table data** type | source test users test2 members test3 admins i need case statement able if source = admins give me type test2 . does make sense , possible basic select? update came temp solution still think there better way handle this.: declare @tmp table ( qid varchar (10)); insert @tmp (qid) select distinct qid tfs_adhocpermissions; select t.qid, emp.firstname, emp.lastname, emp.ntid, (select accesskey tfs_adhocpermissions p p.qid = t.qid xml path ('key'), type, elements, root ('keys')) @tmp t left outer join

c - Could someone explain how fork works? -

Image
i don't understand how fork() works.i understand examples 1 fork,but when there more 1 call don't.i have example , prints 4 lines of hello, how many processes created? int main(void) { fork(); fork(); printf("hello\n"); return 0; } after fork() call, both processes (original , spawned) continue execute next line of code. both processes execute second fork() instruction, in end have 4 processes. hence see 4 instances of "hello" lines printed. one picture worth thousand words:

php - Laravel views - passing multiple arrays to a view -

within laravel app, pass list of jobs completed view , send on number of messages have been sent job: public function index() { $jobs = $this->job->getusersownjobs(auth::id()); $jobid = $jobs['id']; // example of i'm trying $count = $this->message->model->wherehas('conversation.job', function($q) use ($jobid) { $q->where('id', $jobid); }) ->count(); return view('myjobs.index', compact('jobs', 'count')); } my database structured when user clicks on job , sends message, row in conversation table created holds id of job (my detailed schema can found here: http://www.laravelsd.com/share/8nbzmc ) the count function should dependent on id of job, however, how pass on id $jobs array, $count variable, load views? should using view composers though appear in 1 view? edit: trying list jobs in view , display next them, respective messages count it's n

java - Adding headers to CORBA messages? -

i'm working in java application using corba, , able insert special headers messages when these messages sent client service (so these headers checked @ server). there way accomplish this? closest thing got interceptors i'm not sure whether add headers messages. the portable solution corba portable interceptors, see example this article high level information

javascript - Dynamically loaded video source is aborted in IE -

i have script loads sources video works great in chrome, ff , safari. in ie however, source "aborted" in networks tab. here code: <div id="video_wrapper"> <video muted controls="false" autoplay poster="/videos/home.jpg" preload="none" loop id="bg_video"> <img src="/videos/home.jpg" alt="your browser not support html5 video."> </video> documentobj.on('ready', function() { insertvideo(); }); function insertvideo() { if (windowobj.width() > 767) { settimeout(function() { var video = $("video")[0]; insertsource("/videos/home.webm", 'video/webm'); insertsource("/videos/home.mp4", "video/mp4"); video.play(); }, 50); } else { $("video").remove(); } } function insertsource(src, type) { var source = document.createelement('source&

html - What is the meaning of this tag: <t>lorem ipsum</t> -

the template page http://www.blacktie.co/demo/kelvin contains tag haven't seen before: <t>email</t> the corresponding css styles this: #footwrap t {font-weight: 700;} i'm curious significance of <t> . it's not listed @ http://htmldog.com/reference/htmltags or other lists can find. is custom html tag? i've read custom elements (eg http://www.html5rocks.com/en/tutorials/webcomponents/customelements ) need call document.registerelement() or document.createelement() doesn't seem case here. is code semantically correct, or should written as: <span class="t">email</span> #footwrap .t {font-weight: 700;} yes, <t> tag custom element. while custom tags can useful, if want them supported in browsers, have register element js: var ttag = document.registerelement('t'); more custom tags here answer question, coding not valid, unless have registered element browser javascript. sometimes, eas

Display variable content, not variable name in Ruby on Rails -

i want customize message end user can modify welcome message. like: welcome #{userinfo["name"]}, out latest member where userinfo["name"] variable. i store message on model column called welcomemsj . then trying display message using model. like: messages = model.first puts messages.welcomemessage i have output like: welcome #{userinfo["name"]}, out latest member but want display: welcome emmanuel, out latest member what's correct syntax this? thanks in advance. the liquid template engine created kind of use case. have backend user include special string in double curly braces such {{name}} populate @ render time. example, backend user set welcome message " welcome {{name}}, our latest member. " stored in database. assuming current_user variable represents user that's logged in, render customized message following code: template = liquid::template.parse(messages.welcomemessage) templat

javascript - How to make a div be to the right of selected element? -

Image
i have 2 panels, left , right. once user hovers mouse on elements of right panel, new div (called box) should visible right of hovered element. i design it, problem width fixed position of popup panel changes based on size of screen. not work on jsfiddle did not put there, however, complete code provided works fine in browser. please notice both panels in 'container'. even if screen size changed red box should stay on right panel. (where shown in screen shots) red box wont shown mobile devices due small screen. positions left panel right panel element1 |box1 element2 |box2 the box elements overlap right panel. code <!doctype html> <html lang="en"> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/li