Posts

Showing posts from July, 2012

php - Create new folder on upload based on date -

i'm new php , i've written script upload files server appended integer. now, i'm trying adjust script create new folder , name based on date when file uploaded. i think know need do, i'm struggling syntax. php: if(!empty($_files)) { $temp = $_files['file']['tmp_name']; $dir_separator = directory_separator; $folder = "uploads"; $uploaddate = date("m-d-y"); if(!is_dir($uploaddate)) mkdir($uploaddate); $destination_path = dirname(__file__).$dir_separator.$folder.$dir_separator; $target_path = $destination_path.(rand(10000, 99999)."_".$_files['file']['name']); move_uploaded_file($temp, $target_path); } any appreciated! thanks. you should create $destination_path variable first, create folder afterwards. like: $uploaddate = date("m-d-y"); $destination_path = dirname(__file__).$dir_separator.$folder.$dir_separator.$uploaddate.$dir_separator; if...

r - dplyr mutate replace dynamic variable name -

this question has answer here: dplyr string column reference 2 answers the following code replaces values of hwy > 25 1 otherwise 0. library(ggplot2) data(mpg) mpg %>% mutate(hwybin=replace(hwy>25,1,0)) how replace hwy variable name. along lines of: varname <- "hwy" mpg %>% mutate(hwybin=replace(varname>25,1,0)) i feel i'm missing obvious. thank you. might turn comment answer (and make question reproducible): library(dplyr) library(ggplot2) library(lazyeval) data(mpg) <- mpg %>% mutate(hwybin=replace(hwy>25, 1 ,0)) varname <- "hwy" b <- mpg %>% mutate_(hwybin=interp(~replace(varname>25, 1 ,0), varname=as.name(varname))) identical(a, b) ## [1] true

Magento Media URL stripping all forward slashes -

