Posts

Showing posts from March, 2011

ios - UIImagePickerController cannot push camera button in landscape mode -

i want solution problem. problem app cannot take picture in landscape mode. i use uiimagepickercontroller in app. , in portrait mode, it's okey in landscape mode, cannot push camera button , cancel button. if rotate portrait mode, can push buttons. plz let me know solution~ thanks~ iphone 6 plus ios8.3 -> landscape, portrait both okey iphone 5 ios8.1.2 -> landscape no, portrait okey iphone 5s ios 8.1 -> landscape no, portrait okey the code part call uiimagepickercontroller uiimagepickercontroller *imagepickcontroller=[[uiimagepickercontroller alloc]init]; imagepickcontroller.sourcetype=uiimagepickercontrollersourcetypecamera; imagepickcontroller.delegate=self; imagepickcontroller.allowsediting=true; [((ffwebviewcontroller*)[uiviewcontroller currentviewcontroller]) presentmodalviewcontroller:imagepickcontroller animated:yes]; i solve problem. it's ios version issue. i update 8.1.1 -> 8.3 , 8.1 -> 8.3 then, can take picture in lands...

windows - Error changing permissions id_rsa (ssh) -

i trying make ssh connection between windows 8 , raspberry pi. i generate public ssh key command ssh-keygen -t rsa -n '' , saved in folder /cygdrive/c/users/user/.ssh . then, transfer file id_rsa.pub authorized_keys in raspberry. when try connect again, says: permissions 0660 '/cygdrive/c/users/user/.ssh/id_rsa' open. in order correct it, use chgrp -r user .ssh , chmod 0600 .ssh/* , error persists. if try change permission chmod 0400 .ssh/* , error is: permissions 0440 '/cygdrive/c/users/user/.ssh/id_rsa' open. i don't know why setting same permission want user group. i trying correct error days , not solve yet.

ms access 2010 - How is this form bound? -

we working ms access database (2010) front-end sql server database. one of programmers has created form bound linked table. my problem this: all of controls unbound, , yet filled data query. how can be? don't it. wonder if kind of form created query made wizard? [update] i discover if remove record source form of controls dissappear , have table view! what "thing" called? this isn't way want work; can convert normal form or have rebuild scratch? the form's vba possibly calls ado or dao recordset via odbc sql server database , attaches form's recordsource or leaves form unbound , sets values each control corresponding fields in recordset. view code behind form in vba module. alternatively, pass-through query may ran , bound form. this tougher route in connecting frontend backend systems must bypass of access' default features, commands, , functionality. using unbound forms, developer must create custom update, insert, save, ...

How to make a delay in assembly for 8051 microcontrollers? -

i having problem in calculating delays. want make delay 0.5 sec when using 1mhz clock speed 8051 microcontroller. i use proteus simulation , avr studio coding in assembly atmel microcontroller. for example code 8mhz clock microcontroller delay_15ms: ldi dly1, 120 ; delay1: ldi dly2, 250 ; delay2: dec dly2 ; nop ; brne delay2 ; dec dly1 ; brne delay1 ; ret can teach me how calculate time delay take? make 1 0.5 sec delay @ 1 mhz thank you 0,5 s eternity in life of (even slow) microcontroller. do realize not able while waiting ? ( called passive wait ) phil wetzel gave in comment link post describing interrupts. that's need. it require read datasheet know how configure clocking system, how configure timer, how set , write interrupt timer... however answer question ( if code snippet correct (?) ): 15 ms timeout on 8 mhz system realize 120 times second loop (delay2). so have 8 times slower system want wait...

In javascript is there really a good reason to never check for boolean true || false such as if(var){}else{}? -

i isn't duplicate please bear me. i check boolean true||false using if() matter of course in programming. i've programmed extensively in php, in c# asp.net, bit in java, long time ago in c++, & dabled in few others. checking boolean true||false has been pretty straightforward (as far tell). in javascript i've heard, read, , otherwise been told it's bad. instead of: if(var){}else{} i should instead do: if(typeof(var) !== 'undefined' || typeof(var) !== null || var !== ''){}else{} i've been dabbler in javascript until last 6 months when i've been getting steeped in it. after getting tired of writing & re-writing long version of boolean test shown above asked friend who's done extensive js development years. friend supported i'd read, should never test boolean true or false way i'm used to. however, after discussion have stronger belief if(var){}else{} fine in js works intuitively expect ( my jsfiddle testing this ) ...

windows runtime - How do I do bindings in ItemContainerStyle in WinRT? -

i'm trying bind collection itemscontrol, canvas items panel, , each item's canvas.left , top bound properties on item objects. i'm trying re-create 2-d databinding described in this post on blog , time in winrt instead of wpf. since itemscontrol wraps itemtemplate content in ui element (a contentpresenter, in case of winrt), , it's wrapper/container elements placed directly inside items panel, left , top have set on containers; can't set them in datatemplate. in wpf, it's easy enough bindings in itemcontainerstyle, e.g.: <itemscontrol.itemcontainerstyle> <style> <setter property="canvas.left" value="{binding path=x}"/> <setter property="canvas.top" value="{binding path=y}"/> </style> </itemscontrol.itemcontainerstyle> but when try same thing in winrt/xaml project, nothing. not binding errors. if hard-code value, works; if use binding, property stays @ d...

c# - WebAPI OData $Skip on custom IQueryable double applied -

i have implemented custom iqueryable exposed via webapi odata endpoint. structure of controller's get() rather standard: [enablequery( allowedqueryoptions = allowedqueryoptions.count | allowedqueryoptions.filter | allowedqueryoptions.orderby | allowedqueryoptions.skip | allowedqueryoptions.top)] [odataroute] public pageresult<foo> get(odataqueryoptions<foo> queryoptions) { var bars = new queryabledata<foo>(_provider); var result = ((iqueryable<foo>)queryoptions .applyto(bars, new odataquerysettings(new odataquerysettings { enableconstantparameterization = false, ensurestableordering = false }))).tolist(); var count = _provider.count; return new pageresult<foo>(result, null, count); } the odd behavior seeing, odata $skip in query string applied after pageresult returned. example: if query string c...

ruby - Rails 4.2: Unknown Attribute or Server Error in Log -

i have form select_tag , options_from_collection_for_select can't seem pass. in view, when upload id set uploadzip_id 302 redirect , when it's set uploadzip_ids , unknown attribute error. i'm bit confused have relationship set along foreign key. have model checkboxes called uploadpdf works fine. here set up.. class campaign < activerecord::base has_one :uploadzip end class uploadzip < activerecord::base belongs_to :campaign end db/schema.rb create_table "campaigns", force: :cascade |t| t.string "name" t.text "comment" t.datetime "created_at", null: false t.datetime "updated_at", null: false create_table "uploadzips", force: :cascade |t| t.string "file_name" t.string "file_type" t.datetime "date" t.integer "size" t.integer "pages" t.string "file_ident" t.string ...

java - After the codehaus closure what the new location for : http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd ? -

we have xml file refer ' http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd ', gone. current sub using : https://raw.githubusercontent.com/stoicflame/enunciate/master/top/src/main/resources/meta-inf/enunciate-1.27.xsd what ideal long term location file ? new schema location: http://enunciate.webcohesion.com/schemas/enunciate-1.27.xsd source: commit on june 10, 2015. https://github.com/stoicflame/enunciate/commit/7fbd78fa928430079469170bc107f01d1feabfe0

c - Low Level IO with Crypt -

i trying compare encrypted string taken each line of file aaaa-zzzz until finds match of password. guaranteed user password of 4 characters. trying take in file using lowlevel io , output new file decrypted passwords of each line. not best @ c programming yet please gentle. need direction on how create array or list going aaaa way zzzz , comparing each decrypted version of file line. how decrypt file line line , save char [] how compare each line char [] until password found for example: if line $1$6gmkiope$i.zkp2evrxhdmapzyov.b. , next line $1$pkmkicve$wqfqztnmcqr7fqsnq7k2p0. assuming resulting password after decryption absz , taze new file result absz on first line , taze second line. this have far: #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> void pdie(const char *); void die(const char *); #define buffer_size 1024 int main(void) { char *pass; ...

server - How can you upgrade Azure Upgrade A-Series VM to D-Series VM? -

the recent information find while scouring net post 6 months old (back toward original deployment of d-series servers). how can seamlessly upgrade a-series azure vm d-series azure vm without huge headache? to find out sizes available in region (and see instancesize naming sceheme use in powershell) use powershell cmdlet: get-azurelocation | where-object {$_.displayname.contains("<your-region>")} view virtualmachinerolesizes property see sizes have access to. to update vm can use following set of commands: get-azurevm -servicename <cloudservice> -name <vmname> | set-azurevmsize -instancesize <sizevalue> | update-azurevm if run above command on running vm restarted in order provision on right host infrastructure support desired series.

python - Numpy: Multidimensional index. Row by row with no loop -

i have nx2x2x2 array called a. have nx2 array called b, tells me position of last 2 dimensions of in interested. getting nx2 array, either using loop (as in c in code below) or using list comprehension (as in d in code below). want know whether there time gains vectorization, and, if so, how vectorize task. my current approach vectorization (e in code below), using b index each submatrix of a, not return want. want e return same c or d. input: a=np.reshape(np.arange(0,32),(4,2,2,2)) print("a") print(a) b=np.concatenate((np.array([0,1,0,1])[:,np.newaxis],np.array([1,1,0,0])[:,np.newaxis]),axis=1) print("b") print(b) c=np.empty(shape=(4,2)) n in range(0, 4): c[n,:]=a[n,:,b[n,0],b[n,1]] print("c") print(c) d = np.array([a[n,:,b[n,0],b[n,1]] n in range(0, 4)]) print("d") print(d) e=a[:,:,b[:,0],b[:,1]] print("e") print(e) output: a [[[[ 0 1] [ 2 3]] [[ 4 5] [ 6 7]]] [[[ 8 9] [10 11]] [[12 13] [14 ...

multithreading - Multiple TCP sockets in C -

does have guidance on how 1 should go opening many sockets, listening on them, , doing send/receive on each? i'm looking @ 3 high level options make thread per connection make single thread connections don't split connection handling out of main thread i'm making mail server program , can't find best practices on subject. nor can find wisdom on pros/cons of each of above options.

ruby - appending to rails field value -

i need find , update number of records in rails 3.2, ruby 2 application. following code finds records want. need though add " x" (including space) email address of every user , can't figure out how it. this finds records user.joins(:account) .where("users.account_id not in (?)", [1955, 3083, 3869]) .where("accounts.partner_id in (?)", [23,50]) .where("users.staff = '0'") .where("users.admin = '0'") .where("users.api_user = '0'") .where("users.partner_id null") .update_all(email: :email.to_s << " x") but it's last line i'm having problems with. possible, or need find records way? the update_all method updates collection of records, unless write own sql expression, can set 1 value. example, if wanted overwrite email addresses "x", easily: user.joins(:account) .where("users.account_id not in (?)", [1955, 3083, 3...

php - Two forms, one submit - Symfony2 -

i need put 2 different forms on same page , submit send these forms @ once. here action: public function crearusuarioaction() { $newuser = new user(); $formuser = $this->createform(new usertype(), $newuser); $newdatos = new datos(); $formdatos = $this->createform(new datostype(), $newdatos); return $this->render('atajobundle:ingresarvalores:crearusuario.html.twig', array('formuser' => $formuser->createview(), 'formdatos' => $formdatos->createview())); } in template twig have show these 2 forms, 1 submit button , , send save after corresponding tables. form_start thought if pass array 2 official forms did not. here 's try: {% block content %} {{ form_start(array(formuser, formdatos)) }} {{ form_errors(array(formuser, formdatos)) }} <div class="contactotexto">{{ form_label(formuser.usuario) }}</div> <div class="contactocampo">{{ form_widget(formuser.usuario) }}</di...

c++ - Show certain image from image sprite -

Image
i have wrote class responsible image buttons handling: #include "imagebutton.h" imagebutton::imagebutton() { // main constructor } imagebutton::imagebutton(wxwindow* parent, const wxstring& buttonpath) : wxstaticbitmap(parent, wxid_any, wxbitmap(buttonpath, wxbitmap_type_png), wxpoint(0, 0), wxdefaultsize) { refresh(); } imagebutton::~imagebutton() { // ... } this beginning , basic. however, have found out there no possibility resize image (not changing it's dimensions). this how image looks like: what i'd achieve right here tell wxstaticbitmap display one close square button @ time (so make mouse over/click event handlers it). setting it's size won't work here , thats not want. is possible crop image @ dimensions in situation? you can create 2 images it. 1 of ways use wximage::resize (first make copy of original image). second way use wxbitmap::getsubbitmap (you need convert wximage wxbitmap - can done simpl...

multithreading - SQL server force multitheading when executing SSIS package -

here question: using visualcron run ssis package on sql server 2008 r2. ssis package run query millions of rows , output flat file. sometimes, found when run ssis package, sql server doesn't use multi-threading(i can tell activity monitor) , lead long running time 20 hours. but, if using multi-threading done in 8 minutes. is there way force sql server use multi-threading whenever running ssis package? there few options optimizing query handle multiple simultaneous operations... or @ least improving performance. apply option maxdop in query apply maximum number of processors (parallelism) available operating system. listed below example , here link more detail. select firstname, lastname dbo.customer option (maxdop 1) apply nolock in query if there no concern data in tables being updated during ssis package operation. is, works if there no concern "dirty reads." see following link , example. select firstname, lastname dbo.customer with(nolock)...

api - Using RestSharp to get image response from Cloud Sight C# -

i want call api called cloud sight provides image recognition. i want response describes image url of image provided api cloud sight. this code have far var client = new restclient ("http://api.cloudsightapi.com/image_request"); var request = new restrequest("http://cdn.head-fi.org/c/c8/1000x500px-c8c39533_beats-by-dre-studio.jpg", method.post); request.addheader ("cloudsight", [api key here]); irestresponse response = client.execute(request); var content = response.content; console.writeline (content); i error says {"status":"404","error":"not found"} the documentation cloud sight not insightful each individual language, unsure if calling correctly, particularly, addheader part. it may error not waiting response. code executes , api example cloud sight provides on website takes 10-15 seconds. any ideas how go getting api working restsharp? just guess, have tried method.get instead of ...

c# - NLog file not writing -

i've been trying build app use nlog log file. code basic, not seeming work. have ideas? i've set correct things "copy always" well, in question. nlog doen't work on iis code below. main (including using statements show using them) using system; using system.io; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.net; using system.configuration; using newtonsoft.json; using newtonsoft.json.linq; using nlog; class program { static void main(string[] args) { var logger = logmanager.getcurrentclasslogger(); logger.debug("xxxx"); } nlog.config <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/nlog.xsd" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"> <targets> <target name="file" xsi:type="file" layout="${longdate} ${l...

c# - What is the correct path to call a ASP.net controller method from JavaScript? -

Image
perhaps because things in asp.net work automagically, can't seem access method in controller javascript properly. keeps saying resource not found. i have js file in /scripts/wizards/wizard.js function getsum() { $.get("/infrastructure/base/getjsonecatalogs/"); return false; } getsum(); the controller trying reference basecontroller in /infrastructure/basecontroller.cs has method: public string getjsonecatalogs() { // ... return jsonstring } the method returns json-formatted string need use later in javascript. don't have use $.get if not necessary, thought easiest (should use ajax ?). how can json string controller?

8086 MOV instruction error while using a constant value and memory location as operands, -

i trying use instruction mov [si],00h in 8086 assembly language. masm assembler gave me error saying: operand must have size . unable understand reason behind it. also, syntax allowed? because while comparing memory location's content constant value, got same error again. i'm new 8086 programming, it's hard figure out. masm complains because can not know kind of data @ address pointed @ si register. byte or word ? that's why have provide size tag. mov byte ptr [si], 0 or mov word ptr [si], 0

c - Confusion regarding a printf statement -

so running code #include<stdio.h> int add(int x, int y) { return printf("%*c%*c",x ,' ',y,' '); } int main() { printf("sum = %d", add(3,4)); return 0; } and can't seem understand how following statement works return printf("%*c%*c",x ,' ',y,' '); so tried writing simple code int x=3; printf("%*c",x); and got weird special character (some spaces before it) output printf("%*c",x,' '); i getting no output. have no idea happening? please help. thank you. this code int x=3; printf("%*c",x,'a'); makes use of minimum character width can set each input parameter printf . what above print out a character, specifies minimum width x characters - output a character preceded 2 spaces. the * specifier tells printf width of part of output string formed input parameter x characters minimum width x must passed additional argument prior v...

PHP uploading files using <input> multiple Attribute -

i'm having several <input type="file" fields uploading images. want convert input fields 1 single field using html multiple attribute. my working code multiple input fields: <input type="file" name="popup_images_1"> <input type="file" name="popup_images_2"> <input type="file" name="popup_images_3">... ($i = 1; $i <= 3; $i++) { if (is_uploaded_file($_files['popup_images_' . $i]['tmp_name'])) { $products_image = new upload('popup_images_' . $i); $products_image->set_destination(dir_fs_catalog_images); if ($products_image->parse() && $products_image->save()) { $products_image_name = $products_image->filename; // database stuff } } } my new code, not working, single input field: <input type="file" name="popup_images[]" multiple="multiple"> $num_files = count($http_...

ios - UIAlertView delay or not showing -

i have used uialertview several times without problems time can't make work correctly. (simple) code following: - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { alert = [[uialertview alloc]initwithtitle:@"" message:[nsstring stringwithformat: @"reload data ?"] delegate:self cancelbuttontitle:@"yes" otherbuttontitles:@"cancel", nil]; [alert show]; nslog(@"executed"); } if touch in row of tableview have 2 different behaviours: the alertview shown after (6/7) seconds the alertview not shown. in case, touch in point of screen alert shown immediately. in both cases, [alert show] executed after first touch because see "executed" in log screen. before , after alert, application not doing else. any ? try this [[nso...

python - Unmasking an element by assignment in a 2D numpy MaskedArray -

with 1 dimensional numpy maskedarray can assign element unmasks array: in [183]: x = np.ma.maskedarray(data=np.zeros((2),dtype=float),mask=true) in [184]: x[0] = 9 in [185]: x out[185]: masked_array(data = [9.0 --], mask = [false true], fill_value = 1e+20) with 2 dimensional array, assigning single value not unmask array: in [186]: x = np.ma.maskedarray(data=np.zeros((2,2),dtype=float),mask=true) in [187]: x[0][0] = 9 in [188]: x out[188]: masked_array(data = [[-- --] [-- --]], mask = [[ true true] [ true true]], fill_value = 1e+20) if assign slice, slice gets unmasked in [189]: x[0] = 9 in [190]: x out[190]: masked_array(data = [[9.0 9.0] [-- --]], mask = [[false false] [ true true]], fill_value = 1e+20) how can assign single value unmask it? x[0, 0] = 9 it looks when execute x[0][0] = 9 , numpy decouples x[0] temporary's mask x 's mask, assignment unmasks x[0] temporary. relevant...

php - WordPress pagination returns 1 post when it should return 10 -

i have 4 queries on first page. every section works perfect excepts portfolio section. want show 10 posts on portfolio section query shows 1 post. $args = array( 'post_type' => 'project-portfolio', 'numberposts' => 10 ); $the_query = new wp_query ($args); if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); wp_title(); endwhile; else: endif; wp_reset_query(); i don't believe numberposts valid parameter wp_query (as not mentioned in codex page wp_query), believe posts_per_page you're looking for. according wordpress codex wp_query page posts_per_page (int) - number of post show per page (available version 2.1, replaced showposts parameter). use 'posts_per_page'=>-1 show posts (the 'offset' parameter ignored -1 value). set 'paged' parameter if pagination off after using parameter. note: if query in feed, wordpress overwrites parameter stored '...

linux - CLI command to list only the third party softwares installed on Ubuntu and FreeBSD -

is there cli command list third party softwares installed on ubuntu , freebsd? i need compare softwares installed on linux(ubuntu) on freebsd. any or clue appreciated. you can use rpm command display installed packages in linux. red hat/fedora core/centos linux rpm -qa | less debian linux dpkg --get-selections ubuntu linux sudo dpkg --get-selections freebsd pkg_info | less pkg_info apache use pkg_version command summarizes versions of installed packages: pkg_version | less pkg_version | grep 'lsof' openbsd - openbsd use pkg_info command display list of installed packages or software: pkg_info | less pkg_info apache

oracle10g - XPage jdbcRowSet + repeat control: In place changes not persisted in Oracle 10 DB -

i trying create “endless form”, user can edit rdbms table's column values directly in form (i.e. without opening separate “edit form” allows edit single row). using xpages repeat control bound jdbcrowset accesses simple person table in oracle 10 db (id number primary key, first/last name, plus additional columns not exposed in form). displaying data , editing works expected, persisting changes db fails persistently, without error message. in source code below 1 can see ways have tried tell data source save changes made, no avail. (using same code notes datasource works expected , persists changes). how jdbcrowset persist changes in form ? thanks in advance help, martin <xp:view xmlns:xp=“http://www.ibm.com/xsp/core” xmlns:xe="http://www.ibm.com/xsp/coreex"> <xp:this.data> <!-- <xp:dominoview var="view1ld" viewname="authorview"></xp:dominoview> --> <xe:jdbcrowset var="view1" connectionna...

Python MemoryError on a small forloop -

i'm having issue small loop. i'm trying create list of columns in excel sheet , use following code: import string col_list = list(string.ascii_uppercase) in col_list: = 'a' + col_list.append(a) print col_list i following error: traceback (most recent call last): file ".../table.py", line 5, in <module> = 'a' + memoryerror the output want list goes ['a', 'b', 'c', ... , 'ax', 'az'] could please me understand going on here? thank you. you adding list loop on it, loop never ends. try making copy of list: for in list(col_list): = 'a' + col_list.append(a)

python - Most efficient way to remove multiple substrings from string? -

what's efficient method remove list of substrings string? i'd cleaner, quicker way following: words = 'word1 word2 word3 word4, word5' replace_list = ['word1', 'word3', 'word5'] def remove_multiple_strings(cur_string, replace_list): cur_word in replace_list: cur_string = cur_string.replace(cur_word, '') return cur_string remove_multiple_strings(words, replace_list) regex: >>> import re >>> re.sub(r'|'.join(map(re.escape, replace_list)), '', words) ' word2 word4, ' the above one-liner not fast string.replace version, shorter: >>> words = ' '.join([hashlib.sha1(str(random.random())).hexdigest()[:10] _ in xrange(10000)]) >>> replace_list = words.split()[:1000] >>> random.shuffle(replace_list) >>> %timeit remove_multiple_strings(words, replace_list) 10 loops, best of 3: 49.4 ms per loop >>> %timeit re.sub(r'|...

Matlab saving figure with file name containing variables -

i have no idea how save file when name contains variables. a = figure(); % code filename = sprintf('sig1=%d mu1 =%d p1=%.2f sig2 = %d mu2 = %d p2 = %.2f', ... sigma1, mi1, double(p1), sigma2, mi2, double(p2)); print(a, filename, '-dpng'); i got work: a = figure; plot(1:10,sin(pi*(1:10)./4)) filename = sprintf('sig1=%d mu1 =%d p1=%.2f sig2 = %d mu2 = %d p2 = %.2f.png', ... 1, 2, double(3), 4, 5, double(6)); print(a, filename, '-dpng'); the png file opened fine. when want png file name have variables in it, correct approach. can set lot more figure specifications using figure handle ("a", in case) , set(a,...) function. @ matlab documentation using set(a,...) function , gcf . if type get(a) , see list of properties can set before save figure. please let me know if helps.

windows - Batch file to process csv document to add space in postcode field -

i have csv file populated name, address, , postcode. large number of postcodes not have required space in between e.g lu79gh should lu7 9gh , w13tp should w1 3tp. need add space in each postcode field if not there already, space should before last 3 characters. what best way solve via windows command line? many thanks you can for /f follows: @echo off setlocal enabledelayedexpansion if "%~1" equ "" (echo.%~0: usage: missing file name.& exit /b 1) if "%~2" neq "" (echo.%~0: usage: many arguments.& exit /b 1) /f %%i in (%~1) (echo.%%i& goto :afterheader) :afterheader /f "skip=1 tokens=1-3 delims=," %%i in (%~1) ( set name=%%i set address=%%j set postcode=%%k set postcode=!postcode: =! echo.!name!,!address!,!postcode:~0,-3! !postcode:~-3! ) exit /b 0 demo: > type data.csv name,address,postcode n1,a1,lu79gh n2,a2,w13tp n1,a1,lu7 9gh n2,a2,w1 3tp > .\add-space.bat data.csv name,...

php - mySQL - Join with date range -

hi hope can me problem: i have these tables: games id name 1 game1 2 game2 3 game3 plays game_id user_id numbers date 1 1 2,12,34,56 2015-06-30 13:15:00 2 1 5,10,22,41 2015-06-30 13:15:00 3 1 1,7,11,34 2015-06-30 13:15:00 1 2 4,17,29,32 2015-06-30 13:15:00 1 1 2,9,19,45 2015-06-31 13:15:00 2 1 5,16,26,31 2015-06-31 13:15:00 3 1 4,12,16,34 2015-06-31 13:15:00 1 1 3,15,27,43 2015-06-01 13:15:00 1 1 1,7,14,29 2015-06-02 13:15:00 2 1 7,23,31,48 2015-06-02 13:15:00 i need of user_id = 1 plays between today , 10 days in past if user didn't play in 1 date date should returned anyway. result should this: game_id user_id numbers date ...

combining performing _.uniq with _.isEqual in lodash -

lodash provides method _.uniq() find unique elements array, comparison function used strict equality === , while want use _.isequal() , satisfies: _.isequal([1, 2], [1, 2]) // true is there way perform _.uniq() _.isequal() , without writing own method? as of lodash v4 there's _.uniqwith(array, _.isequal) . docs: var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; _.uniqwith(objects, _.isequal); // → [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] more info: https://lodash.com/docs#uniqwith

html - highlight a div linked to the current page -

i'd buttons (moon, planets, etc...) staying red when on current page. link site: http://www.chooseyourtelescope.com/moon-telescope/ here, "moon" button should red. here code: html <a href=""><div class="top-logos"><img src="" alt="lune"></div></a> <a href=""><div class="top-logos"><img src="" alt="planetes"></div></a> <a href=""><div class="top-logos"><img src="" alt="ciel profond"></div></a> <a href=""><div class="top-logos"><img src="" alt="soleil"></div></a> <a href=""><div class="top-logos"><img src="" alt="telescope polyvalent"></div></a> css .top-logos { width:20%; top:108px; padding:5px; position: relativ...

Read java Byte from PHP -

i have java application send compressed image on network. each pixel value converted new byte type. problem don't know how correctly decode thos byte php. here java compression: public byte[] compressedimage(bufferedimage img, int color_type) { if ((img.gettype() != 2) && (img.gettype() != 1)) { throw new runtimeexception("image format not supported"); } int sizex = img.getwidth(); // 640px int sizey = img.getheight(); // 80px vector compresseddata = new vector(sizey * (1 + 3 * sizex) + 1); databuffer data = img.getraster().getdatabuffer(); int count = 0; int nextpix = 0; int ptr = 0; (int y = 0; y < sizey; y++) { compresseddata.add(new byte((byte)-128)); int currpix = data.getelem(ptr++); int x = 1; do{ if (x < sizex) { nextpix = data.getelem(ptr++); if ((nextpix == currpix) && (count < 63)) { count++; continue; } } int color_r = (...

javascript - POST request variables not coming through in Sails.js -

i'm new sails, may doing wrong, can't seem data form in controller. the submit action routes proper controller method. <form action="/create" method="post"> <div class="form-group"> <label for="title">title</label> <input type="text" class="form-control" id="title"> </div> <button type="submit" class="btn btn-default">submit</button> </form> controller action: save: function (req, res) { console.log(req.param('title')); console.log(req.params.all()); } results in: undefined {} how supposed submitted form data? it seems omit name attribute. <label for="title">title</label> <input type="text" class="form-control" id="title" name="title"> without parameter can't received server.

Out of order touch events in emulator when using host GPU on Ubuntu 14.04.2? -

i'm firing android kitkat x86 atom emulator instance host gpu enabled. when so, of touch input events fed emulator kernel appear out of order. occurs when using host gpu. for example, below can see believe valid tap (position + down followed position+up) next event down before pointer position changed. $ adb shell 'getevent -l' not driver version /dev/input/mouse0, not typewriter add device 1: /dev/input/event0 name: "qwerty2" not driver version /dev/input/mice, not typewriter /dev/input/event0: ev_abs abs_x 0000031e /dev/input/event0: ev_abs abs_y 0000047a /dev/input/event0: ev_key btn_touch down /dev/input/event0: ev_syn syn_report 00000000 /dev/input/event0: ev_abs abs_x 0000030b /dev/input/event0: ev_abs abs_y 00000472 /dev/input/event0: ev_syn ...

css - Styling angular-ui-bootstrap checkbox (label) -

i found cool style here on stackoverflow link didn't know how apply chekcbox angular-ui , they're labels. i tried adding them classes, effect has changed active class keep on messing everything, , looked weird. here working plunkr... http://plnkr.co/edit/6cfc73jztwujuqwntrwr?p=preview basically add css, .btn-primary { background: url('http://lorempixel.com/output/people-q-c-50-50-1.jpg') no-repeat; height: 50px; width: 50px; display: block; border-radius: 50%; position: relative; transition: 0.4s; border: solid 5px #fff; box-shadow: 0 0 1px #fff; /* soften jagged edge */ } /* provide border when hovered , when checkbox before checked */ .btn-primary:hover, .btn-primary.active, .btn-primary:focus{ border: solid 5px #f00; box-shadow: 0 0 1px #f00; /* soften jagged edge */ } /* - create pseudo element :after when checked , provide tick - center content */ .btn-primary.active::after { content: '\2714'; /*content required...

python - Convert DateField to unix timestamp in Django -

how can convert datefield() value unit timestamp representation in django? as datefield() returns native python datetime.date instance, https://docs.python.org/2/library/datetime.html , same converting datetime.date object unix timestamp integer.. such as: import time import django.models models date = models.datefield() unix_timestamp = int(time.mktime(date.timetuple()))

merge - Git, merging files manually from an upstream repo to a different repo -

i'm going explain how fetch files 1 repo , manually merge files 1 one using git. the solution propose based on couple of other posts can find here , here . you may find these posts helpful: git -p options list files git commit hope helps saving time. 1- go folder containing code branch x of repo r1 2- add repo r2 upstream running: git remote add upstream 3- fetch (do not pull) branch y of repo r2: git fetch upstream y note : if have same branch names (in case "y") in r1 , r2 git confused @ stage , have disambiguate branch name git proceed. 4- if don't want mistakenly push changes upstream use dummy url pushurl: git config remote.upstream.pushurl "some random text" 5- figure out files have changed in last commit in y branch of r2 running following command: git rev-parse head git diff-tree --no-commit-id --name-only -r note : can run above commands either going folder containing branch y of r2 or checking out y ...

excel - Dragging INDIRECT and -

i thought take through thinking there may better way using indirect achieve desired result if not solution indirect handy. i had simple formula =sumproduct($e$10:$e20,j10:j20) dragged across great number of columns ending somewhere in cc's however found when inserted row change 10 , $10 11 , $11, placed indirect in there. =sumproduct(indirect("$e$10:$e20"),indirect("j10:j20")) i realize i'm referring string , if drag across right, cell references won't update. so first question how go updating these can drag indirect across columns right , update cell references formula resemble or @ least work in same way when dragged column k , on. =sumproduct(indirect("$e$10:$e20"),indirect("k10:k20")) however if there better solution indirect keep orignial formula when rows inserted or deleted helpful too. you have turned both rows , columns static string representations when want guard row designations changing on...

javascript - Can't Send Base64 string To C# via AJAX -

i sending base64 string thru ajax aspx page c# code behind. string never makes c#. comes out empty. the ajax being sent in post request , other form fields post fine. my string looks like: qmfzzsa2ncdigjqgtw96awxsysbezxzlbg9wzxigtmv0d29yaw== the method sends string c# code behind is: string signature = request.form.get("newsig"); var pdfcontents = pdfhelper.generatepdf(pdfpath, formfieldmap, signature); the code behind: string base64image = sig; // convert base64string bytes array var newbytes = convert.frombase64string(base64image); sometimes base64 string long - issue? there better way of handling base64 strings in c#? update: ajax post method: var localbase64string = localstorage["signature"]; var b64 = localbase64string.replace(/^data:image\/(png|jpg);base64,/, ""); var formdata = new formdata($(this)[0]); formdata.append( 'newsig', b64); var sendpost = 'http://xxx.xx/this.aspx'; $.ajax(...

vim - Setting tab width based on file type -

i'm trying learn use vim. indenting 4 spaces use 2 spaces languages, such nim , moonscript. tried adding .vimrc : autocmd bufnewfile,bufread,bufenter *.nim :setlocal tabstop=2 shiftwidth=2 softtabstop=2 problem? doesn't anything! happens tab nothing when press it! doing wrong? autocmd bufnewfile,bufread *.nim setlocal tabstop=2 shiftwidth=2 softtabstop=2 this should work (after restarting vim / re-editing existing file via :e! ) fine, mixes filetype detection filetype settings . vim has intermediate abstraction called filetype , should use. it, map file globs *.nim filetype nim , , define settings either via :autocmd filetype , or filetype plugin in ~/.vim/ftplugin/nim.vim (for latter, need :filetype plugin on in ~/.vimrc ). steps so, create filetype detection in ~/.vim/ftdetect/nim.vim : autocmd bufread,bufnewfile *.nim setfiletype nim then, create filetype plugin in ~/.vim/ftplugin/nim.vim : setlocal tabstop=2 shiftwidth=2 softtabstop=2 you...

html - How to make dropdown navbar full width -

i have nav bar following html: <nav id="menu-bar"> <ul> <li><a href='http://sunilpatro1985.blogspot.in/' >home</a></li> <li><a href='http://sunilpatro1985.blogspot.in/search/label/seleniumtesting'>selenium</a> <ul> <li><a href='http://sunilpatro1985.blogspot.in/2015/04/selenium-testng.html'>testng</a></li> <li><a href='http://sunilpatro1985.blogspot.com/2015/03/selenium-result-report-testng-ant.html'>ant reporting</a></li> </ul> </li> <li><a href='http://sunilpatro1985.blogspot.in/search/label/softwaretesting'>testingconcepts</a></li> <li><a href='http://sunilpatro1985.blogspot.in/search/label/basicjava' >javabasics</a></li> <li><a href='http://sunilpatro1985.blogspot.in/search/label/windowsos' >windows<...

io - Python reading from non ascii file -

i have text file contains following character: ÿ when try , read file in i've tried both: with open (file, "r") myfile: and with codecs.open(file, encoding='utf-8') myfile: with success. when try read file in string using: file_string=myfile.read() or file_string=myfile.readline() i keep getting error: unicodedecodeerror: 'utf-8' codec can't decode byte 0xff in position 11889: invalid start byte ideally want ignore character or subsitute '' or whitespace i've come solution. use python2 instead of python3. still can't seem work in python3 though

javascript - link_to with :method => :delete routing through GET not DELETE rails 4 -

i making ruby on rails app , have run problem believe has javascript in app not working. the specific issue i'm having link_to: <%= link_to 'sign out', destroy_user_session_path, :method => :delete %> fairly standard can see. i getting in console: started "/user/sign_out" ::1 @ 2015-06-02 i think may have bootstrap , application.js file solution have found online have no helped. here application.js file: //= require bootstrap-sprockets //= require jquery //= require jquery_ujs //= require turbolinks //= require_tree . earlier in app having similar issue deleting "space" entities within same app, , other similar js issue must that. this on rails 4 way the rails unobtrusive javascript driver (ujs) - jquery-rails default uses intercepts clicks on links data-method , sends ajax request either sends correct http method or fakes when client not support particular verb sending post request special _method parameter. ...

dataframe - PHP passing boolean to ArrayObject for inner comparison -

is there way access details of boolean passed arrayobject comparison each element of array? i've begun work on dataframe php , seem have hit glass ceiling one. sample code: <?php class dataframe extends arrayobject { public function offsetget($key) { if (is_bool($key)) { echo "passed boolean: {$key}\n"; } else { echo "comparing: {$key}\n"; } } } just simple case code: $df = new dataframe(); $df['hello'] = 'world'; $df[$df['hello'] == 'world']; will output (for non-null, non-false, non-zero comparison): comparing: hello passed boolean: otherwise: comparing: hello passed boolean: 1 either way have no access comparison approach. is there interface can implement in order gain access boolean comparison methods or out of reach of php? either way sugar number of other approaches can taken, shame not have classic dataframe syntax. if mean r-li...

Git set tracking branch while offline -

git push -u origin branch binds branch origin/branch subsequent pushes branch can git push , far understand. can set kind of tracking brand new repo ( origin/branch doesn't exist yet) while offline? want make subsequent pushes branch go origin/branch without me having specify when go online. i'll use xyz name of branch , keep origin name of remote avoid confusion. mentioned online method push , set upstream @ same time.. git push --set-upstream origin xyz fetch online, set upstream offline the preferred way fetch branch before going offline , using --set-upstream-to option of git branch set upstream without pushing. git branch --set-upstream-to origin/xyz that results in adding following lines .git/config result of online way described before. [branch "xyz"] remote = origin merge = refs/heads/xyz fully offline approach when don't want fetch remote branch first, can either edit .git/config hand or use git confi...

c# - How to populate UL from code-behind -

i have ul in asp.net page: <ul id="ulo" runat="server"> </ul> code-behind: foreach (string wrwg in workgrouplists) { // add each "wrwg" list item `ulo` } i tried using asp:repeater populate didn't work. this work: foreach (string wrwg in workgrouplists) { htmlgenericcontrol li = new htmlgenericcontrol("li"); li.innertext = wrwg; ulo.controls.add(li); }

What's faster for Stata: manipulating data in a flat database (i.e. Excel) or in a relational database? -

i'm entry-level optimization analyst @ company publishes risk ratings data various companies. have tons of data (to point our history solely limited number of rows possible in excel). we use many .do files in stata perform manipulations , statistical analyses (the largest production run takes 9 hours, 1 insheet taking half minute). i'm trying convince company move away using flat database using relational database have been having trouble finding information online whether flat or relational better in stata. so--which better, , why? i hypothesise answered own questions emphasising limitations of excel prevent capitalising on full potential of data. excel is not proper analytical tool or data warehousing solution , such there no point in using in analytical projects involving more complex doing basic sums small business / household needs. to answer question: flat file databases archaic technology dating beginnings of computer science: never designed meet mod...

javascript - Zoomable Circle Packing with Automatic Text Sizing in D3.js -

i'm trying merge 2 of mike's examples: zoomable circle packing + automatic text sizing . it works when displayed @ top-level. however, if zoom in next level, fonts not sized correctly. i'm not sure if need modify transform, or modify part calculates font size. here's codepen: http://codepen.io/anon/pen/gjwqrl var circlefill = function(d) { if (d['color']) { return d.color; } else { return d.children ? color(d.depth) : '#fff'; } } var calculatetextfontsize = function(d) { return math.min(2 * d.r, (2 * d.r - 8) / this.getcomputedtextlength() * 11) + "px"; } var margin = 20, diameter = 960; var color = d3.scale.linear() .domain([-1, 18]) .range(["hsl(0,0%,100%)", "hsl(228,30%,40%)"]) .interpolate(d3.interpolatehcl); var pack = d3.layout.pack() .padding(2) .size([diameter - margin, diameter - margin]) .value(function(d) { return d.size; })...