Posts

Showing posts from February, 2015

c# - Multi-threading in custom SSIS transformation data flow task -

i have ssis package this: 1. read records flat file source 2. transform calling webservice adds additional response column buffer 3. output input records , response column destination file. 2 custom transformation data flow task wrote, synchronous because outputting input. i thought default buffersizes , enginethread properties multithreaded , call multiple processinputs @ same time. once ran it, realised called web service 1 @ time. how can make multi-threaded? i've googled around found myself getting more confused. thanks in advance have seen this excellent blog ? quote blog: sql server integration services (ssis) allows parallel execution in 2 different ways. these controlled 2 properties outlined below. the first 1 maxconcurrentexecutables, property of package. defines how many tasks (executables) can run simultaneously. defaults -1 translated number of processors plus 2. please note if box has hyperthreading turned on, logical processor rather

multithreading - Can one OpenCL device host multiple users on different threads? -

we're using intel opencl 1.2 inside large commercial program, running on single intel haswell cpu/gpu. conceivably, number of threads may want use gpu different functions @ different times. so questions: is idea @ allow multiple users single device? complications may face? i considering setting common context against device , platform users. set own programs, kernels , queues. i'm nervous device behaviour: can create non interacting silos of buffer, programs, queues, kernels , kernel args on 1 context? @ least, see clsetkernelarg not thread safe. from personal experience, can there no problems multiple threads, using same device context, shared between threads. there ideas on it: create multiple kernels single programm - each kernel each thread. quote khronos: clsetkernelarg safe call host thread, , safe call re-entrantly long concurrent calls operate on different cl_kernel objects though, creating separate command queue each thread may not re

Check condition in Perl regex for substitution -

i want substitute particular pattern in file other string. want substitution when particular string not matched in pattern. my code follows: use warnings; use strict; $filename = 'c:\test_folder\file.txt'; $pattern = undef; $read_handle = undef; $string = undef; open($read_handle, "<", $filename) || die "$0: can't open $filename reading: $!"; while ( <$read_handle> ){ $string = $string.$_; } $pattern = qr/(test_case_name.*?:(.*?)\n.*?priority.*?:(\w\d).*?=cut)/s; $string =~ s{$pattern}{$1\n\nsub $2\n{\n}\n}g; print $string; i have stored whole file in string. have following problem: if in pattern, $3(3rd back-reference) not equal "p3", substitution should occur. how can achieve this? some sample data input is: =head2 gen_001 test_case_name :gen_001 priority :p0 release_introduced :7.4 automated :yes step_name : step1 step_desc :example desc understanding

java - Hibernate error - QuerySyntaxException: administrator is not mapped error -