Image
on dev box have noticed in text attributes media encased urls eg: <img src="{{media url="wysiwyg/diagram/bigpool.jpg"}}"/> are being displayed on front end <img src="{{media url="wysiwyg diagram bigpool.jpg"}}"/> and breaking image links. playing around {{skin url & {{ base url yields same results. urls outside of working fine. to clarify saving correctly in database (with slashes) rendering in browser without breaking image. i've hardcoded url without {{media url=""}} , render fine. has run problem before or ideas on causing this? google , se not being helpful! the dev box running nginx, hhvm & magento ce 1.9.2 cheers. magento url hhvm share | improve question edited aug 27 '15 @ 4:23 ...

mysql - Overwrite default values from source table using union -

in table, have few specific keys , few generic keys. specific data can got combining specific key column values on top of generic key column values. specific key | generic key | col1 | col2 | null | generic key 1 | defaultval1 | default val2 | specific key1 | generic key 1 | null | specific val2 | in case specific record should need like, specific key1 | generic key 1 | defaultval1 | specific val2| i trying achieve using union statement, but, overwriting null value specific key1 on top of generic defaultval1. hence columns overwritten on top of generic records when not null. if columns of specific record null, want retain default value. edit: i tried provide info simple possible, looks attracts more downvotes. here trying explain schema bit further: i have 2 tables namely ids_link, core_params ids_link table contents: unique key : specificid | globalid | specificid | type | | gid1 | sid1 | type1 | | gid1 | sid2 | type2...

javascript - Bluebird Map on HashMap/Obj -

i'm using bluebird library asynchronous calls in javascript. noticed there's map function can apply asynchronous function each element in array. however, want use method on object has keys. there way this? there many way convert object array : object.keys(yourobject).map(function(key){ return yourobject[key] }) you can use promise.map too

python - Getting py2exe to Include (Selenium) .json Files in .zip -

i have spent day trying solve py2exe not including required selenium files (webdriver.xpi , webdriver_pref.json) in .exe's library.zip or inside .exe seems encountered many people before. i have researched many similar questions , have tried adapt provided answers no avail (such here , here ). have learnt manually transferring files after running py2exe not work suggest some. my current setup.py looks (although have had many variants similar, none of worked) from distutils.core import setup import py2exe wd_base = 'c:\\python34\\lib\\site-packages\\selenium\\webdriver' requireddatafiles = [ ('selenium/webdriver/firefox', ['%s\\firefox\\webdriver.xpi'%(wd_base), '%s\\firefox\\webdriver_prefs.json'%(wd_base)]) ] setup( console=['test.py'], data_files=requireddatafiles, options={ "py2exe":{ "skip_archive": true, "unbuffered": true, ...

R - Permutations between 2 or more vectors, with constraints -

i generate possible permutations between 2 or more vectors, but; order important. the first number must lesser second, , second must lesser third. there cannot same number. for instance: a <- c(3, 5, 8) b <- c(8, 10, 12) c <- c(12, 15, 20) the first element a , second b , third c . possible results be: (3, 8, 12), (3, 8, 15), (3, 8, 20), (3, 10, 12), (3, 10, 15) , (3, 10, 20). but there shouldn't results repeated numbers, instance: (8, 8, 12), (8, 12, 12). how can accomplished using r? if understand rules correctly, should work. a <- c(3, 5, 8) b <- c(8, 10, 12) c <- c(12, 15, 20) f <- function(x,y) lapply(y[y>tail(x,1)], function(zz) c(x,zz)) g <- function(x,y) unlist(lapply(x,f,y=y), recursive=false) do.call(rbind,g(g(a,b),c)) # [,1] [,2] [,3] # [1,] 3 8 12 # [2,] 3 8 15 # [3,] 3 8 20 # [4,] 3 10 12 # [5,] 3 10 15 # [6,] 3 10 20 # [7,] 3 12 15...

SQL Server restore differential without original full backup -

here situation: had full backup, , differential backup. have restored full backup database. accidentally lost backup file. now apply differential backup. must restore both full backup, , differential, without opening db use (norecovery option). however, have opened db, not made updates. we have made new full backup, should identical original full backup, except @ least timestamp. is, sql server detects differential not taken db full backup. is there way trick sql server allowing differential work new full backup? (i realize risky, data important , willing risk errors.) is there other way updates out of differential backup applied manually? there "decoder" differential backup file? special recovery tools kind of situation? you can try restoring diff. norecovery mode: restore database diff_db disk='m:\diff_db.bak' norecovery then bring database online running below restore database diff_db recovery if doesn't helpful can try a...

ios - How do i add more text field to this code so it could connect to the email and so it could be sent -

i need how add more textfield name code info textfield goes email composer thing. nsstring *message = [[self name]text]; if have many textfields , want add text inside them 1 nsstring following : nsmutablestring * string = [nsmutablestring new] ; [string appendstring:textfield1.text] ; [string appendstring:textfield2.text] ; [string appendstring:textfield3.text] ; where textfield1 , textfield2 textfields

css - Setting max-width on an input element -

today tried setting max-width: 200px on <input type="text"> apparently gets ignored browsers. if set width: 200px gets applied (but doesn't resized if input field gets resized smaller 200px. how apply max-width css property input fields? if set max-width:200px; have set width in relative unit %. because if set width:200px site of input not going change; this example //copy , paste , run in browser <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title></title> <link rel="stylesheet" href=""> <style type="text/css" media="screen"> div{ background-color: tomato; width: 100%; max-width: 1024px; margin: auto; } input{ margin: auto; background-color: red; display: block; margin-bottom: 2rem;...

The best way to initialize multiple Objects of the one Class in C# -

i have app people can enter details console, details stored object, problem don't know how many needed initialization needs happen dynamically. have decided use list right thing use? if not pointers in right direction great. list fine, assuming object called "inputdata" following public list<inputdata> inputlist = new list<inputdata>(); public void builder() { string input = console.readline(); inputdata id = new inputdata(input); inputlist.add(id); } then can iterate through data @ later point foreach foreach(inputdata in inputlist) { i.dosomething; } not sure if wanting do, let me know fi have more specific query

android - Search for two strings at once in java -

so on basic level there way (maybe using operator) string or 1 within same variable declaration. (maybe array). i've tried operators such pipe , & , doesn't work single string variable input. have tried putting strings array , using string value of array no avail. thank you elements names= doc.body().getelementscontainingowntext("mr."); (element web2: names) { log.i("names", web2.text()); } i want check "ms." @ same time because sequence matters in instance. way jsoup sdk 1.8.3. you can use method getelementsmatchingowntext(string regex) . so match mr. or ms. query like, elements names= doc.body().getelementsmatchingowntext("mr\\.|ms\\."); // escape . in regex.

javascript - JQuery for Touch Slideshow in Chrome and LightCMS -

ok, need use light cms client's site, having issue slideshows on touch devices. touch important site , need operate in chrome. want touch images scroll next , can't figure out. know little jquery. set basic example page how slideshows run in cms. have googled weeks , exhausted self on this. if can me figure out appreciate it! slideshowexample.publishpath.com

SQLite EF Design time tools for Visual Studio 2015 doesn't work -

i use system.data.sqlite https://system.data.sqlite.org/downloads/1.0.98.0/sqlite-netfx46-setup-bundle-x86-2015-1.0.98.0.exe . have c# project vs2013 ef6 edmx model , latest system.data.sqlite nuget package can't update model design time tool. decide generate new 1 sqlite database. can add sqlite connection in entity data model wizard can't proceed next step. wizard quit , leave nothing. how can fix issue? some time throwing kind of problem better go ef5 edmx model . than may work.

embedded - RTC calibration in energy meter IC 71M6541F -

how calibrate rtc of energy meter ic 71m6541f? here details: i working on above mentioned soc on smart meter project. using 32.768 khz frequency getting accurate time without mismatch global time. in crystal there small deviation undergoing 2 4 second difference in real time in 24 hours of time. how rectify problem? the problem affordable crystals have deviation. typical values 30 ppm. and each crystal has own deviation need calibrate each system or need external sync mechanism.

ibm bluemix - Database script encounterd "AWKDBE018E Cannot access required JDBC Driver folder" in Workload Scheduler -

Image
i create step of database script access sql database service in workload scheduler service. when run process, step encountered error below. error message awkdbe018e cannot access required jdbc driver folder message information http://www-01.ibm.com/support/knowledgecenter/ssgspn_9.2.0/com.ibm.tivoli.itws.doc_9.2/common/src_ms/awsmsawkdbe.htm?lang=en awkdbe018e cannot access required jdbc driver folder explanation job not able access jdbc driver folder, might not have enough permissions. system action operation not performed. operator response verify have enough permissions. this message seems ask me grant proper authority job user. there no property specify job user of workload automation agent. use workload automation agent provisioned bluemix automatically. could teach me parameters needed ? database script step information jdbc driver class path info checked path following "ls -lr" command step's log. it...

python - What is the default if I install virtualenv using pip and pip3 respectively? -

i used sudo pip install virtualenv , when run virtualenv env in directory, python 2 virtual enviroment. if use 'pip3 install virtualenv' install virtualenv again, override previous installation of virtualenv, when run virtualenv env , python 3 virtual enviroment? or install new virtualenv in different name virtualenv3 in different place ? you don't need go lengths. can use python 2's virtualenv create python 3 virtual environment. supposing have python 3's binary installed @ /usr/local/bin/python3 run virtualenv -p /usr/local/bin/python3 env and find that source env/bin/activate gives python 3 environment want.

python - WxPython wxSplitterWindow.SplitVertically always shows uneven split -

Image
i'm trying understand how use wxsplitterwindow class can't seem vertical split (i.e. left , right panes each take same amount of space). according wxpython 3.03 documentation, wxsplitterwindow.splitvertically has following signature: splitvertically(self, window1, window2, sashposition=0) the last parameter sashposition has following description: sashposition - initial position of sash. if value positive, specifies size of left pane. if negative, absolute value gives size of right pane. finally, specify 0 (default) choose default position (half of total window width). from description, gather passing 0 sashposition splits window in half left , right panes taking equal space. however, when run following example program, window uneven split of left panel hidden. import wx class splitterframe(wx.frame): def __init__(self): wx.frame.__init__(self, none, title='splitterwindow example') # create main splitter window (to split vertically...

c# - Passing a list to aview in asp mvc : List vs IEnumerable -

just quick question. @using mvcapplication6.models; @model ienumerable<employee> @{ viewbag.title = "index"; } <h2>index</h2> <p> @html.actionlink("create new record", "create") </p> <p>@html.actionlink("check departments", "index", "department")</p> <table border="1"> <tr> <th> @html.displaynamefor(model => model.id) </th> <th> @html.displaynamefor(model => model.firstname) </th> <th> @html.displaynamefor(model => model.lastname) </th> <th> @html.displaynamefor(model => model.gender) </th> <th> @html.displaynamefor(model => model.department) </th> <th>action</th> </tr> @foreach (employee item in mod...

python - Creating a dask dataframe from a list of HDF5 files -

what correct way go creating dask.dataframe list of hdf5 files? want dataframe dsets = [h5py.file(fn)['/data'] fn in sorted(glob('myfiles.*.hdf5')] arrays = [da.from_array(dset, chunks=(1000, 1000)) dset in dsets] x = da.stack(arrays, axis=0) briefly if individual files can read pd.read_hdf can dd.read_hdf , dd.concat . import dask.dataframe dd dfs = [dd.read_hdf(fn, '/data') fn in sorted(glob('myfiles.*.hdf5')] df = dd.concat(dfs) but useful (and easy) support idiom within dd.read_hdf directly. i've created an issue , try in next couple of days.

javascript - Recursively check for property on prototype and delete it from prototype if it exists -

i trying write code delete property in object. if inherited, must go chain , delete itfrom ancestor. far have come (doesnot work): // objects: var pro = {'a':1}; var pro2 = object.create(pro); var pro3 = object.create(pro2); // ----------------------------------------------------- function deleteprop(obj, prop){ console.log(obj,prop) //get own properties var ownprop = object.getownpropertynames(obj); for(var i=0 ;i <ownprop.length; i++){ if (prop === ownprop[i]){ delete obj.ownprop[i]; } else{ //get parent var parent = object.getprototypeof(obj); console.log(parent); while (object.getprototypeof(parent)!== object.prototype){ //recursive call deleteprop(parent, prop); } } } } you don't need recursion here--a simple wh...

php - How to refresh parent page form a child page in javaScript -

i wondering if there way refresh parent page page originated from. for example have parent.php page have javascript function opens child.php using javascript: parent.php <input type="submit" value="new page" onclick="createchild()" > <script> function createchild() { mywindow = open('child.php', '', 'menubar=no, width=450, height=550'); } </script> in child page want have javascript function refresh parennt.php somehow not working. child.php <script> function refreshhome() { mywindow.window.location.href = mywindow.window.location; } </script> when click refresh home button nothing happens. know if it's possible , if yes doing wrong? you can parent window object using window.opener or opener. to refresh parent window, try following: funcion refreshhome() { opener.location.reload(); or opener.location.h...

android - JSONObject or JSONArray -

i have data on string, i'm having trouble access individual data. code: log.d("detail outputss", "" + response.tostring()); and string output: {"futsal_id":"45","info":[{"futsal_id":"45","futsal_name":"kathmandu futsal","city":"kathmandu","address":"kathmandu","owner_name":"hari prasad","owner_address":"kathmandu","email":"kathmandufutsal@gmail.com","password":"kathmandu","phone_no":"1111111","mobile_no":"9841112233","status":"1"}],"description":[{"futsal_id":"45","futsal_desc":"futsal fever never ends.\r\nkathmandu futsal - platform, medium of communication our fraternity. not somewhere host challenges or seek venues, place can share , spread luv! here, can fin...

http status code 404 - I have disabled products in magento which are showing 404 not found crawling error -

i have disabled products in magento showing 404 not found crawling error,i want remove crawling errors seo when try visit disabled product in magento shows 404 error. in order open product details correctly must mark product enabled.

win universal app - How to customize the the POLL UI and Announcement UI in Windows 8.1 app using C# and xaml? -

Image
i have implemented me in windows universal 8.1 app. when create announcement or poll appears in black screen in app below. but want change ui per requirements. how can change this? anybody please me sample code. thanks in advance we don't have sample find place customize appearance on client side in "resources" folder of sdk in windows app solution. 1) use html/engagementnotification.html & overlay/engagementoverlaynotification.xaml change base notification shows when set campaign server side. can add company logo/branding, images, change size, orientation etc. 2) use html/engagementannouncement.html & overlay/engagementoverlayannouncement.xaml change subsequent announcement gets displayed in form of poll or text or web announcement. again can change , feel etc. if sending web announcement service can specify html in content of announcement html content send service gets merged html have customized on client , presented such. hope helps....

javascript - if previous page url with “-cn” ending then change content in current page -

i making site in both english , chinese language, need detect if previous page url "-cn" ending (so know chinese page) change content in current page(default in english). thank you. code below, sorry i'm new js $(document).ready(function() { var referrer = document.referrer; //*detect if previous url without "-cn"ending nothing if "-cn" below //*change content inside "new"<div class="block"></div> }); <div class="block">old</div> try one: think want this. $(document).ready(function() { var referrer = document.referrer; if(referrer.indexof("-cn")>-1) { // referrer url contain "-cn" } else { // not contain "-cn" } });

xcode - iOS Build failed with IOException -

i started unity since few days , want run game snake on ipad. on ios builds, following error: ioexception: failed copy file / directory 'temp/stagingarea/trampoline/unity-iphone.xcodeproj/project.pbxproj' '/users/markusunger/desktop/snake-ios/snake-ios/unity-iphone.xcodeproj/project.pbxproj'. unityeditor.ios.utils.replacefileordirectorycopy (system.string src, system.string dst) unityeditor.ios.postprocessiphoneplayer.updateinstalllocation (unityeditor.ios.projectpaths paths, scriptingimplementation backend, buildoptions options, unityeditor.ios.includedfilelist includedfiles) unityeditor.ios.postprocessiphoneplayer.postprocess (unityeditor.ios.iosbuildpostprocessor pp, buildtarget target, system.string stagingareadata, system.string stagingarea, system.string stagingareadatamanaged, system.string playerpackage, system.string installpath, system.string companyname, system.string productname, buildoptions options, unityeditor.runtimeclassregistry usedclassregistry)...

Jquery Ajax call in a loop -

i need make call server , batches of 50 records back. need untill i've had records. can out of this var stillrecordsavailable = true; var start = 1; while (stillrecordsavailable) { // next batch of records $.ajax({ url: '/getdata?start='+start+'&recordlimit=50', type: 'get', success: function(data) { if(data.records == 0){ stillrecordsavailable = false; } else{ start += 50; // } }, error: function(data) { // nothing left stillrecordsavailable = false; } }); try using recursion, call same method until records. // next batch of records var callserver = function() { $.ajax({ url: '/getrecords.json', data: { data_set_id: dataset.id }, type: 'get', success: function(data) { if (data.records != 0) { callserver();//make ajax call again next records. } //...

Pax-Exam issue with TestNG Integration -

i tried integrate pax-exam plugin testng , ended getting following error. working fine junit. [org.ops4j.pax.exam.spi.intern.defaulttestaddress] : new address= paxexam-90b1718e-7414-486a-8ae2-b5628e4b7a67 parent=[testaddress:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99 root:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99] root=[testaddress:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99 root:paxexam-ea9b0dd3-b693-4efb-8003-7f6b92b05f99] args=[ljava.lang.object;@4f063c0a [org.ops4j.pax.exam.spi.intern.defaulttestaddress] : new address= paxexam-652d3b11-ab7c-49d0-bcba-f9d56c9210ee parent=[testaddress:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855 root:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855] root=[testaddress:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855 root:paxexam-806e1a66-76ff-44cf-90d9-ff26b658b855] args=[ljava.lang.object;@1e6d1014 org.apache.maven.surefire.util.surefirereflectionexception: java.lang.reflect.invocationtargetexception; nested exception java.lang.reflect.invocation...

python - Boto issues listing AWS instances with no-tags -

i use custom tags aws instances. trying list instances (running , stopped) in csv file. not being programmer, searched , copied/pasted codes , came script runs well. have noticed if 1 tag missing script throws error , stops right there. if tag created empty, script prints blank space, if tag not created @ script stops. example if tag owner missing throws error keyerror: 'owner' , stops there. script pasted below. can let me know changes need make if tag not exist, script prints out n/a instead of stopping. #!/usr/bin/env python import boto.ec2 boto.ec2 import ec2connection csv_file = open('/home/sbasnet/scripts/instances/instances_east.csv','w+') def process_instance_list(connection): map(build_instance_list,connection.get_all_instances()) def build_instance_list(reservation): map(write_instances,reservation.instances) def write_instances(instance): if (instance.platform == 'windows'): platform = 'windows' els...

python - Access a parent class' property getter from the child class -

i'm attempting set test caching tool in cache based on function object , arguments. test, need access exact function being called in property, , can't figure out how this. the caching code looks this: def cached(func): """ decorator cache function calls """ @wraps(func) def wrapper(self, *args): # cache lives in instance gets garbage collected if (func, args) not in self._cache: self._cache[(func, args)] = func(self, *args) return self._cache[(func, args)] return wrapper and have cached property: class spatialmixin(object): @property @cached def longitude_extrema(self): return 25 the class looks this: class mainclass(someotherbaseclass,spatialmixin): pass myobject = mainclass() i can access base_class.spatialmixin.longitude_extrema.fget directly, different object myobject.longitude_extrema.fget (which i'm using indicate getter of property...

ruby on rails - ActionController::UnknownFormat in htmltoword gem -

i using htmltoword gem here https://github.com/karnov/htmltoword , followed steps that. here error when running controller error is actioncontroller::unknownformat in htmltopdfccontroller#show my controller code class htmltopdfccontroller < applicationcontroller def show respond_to |format| format.docx file = htmltoword::document.create params[:docx_html_source], "file_name.docx" send_file file.path, :disposition => "attachment" end end end end help me out.

java - Parse delete object from listview android -

i'm using parse on app send pushes other users has app. want user able remove added friend list. i've managed modify code, deletes first item on list. how can modify delete selected user? @override public void onpositive(materialdialog dialog) { parsequery<parseobject> query = parsequery.getquery("friend"); query.whereequalto("user", mcurrentuser); query.findinbackground(new findcallback<parseobject>() { @override public void done(list<parseobject> list, parseexception e) { if (list.size() != 0) log.v("tag", "sizzzze" + list.size()); //showing 1 list.get(0).deleteinbackground(new deletecallback() { @override ...