full error message: 11:49:51,896 info [stdout] (http-localhost-127.0.0.1-8080-1) javax.ejb.ejbexception: java.lang.illegalargumentexception: org.hibernate.hql.internal.ast.querysyntaxexception: administrator not mapped [select ad administrator ad ad.adminid='123' , ad.password='123'] @stateless public class manageadministrator implements manageadministratorremote { @persistencecontext(unitname = "jpadb") private entitymanager entitymanager; public manageadministrator() { } public administrator createadministrator(administrator adminid ) { entitymanager.persist(adminid); system.out.println("inside create administrator"); entitymanager.flush(); return adminid; } public list retrievealladministrators() { string q = "select ad " + administrator.class.getname() + " ad"; query query = entitymanager.createquery(q); list adm

javascript - Does a clicked on item go out of scope when going into the getJSON section -

when clicking on list item, go out of scope when going getjson section want go , data database? i have list of items displaying colours. each list item has id set of sku. when click on list item, must go , data database sku , populate contents on page. i playing around code , interest's sake wanted see if change text of clicked on list item. after json call done, tried set text, nothing happened. i sku of clicked on list item this: var sku = this.id; after json call tried set text of clicked on list item this: this.text('sample text'); i tried: this.text('sample text'); here full javascript/jquery code: <script> $(document).ready(function () { $('.attributes li').click(function () { var url = 'www.example.com/test-url'; var sku = this.id; $.getjson(url, { sku: sku }, function (data) { // not work this.text('sample tex

alchemyapi - Shows Progress Dialogbox when API request is being processed in CakePHP 2.x -

$this->alchemyapi = new alchemyapi(); $response = $this->alchemyapi->sentiment("text", "text anaylse", null); i have above code made request alchemyapi , wait response ,in action of controller.my question should using create progress box showing spinning icon while request being processed.and dialogbox disappear when request finished?.i wondering if possible on server side(on controller/action) instead of using javascript/jquery on view. since how design code passing $response variable view. $this->set($response); i new cakephp , have no idea start that.any appreciated.

How to represent a big number in Java -

this question has answer here: large numbers in java 7 answers how can represent , use large number in java? in scientific computing there number of times need numbers greater long . you should use biginteger this.. they can large need - until run out of memory. eg: biginteger bigintvar1 = new biginteger("1234567890123456890"); biginteger bigintvar2 = new biginteger("2743561234"); bigintvar1 = bigintvar1.add(bigintvar2);

ios - How can I process multiple links of JSON data? -

the code works perfectly. problem that, after trying while, cannot figure out how make program process second link of different json data. here viewdidload goes on: override func viewdidload() { super.viewdidload() var err: nserror? let urlpath: string = "https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/" + searchfielddatapassed + "?api_key=(removed private api key obvious reasons" var url: nsurl = nsurl(string: urlpath)! let session = nsurlsession.sharedsession() let task = session.datataskwithurl(url) { data, response, error in // cast response nshttpurlresponse , switch on statuscode if if let httpresponse = response as? nshttpurlresponse { switch httpresponse.statuscode { case 200..<300: println("ok") default: println("not ok") } } // parse json using nsjsonserialization if you've got data if let jsonresult = nsjsonserializatio

Changing SQL NOT IN to JOINS -

Image
hello guys, our aim script insert missing pairs of product - taxcategory in intermediate table (producttaxcategory) the following script correctly working trying find way optimize it: insert producttaxcategory (producttaxcategory_taxcategoryid,producttaxcategory_productid) select taxcategoryid ,productid product pr cross join taxcategory tx pr.productid not in ( select producttaxcategory_productid producttaxcategory ) or pr.productid in ( select producttaxcategory_productid producttaxcategory ) , tx.taxcategoryid not in ( select producttaxcategory_taxcategoryid producttaxcategory producttaxcategory_productid = pr.productid ) how can optimize query ? try (full statement now): insert producttaxcategory (producttaxcategory_taxcategoryid,producttaxcategory_productid) select taxcategoryid, productid product pr cross join taxcategory tx not exists (select 1 producttaxcategory producttaxcategory_p

asp.net - Downloading in pdf format -

this how i'm downloading gridview in excel. pls pdf download code: string strfilename = "salary_statement" + datetime.now.tostring("ddmmyyyy"); gridview1.allowpaging = false; gridview1.headerrow.cells[2].visible = true; gridview1.headerrow.cells[3].visible = true; (int = 0; < gridview1.rows.count; i++) { gridviewrow row = gridview1.rows[i]; } gridview1.headerrow.style.add("background-color", "#e5e1e1"); (int = 0; < gridview1.rows.count; i++) { gridviewrow row = gridview1.rows[i]; row.attributes.add("class", "textmode"); } response.clear(); response.buffer = true; response.addheader("content-disposition", "attachment;filename=" + strfilename + ".xls"); response.charset = ""; response.contenttype = "

method binding in C++ -

class shape { public: virtual void draw() = 0; virtual void area() { . . .} . . . }; class circle : public shape { public: void draw() { . . . } . . . }; class rectangle : public shape { public: void draw() { . . . } . . . }; class square : public rectangle { public: void draw() { . . . } . . . }; rectangle* r = new rectangle; r->draw(); // (1) r = new square; r->draw(); // (2) shape* sh = new circle; sh->area(); // (3) square* sq = new square; sq->draw(); // (4) (1),(2) dynamic binding, there's no doubt think (3) since class derived shape don't override method area, it's resolved shape::area() compiler? (4) no class derived sqaure class, sq can reference square type, means static method binding occurs? is there wrong?? in advance. binding wise seems true . above code have memory leaks rectangle* r = new rectangle; r->draw(); // (1) r = new s

javascript - How to correctly pass an object to a custom directive? -

i have "simple" goal: have kind of form creator, , directive expected "render" content of form. for that, created custom directive planing pass object , create logic rendering trough templates. however, failing pass object custom directive html: <div ng-controller="mycontroller"> <p>components starts</p> <div ng-repeat="item in items"> <!-- <p>{{item}}</p> --> <my-component obj="item" ></my-component> </div> <p>components ends</p> </div> js angular.module('myapp', []) .controller('mycontroller', function($scope) { $scope.items = [ { type: 'textarea', data: 'somedata1', mandatory: true }, { type: 'list', data: 'somedata2', mandatory: false }, { type: 'select', data: 'somedata3', mandatory: true }]; }) .directive('myco

python - How to add <br> tags with BeautifulSoup? -

so let's have <p>hello world</p> can beautifulsoup add tag so? <br><p>hello world</p> initially around doing like: soup = beautifulsoup("<p>hello world<p>") soup = beautifulsoup(re.compile('(<p>)', '<br>\1', soup.prettify()) but problem in actual usage more complex html .prettify() messes html adding whitespace , lines. i checked docs doesn't mention <br> tag @ all. it can done using soup.insert() function >>> br = soup.new_tag('br') >>> br <br/> >>> soup = beautifulsoup("<p>hello world</p>") >>> soup.insert(0,br) >>> soup <br/><p>hello world</p> the insert() function inserts tag @ numeric position. here have specified 0 inserted @ start.

php - How I can Use parent theme's constants in child Theme. Wordpress -

i have created child theme when load site did not find logo image saved in constant in parent theme's function file , httpd.exe memory goes upt 1gb , did not show error check apche php error log below error found. so question how can use constant defined in parent theme function file child theme should need redefine in child theme. [02-jul-2015 02:53:21 utc] php warning: getimagesize( http://localhost/wordpress/wp-content/themes/my-shahid/images/logo.png ): failed open stream: http request failed! http/1.0 404 not found in c:\xampp\htdocs\wordpress\wp-content\themes\my-framework\functions.php on line 233 at line 233 code 232: $logo = images . '/logo.png'; 233: $logo_size = getimagesize( $logo ); $logo = images . '/logo.png'; not right way define constant in wordpress, instead should define as. define("theme_logo", images ."/logo.png"); and can use writing theme_logo, anywhere in theme scope

Oracle 11G - Performance effect of indexing at insert -

objective verify if true insert records without pk/index plus create thme later faster insert pk/index. note point here not indexing takes more time (it obvious), total cost (insert without index + create index) higher (insert index). because taught insert without index , create index later should faster. environment windows 7 64 bit on dell latitude core i7 2.8ghz 8g memory & ssd hdd oracle 11g r2 64 bit background i taught insert records without pk/index , create them after insert faster insert pk/index. however 1 million record inserts pk/index faster creating pk/index later, approx 4.5 seconds vs 6 seconds, experiments below. increasing records 3 million (999000 -> 2999000), result same. conditions the table ddl below. 1 bigfile table space both data , index. (tested separate index tablespace same result & inferior overall perforemace) flush buffer/spool before each run. run experiment 3 times each , made sure results similar. sql flush:

c# - WPF SurfaceButton that drops down SurfaceScrollViewer on click -

as title says, i'd have component base surfacebutton, , when clicked drop down surfacescrollviewer. think i've made proper first steps, surfacescrollviewer never becomes visible, nor seem show in blend's hierarchy. accessing or initializing incorrectly? have multiple instances of surfacedropdown objects children of stackpanel, content of surfacescrollviewer. parenting scroll viewer aligned in grid, why set heights , widths using actualheight/width properties. public class surfacedropdown : surfacebutton { public surfacescrollviewer scrollviewer; private stackpanel stackpanel; public surfacedropdown() { this.click += onclick; scrollviewer = new surfacescrollviewer(); scrollviewer.height = this.actualheight * 5.0; scrollviewer.width = this.actualwidth; scrollviewer.horizontalalignment = system.windows.horizontalalignment.center; scrollviewer.verticalalignment = system.windows.verticalalignment.center;

javascript - Mouse Wheel Zooming -

so i'm working on canvas can drag image side side , use mouse wheel re size image zooming in , out on here code have far please feel free ask more details. i'm trying find way that's compact , require minimum code. <!doctype html> <html> <head> <style> body { margin: 0px; padding: 0px; } </style> <script src="kinetic-v5.1.0.min.js" type="text/javascript"></script> </head> <body> <div id="container"></div> <script type="text/javascript"> function drawimage(imageobj) { var stage = new kinetic.stage({ container: "container", width: 1800, height: 800 }); var layer = new kinetic.layer(); // image var image1 = new kinetic.image({ image: imageobj, x: stage.getwidth() / 2 - 896 / 1, y: stage.gethe

java - Serialization: good or bad in a multi-thread environment to maintain a cache? -

which better approach: using serialization create cache, or simply writing objects in form of string arrays file using delimiters? recently told serialization creates different thread process, , should not used in multi-threaded environment/application timing constraints need faster processing , less interruption! so true serialization inefficient in big multi-threaded java project ? serialization not take place on different thread. while java serializes object, if thread trying modify same object, may run consistency issues state of object being changed while serialization taking place. run in same issue own implementation. answer question "if serialization build cache efficient", suggest @ cache implementations (some open source hazlecast or ehcache).

mongodb - The output of mongo is non-deterministic with native-ruby-mongo-mapper -

i ran problem happens randomly. first, exsit?(collection, id) returned true it means there has document in mongodb, have further check in next step then (coll.find({_id: id}).first['history'].last['price'] raise error #<nomethoderror: undefined method `last' nil:nilclass> i don't why happens randomly. code def exsit?(collection, id) return (collection.find({_id: id}).first.nil? ) ? false : true end def is_price_changed?(coll, id, current_price) if exsit?(coll, id) return (coll.find({_id: id}).first['history'].last['price'] != current_price)? true : false else return true end end this document format { "updated_at": new date(1435757280839), "price": 16890, "history": [ { "updated_at": new date(1435757277672), "price": 16890 } ] } it looks 'history' attribute of id nil

vb.net - How to set only part of a string in a variable -

i trying make simple skype bot give response when user sends message option. my issue when user responds "!resolve username" tries resolve whole string. how select username response , place in variable? elseif msg = "resolve" or msg = "resolve" 'send usernamer sever , saves response in var dim resolvedip string = new system.net.webclient().downloadstring( "http://api.c99.nl/skyperesolver.php?key=korrupted.1020ull&username=" + pmessage.body) 'prints ip c.sendmessage(resolvedip) is kind of thing need? dim username = _ regex _ .match("!resolve user3812866", "^!resolve (.*)$", regexoptions.ignorecase) _ .groups(1) _ .value now username equals "user3812866" .

oracle11g - Error 1882 recovering Oracle dump File - Timezone region not found -

sorry english. i'm trying restore oracle database through dump have server crashed . the database exported in oracle 10g . when start import through imp tool , returns me following error: import fails following errors: imp-00058: oracle error 1882 encountered ora-01882: timezone region not found ora-06512: @ "sys.dbms_export_extension", line 810 ora-06512: @ line 1 imp-00009: abnormal end of export file i run command: imp file=2015-06-27_biblioteca.dmp log=my.log fromuser=biblioteca touser=biblioteca full=y thanks in advance

javascript - looping and decrementing sum -

i can't figure out why decrement sum won't work. work fine incrementing part, if first array value greater second doesn't seem run: function sumall(arr) { console.log(arr[0], arr[1]); var sum = 0; if (arr[0] < arr[1]) { (var = arr[0]; <= arr[1]; i++) { sum += i; console.log(sum); } } else if (arr[0] > arr[1]) { (var j = arr[1]; j >= arr[0]; j--) { sum += j; console.log("sec", sum); } } return sum; } sumall([9, 3]); already explained in comment, here code: its because in loop have condition j >= arr[0] in else if have condition (arr[0] > arr[1]) , because of loops never gets executed. here working code: function sumall(arr) { console.log(arr[0], arr[1]); var sum = 0; if (arr[0] < arr[1]) { (var = arr[0]; <= arr[1]; i++) { sum += i; console.log(sum); } } else if (arr[0] > arr[1]) { (var j = arr[0]; j >= arr[1]; j--) { sum

c - How to detect when one file is modified inside a symbolic link directory in Linux -

i have symbolic link 1 directory this root@beaglebone:/sys/class/drm# lrwxrwxrwx 1 root root 0 sat jan 1 00:00:01 2000 card0-hdmi-a-1 -> /sys/devices/ocp.3/4830e000.lcdc/drm/card0/card0-hdmi-a-1 how can detect/watch when 1 file modified inside real path (/sys/devices/ocp.3/4830e000.lcdc/drm/card0/card0-hdmi-a-1) symbolic link (/sys/class/drm/card0-hdmi-a-1) points to. (i prefer c program this). thanks much. the command looking stat . stat retrieves data file (in *nix, directory kind of file). when used on symbolic link, stat return data on link points to, not link itself. stat populates struct stat , st_mtime member time of last modification, directory, update when contents change. struct stat file_info; if ( stat ( "/sys/class/drm/card0-hdmi-a-1", &file_info ) == 0 ) { /* stat succeeded, file_info.st_mtime real directory's mod time */ } else { /* stat failed reason. consult man page info error codes */ }

Laravel 5 "www" and naked domain routing -

i ask approach should use handle naked domain routing in laravel 5? given scenario this, when user types in example.com, can use route::group(['domain' => 'example.com'], function(){ route::get('/', function() { return redirect::to(url::route('/')); }); }); noted route('/') has been namespaced in route groups www.example.com so question is, if user enters example.com/something/very/interesting , how should redirect user www.example.com/something/very/interesting ? bare in mind other actions. means @ point of time when user enters example.com/* bring user www.example.com/* thank you this more solved web server rather @ laravel level of things. if using apache check out this answer . if using nginx check out this answer . you wanting force user www.example.com need update route group following; route::group(['domain' => 'www.example.com'], function () { // rest of routes });

javascript - Why is this method called multiple times? -

when refresh page, must click button twice in order prompt. after that, each time click same button , call classichover() method (without refreshing), 1 plus prompt(two prompts, 3 prompts, four...). this code: function classichover(){ $('#button1').click(function(){ gridsize = prompt("set grid size") $('.container').empty(); for(i = 0; < gridsize * gridsize; i++) { $('.container').append("<div>a</div>"); }; }); }; button: <input id="button1" type="button" value="set new grid" onclick="classichover()" /> what doing wrong? js/jquery newbie btw your click calls classichover . classichover adds function button's listener. each time click it, add listener. first click adds 1. second click runs 1 , adds another. third click runs 2 , adds another. repeat each click.

C - Why does this output "%s" -

char *x = "world"; x = &x[6]; printf("%s", x); hi can't understand why above code outputting first argument in printf statement. if change printf("f%s",x); outputs "ff%s" why output ff twice? thanks because reading beyond array boundary. array of length 6 (0-5) , you're accessing 6th member (your last available 5th). undefined operation , unpredictable things print out portion of printf statement.

c - How can this be dereferencing ‘void *’ when the pointer was declared with a type? -

i'm trying make array file-level or global scope size determined @ runtime. various articles this one suggest pattern such dynamic array: static misctype *handles; static int nthreads; int main(int argc, char **argv) { // nthreads set from argv handles = malloc(nthreads * sizeof(misctype)); for(i = 0; < nthreads; i++) { handles[i] = miscfunction(); ... free(handles); return 0; } int otherfunction(...) { for(i = 0; < nthreads; i++) { handles[i] = miscfunction(); ... } however, everywhere use pointer array (i.e. handles[i] ) compiler says warning: dereferencing ‘void *’ pointer , error: invalid use of void expression . but it's not void pointer! has type (misctype in pseudocode), , re-casting same type doesn't stop errors. pass void * or that. what's going on here? more importantly, can it? okay, start with, if compiler tells handles void * , should believe it. now, turns out malloc returns

c++ - How while(!(cin >> x)) works to re-prompt for input -

while(!(cin >> ar[i])) { cin.clear(); // clears bad input while(cin.get() != '\n') continue; cout << "invalid input, please enter valid scores"; } the above code larger file. copied bit of code 1 of textbooks , don't feel comfortable using not understand how works. i using measure handle input errors. so ar empty array of integers, if decide enter 'k', then !(cin >> ar[i]) is true. from here clear input buffer (i think correct, i'd confirm or dispute please). terminal prints "invalid input..." if press enter nothing happens, isn't enter newline char? shouldn't code read while(cin.get() == '\n' ? while(!(cin >> ar[i])) this tries parse value cin , store in ar[i] . default, >> skips whitespace first, sees if characters in cin describe legal value whatever type of ar[i] is. if legal value found, cin stream state re

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.dll - C# visual studio -

i've got code lines, when try save data data base shows error: an unhandled exception of type 'system.invalidoperationexception' occurred in system.data.dll additional information: executenonquery: propriedade connection não foi inicializada. can guys give little ? sqlconnection cn = new sqlconnection(@"data source=(localdb)\v11.0;attachdbfilename=c:\basededadospap.mdf;integrated security=true;connect timeout=30"); sqlcommand cmd = new sqlcommand(); private void button1_click(object sender, eventargs e) { if (textbox4.text != "" & textbox2.text != "") { { using (var connection = new sqlconnection(@"data source=(localdb)\v11.0;attachdbfilename=c:\basededadospap.mdf;integrated security=true;connect timeout=30")) { cn.open(); cmd.commandtext = "insert artigo (nomeartigo,pre

regex - htaccess blocking requests to /? -

i getting ton of bots or hitting site urls like: www.website.com/?how-much-does-a-ventolin-inhaler-cost-in-canada i have no idea are, doesn't resolve on site causing significant mysql overhead index has heavy queries. i can't seem figure out how stop these via htaccess because of question mark... i thinking this: rewriteengine on rewritecond %{request_uri} /\?^ rewriterule .*$ - [f,l] but no dice. all values found after "?" in url called query string parameters. entire website not use query string parameters? may want careful before removing every request query string parameter, because that's pretty common way of using internet. if want strip them, following code work. rewriteengine on rewritecond %{query_string} !="" rewriterule . - [f,l] however, blocks requests page contain query parameters. spam page without query parameters if knew caused issue lead denial of service you. this whole issue sounds there's more sy

java - GSON JsonObject getAsString() UTF-8 issue -

i have json value "test":"d'exécuter" , when print gson's getasstring() method displays d\u0027ex├âŒ?cuter or d'ex??cuter. how actual value "d'exécuter"? string envservices = system.getenv("services"); jsonobject services = new jsonparser().parse(envservices).getasjsonobject(); jsonarray arr = (jsonarray) services.get("dev.dev"); //$non-nls-1$ if (arr.size() > 0) { services = arr.get(0).getasjsonobject(); jsonobject credentials = services.get("credentials").getasjsonobject(); string val = new string((credentials.get("test").getasstring()).getbytes("utf-8")); string val1 = new string((credentials.get("test").getasstring())); } the json value follows services={"dev.dev": [{ "name": "wds", "credentials": { "url": "http://test.com", "username": null,"test":"d'exécut

entity framework - MVC 5 Unit tests vs integration tests -

i'm working mvc 5 project using entity framework 5 (i may switch 6 soon). use database first , mysql existing database (with 40 tables). project started “proof of concept” , company decided go software i'm developing. struggling testing part. my first idea use integration tests. way felt can test code , underlying database. created script dumps existing database schema “test database” in mysql. start tests clean database no data , creates/delete bit of data each test. thing takes fair amount of time when run tests (i run tests often). i thinking of replacing integration tests unit tests in order speed time takes run them. “remove” test database , use mocks instead. have tested few methods , seems works great i'm wondering: do think mocking database can “hide” bugs can occur when code running against real database? note don’t want test entity framework (i'm sure fine people microsoft did great job on that), can code runs against mocks , breaks against mysql ?

database - Why can SQL Server 2012 not add an included column to an existing non clustered index -

i don't understand why not simple alter index whatever add included (columnname) what prevent being simple operation sql server add column index , populate value in pages table? this not affect ordering @ of index, trying optimize select statement. hoping can have less down time 8 hours take drop , rebuild set of indexes sadly disappointed. because included column in index page, @ moment have like: page row 1: key 1, key 2, inc 1 row 2: key 1, key 2, inc 1, row 3: key 1, key 2, inc 1 ... if row 1 starts @ byte 0, row 2 @ byte x, etc to add new included column need take each page, break rows add column , re-write it, possibly on either 1 page or more 1 pages, including metadata previous pages points - having completly re-write index why not rebuild it. it cheaper sql server build new index insert little pieces of data here , there. edit: index fragmentation need rebuild it

Vim - When I run my Java file, the println statements don't seem to be getting executed -

i'm using gvim. created file caled insertionsort.java , inside file: public class insertionsort { public static void main (string[] args) { system.out.println("hello world"); } } i opened terminal , did sudo apt-get install default-jdk to install javac. next, went gvim , did: :!javac % to run current file. when did this, said: !javac /documents/java/insertionsort.java press enter or type command continue and when press enter, goes insertionsort.java. doesn't print anything. looked @ post: compiling java code in vim more efficiently , highest rated answer said add these .vimrc file: autocmd filetype java set makeprg=javac\ % set errorformat=%a%f:%l:\ %m,%-z%p^,%-c%.%# map <f9> :make<return>:copen<return> map <f10> :cprevious<return> map <f11> :cnext<return> after adding above lines .vimrc file, reopend gvim / insertionsort.java , pressed f9 , said: !javac documents/java/insertionsort.j

SQL server combining rows to columns -

this question has answer here: simulating group_concat mysql function in microsoft sql server 2005? 9 answers i had problem in combining 2 rows in single column in sql server. here want original table this -------------------------------------------- | id || d_code1 || d_code2 || dcode3 | -------- ---------- -------- -------- | 1 || 2f || v012 || f013 | | 1 || k013 || c190 || null | -------------------------------------------- i want loaded in this. bit complicated. ---------------------------------- | id || d_code | ---- ------------------------ | 1 || 2f,v012,f013,k013,c190 | ---------------------------------- could 1 please me on this. new sql server. in advance. you can use stuff , xml select distinct i.id [id], stuff(( select '

cql3 - In cassandra cqlsh, how do I select from map<ascii, ascii> in a table? -

basically here how table set up: create table points ( name ascii, id varint, attributes map<ascii, ascii>, primary key (name, id) ) and if run following select statement returned: select id, attributes points limit 5; id | attributes ----+------------------------------------------ 1 | {station/name: abc, type: 2, pfreq: 101} 2 | {station/name: abc, type: 1, pfreq: 101} 3 | {station/name: def, type: 1, pfreq: 103} 4 | {station/name: ghi, type: 2, pfreq: 105} 5 | {station/name: ghi, type: 1, pfreq: 105} what able form clause based on info inside of attributes. following statement: select id points name = 'name' , attributes['pfreq'] = 101; however, when run following error: bad request: line 1:56 no viable alternative @ input '[' i looked @ this discussion , seems though not supported yet, true? or there way filter on attributes information? here versions working with: [cqlsh 4.1.1 | cassandra 2.0.

apache - How I can setup main directory instead web directory to my website in Symfony? -

actually i make clone of previous site have on symfony . copy directory , files on same server , assign other domain. can not access clone thru www.domain.com. view site need this: wwww.domain.com/proyect/web/app.php . my question is: need load site on principal directory?. change config of webpage, e.g. <virtualhost *:80> serveradmin webmaster@localhost servername www.domain.com serveralias domain.com documentroot /var/www/proyect/web/ <directory /var/www/proyect/web/> options indexes followsymlinks multiviews allowoverride order allow,deny allow </directory> </virtualhost> and restart apache

python - finding closest x,y position in one list to an x,y position in another? -

so have 2 2d lists x , y coordinates , want go through list1, , each point find closest x,y coordinates in list2. they're of different lengths, , it's okay if don't use points of list2 or if reuse points, long go through points once in list1. need shift location in lists of both points. tried using function found on site doesn't seem working: def do_kdtree(combined_x_y_arrays,points): mytree = scipy.spatial.ckdtree(combined_x_y_arrays) dist, indexes = mytree.query(points) return dist,indexes #perhaps it's not doing wanted do. here tried: s_x = ([1.0,2.0,3.0]) s_y = ([1.5,2.5,3.5]) sdss_x = ([3.0,4.0,5.0]) sdss_y = ([3.5,4.5,5.5]) list1 = zip([s_x],[s_y]) list2 = zip([sdss_x],[sdss_y]) shift,place_in_array = do_kdtree(list1,list2) and error get: traceback (most recent call last): file "tester.py", line 23, in <module> shift,place_in_array = do_kdtree(list1,list2) file "tester.py", line 9, in do_kdtree m

java - Array of Doubly Linked Lists -

i create array each element doubly linked list. here's have far: public arrayoflists() { this.limit = limit; //limit of nodes in each element of listarray listarray = (doublylinkedlist<e>[]) new doublylinkedlist[3]; listarray[0] = new doublylinkedlist<e>(); listarray[1] = new doublylinkedlist<e>(); listarray[2] = new doublylinkedlist<e>(); size = 0; } i'm not sure if conceptually correct, kind of see 2d array. i'm confused how go adding , removing objects lists stored in array. example, public void add(e obj) { //some stuff } public void remove(int index) { //some stuff } could somehow access implemented methods in doublylinkedlist class assist this? thank much. i'm not sure logic use figure out slot of array want add obj to, how (after implementing calculatearrayslotsomehow of course): public void add(e obj) { int index = calculatearrayslotsomehow(obj); listarray[index].add(

twilio - How to detect if the outbound call has been forwarded? -

when making outbound phone call , if call has been forwarded phone number, there way retrieve forwarded-to phone number? or there way detect if outbound call has been forwarded? twilio evangelist here. unfortunately thats not possible know on our end, there isn't way give you. hope helps.

html - Javascript : How can I enter a '@' in an url? -

i got code let me change value in page using form submit in javascript, problem url not accept value @ ( @ = %40 in url) here code: index.html <form method="get" action="page.html"> <input type="text" id="my_text" name="my_text" /> <input type="submit" /> </form> page.html <input id="title"></input> <script type="text/javascript"> function geturlvars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } document.getelementbyid("title").value = geturlvars()["my_text"]; </script> how can fix problem? you want use encodeuri() , see this answer in depth explanation.

Ruby Elasticsearch API: Returning the latest entry to an index -

i've enabled "_timestamp" field in index mapping, , i've confirmed using rest api calls elasticsearch can retrieve latest entry index. post request used confirm is: { "query": { "match_all": {} }, "size": "1", "sort": [ { "_timestamp": { "order": "desc" } } ] } now i'm trying translate ruby elasticsearch-api syntax... have far: client = elasticsearch::client.new host: 'blahblahblah:9200' json = client.search index: 'index', type: 'type', body: { query: { match_all: {} }}, sort: '_timestamp', size: 1 i've tried several variations on above code, nothing seems return newest entry. can't find many examples online using ruby elasticsearch api syntax, appreciated! if there way return latest e

c++ - How to Get Visual Studio To Stay Within 4GB Virtual Address Space -

Image
the visual studio devenv.exe process 32-bit ( even when run on 64-bit os ), can't use more 4gb of virtual memory. unfortunately, when debugging c++ application visual studio run out of memory due 4gb limit. example, using vmmap , below shows progression of typical visual studio usage on few hours leading crash. how can visual studio use less memory stop wasting time crashing? is typical visual studio use more 3.5 gb virtual address space? i using visual studio 2012, assume problem spans different vs versions, since visual studio 2015 still doesn't have 64-bit version. (note vmmap reports “free” remaining memory in address space, 4gb 32 bit processes, , 8tb 64 bit processes on windows.) things i've tried: starting in safe mode removing plugins , extensions nothing shows in tools > add-in manager nor tools > extensions ( https://github.com/tsasioglu/total-uninstaller helpful this) deleting .suo/.sdf files deleting appdata/*/microsoft/vi

r - Delete Last Part of a String Starting with a Numeric Value -

i have dataframe of drug names. there multiple doses each type of drug. instance, have: x <- data.frame(c("drugx 10 mg", "drugx 20 mg", "drugx 30mg", "drugx 2% cream", "drugx 10% gel", "drugy 20 mg", "drugy 30 mg")) x[,1] <- as.character(x[,1]) i delete after given numeric value. new dataframe looks this: xnew <- data.frame(c("drugx", "drugx", "drugx", "drugx", "drugx", "drugy", "drug y")) at point take 'uniques' xnew2 <- unique(xnew) so final product be xnew2 <- c("drugx", "drug y") thanks in advance! you can try sub v1 <- sub('\\s*\\d+.*$', '', x[,1]) v1 #[1] "drugx" "drugx" "drugx" "drugx" "drugx" "drugy" "drugy" unique(v1) #[1] "drugx" "drugy"

seo - Advice regarding Google Webmaster 404 errors -

i created cms website , integrated google analytics. site changes it's content every week (adding, editing, removing pages , urls) , rewrite sitemap every time when 1 of actions occurred. the problem web crawlers google detect lot of 404 error pages. what doing wrong? getting reports 404s normal , no need worry them. check google find 404 urls, can see in search console (formerly webmaster tools), , see if can fix them. if cannot, if have great content, sooner or later you'll better links. what additionally, create custom 404 pages, link content on site that's similar missing page (if it's possible determine that), or that's popular on site.

node.js - Sails.js - API attribute not changing via PUT -

i following tutorial written node/express , attempting adapt sails. using postman put name : chris @ localhost:1337/api/data/5591bbdedabb79240b34a46b sails -v 0.11.0 node -v 0.12.4 here controller: modify_one: function (req, res) { api.findbyid(req.params.data_id, function(err, data, callback) { if (err) res.send(err); data.name = req.body.name; data.update({data_id:req.params.data_id},{$set: {name:req.body.name}}, callback) }) route: 'put /api/data/:data_id': 'apicontroller.modify_one', if /api/data doesn't show modification. howver res.json(data.name) returns correct change. any thoughts? must not saving in mongodb?

java - Why does deletion of rows from one table work, but not from another? -

i trying delete rows tables. code in first program succeeds in deleting row. code in second, similar program deletes 0 rows. however, when issuing same delete command sql command line tool, reports 1 row being deleted. first program: package oracle; import java.sql.drivermanager; import java.sql.connection; import java.sql.preparedstatement; import java.sql.sqlexception; import java.text.dateformat; import java.text.simpledateformat; public class jdbcpreparedstatementinsertexample { private static final string db_driver = "oracle.jdbc.driver.oracledriver"; private static final string db_connection = "jdbc:oracle:thin:@localhost:1521:xe"; private static final string db_user = "system"; private static final string db_password = "datta123"; public static void main(string[] argv) { try { insertrecordintotable(); } catch (sqlexception e) { system.out.println

powershell - Please explain, function to add string to first line of a file -

would explain happing in powershell code @ bottom of post? i got first, lets "hello world" in powershell, , needed these lines of code. works charm, not sure does, exactly. the questions starts at $( ,$_; get-content $path -ea silentlycontinue) | out-file $path so understand far. we create function called insert-content . params (input interpeted string , added $path ). function insert-content { param ( [string]$path ) this function does/processes: process { $( ,$_; i not sure does, guess gets "the input" (the "hello world" before | in "hello world" | insert-content test.txt ). and got -ea silentylycontinue , do? process { $( ,$_; get-content $path -ea silentlycontinue) | out-file $path it appreciated if explain these 2 parts $( ,$_; -ea silentylycontinue code needed/used: add string first line of doc. function insert-content { param ( [string]$path ) process { $( ,$_;get-content $path -ea