Posts

Showing posts from April, 2011

jquery - renderDataTable Select all cells containing value > 10 and highlight -

i'm creating datatable has user-defined number of rows & columns. loop through of cells in table (minus first column, contains names) , highlight/change css if values greater 10. shiny has great example of targeting specific column (see below). i'm assuming i'd need write sort of jquery function? i'm complete jquery newbie, gave try, and, hasn't worked (also see below). appreciated! shiny example of targeting specific column: rowcallback = i( 'function(row, data) { // bold cells >= 5 in first column if (parsefloat(data[0]) >= 5.0) $("td:eq(0)", row).css("font-weight", "bold"); }' ) my failed attempt @ writing function loop through cells: rowcallback = i(' function(row, data) { each (i in 1:1000) { if (parsefloat(data[i]) > 10.0) $("td:eq(i)", row).css("color", "red");} }') ...

javascript - Save last session of chrome extension -

in html file have simple table , couple of buttons allow adding/removing rows. if store html in popup.html, every time close chrome extension session disappears. if added rows , put values cells of table, once go extension, these rows , values disappear when click on extension again. as solution saw putting html background.html , retrieving code popup.js: // listeners save/restore document.body window.addeventlistener("unload", function(event) { chrome.extension.getbackgroundpage().docbody = document.body; }); window.addeventlistener("load", function(event) { var docbody = document.body, lastdocbody = bgpage.docbody; if (lastdocbody) docbody.parentelement.replacechild(document.importnode(lastdocbody,true), docbody); }); however, doesn't output content of background.html extension. the question general: save last state of table, no matter if closed extension or not. how can this? or in particular, how can load/save page ...

python 2.7 - ProgrammingError: invalid reference to FROM-clause entry for table "iris_category" -

i have created module , adding category, working correct in previous version of odoo , on 10-april-2015 updated new version getting error error: hint: perhaps meant reference table alias "iris_business_category__category_id". , in query select "iris_business_category"."id",iris_category__content_id."title" "iris_business_category","iris_category" "iris_business_category__category_id","iris_content" "iris_category__content_id" "iris_business_category".id in %s , ("iris_business_category"."category_id" = "iris_business_category__category_id"."id") , ("iris_category"."content_id" = "iris_category__content_id"."id") order "iris_business_category"."id" how solve issue in new version?? yes problem , has been mentioned on odoo.

css - SVG using textPath a symbol not rendering in Firefox -

using textpath within symbol doesn't render in firefox. renders fine in latest chrome , ie, when try reference symbol, svg text doesn't render in firefox (37.0.1) - first box appears empty. code below (no external dependencies), there should 2 boxes word test flowing vertically in centre of each. edit: thought issue somehow involved flexbox layout, until paul pointed out issue exists without flexbox layout. the html is: <div> <svg id="not_working" viewbox="0 0 250 1200" preserveaspectratio="xmidymid meet"> <symbol id="test_symbol1" preserveaspectratio="xmidymid meet" viewbox="0 0 250 1200"> <path id="test_symbol_path" d="m 100 1200 l 100 0" /> <text font-size="100" fill="red"> <textpath text-anchor="middle" startoffset="50%" xlink:href="#test_symbol_path...

interactive brokers - Getting positions of your portfolio using python ibPy library -

i using ibpy positions of portfolio. understand can do: from ib.opt import ibconnection tws = ibconnection( host = 'localhost',port= 7496, clientid = 123) tws.reqaccountupdates(true,'accountnumber') and supposed use updateportfolio() in way, don't know how. thanks tws.reqaccountupdates(true,'accountnumber') send string "acctnumber" when meant variable. notice string send actual (fake)account number. then need register callback messages you're interested in. from ib.opt import ibconnection, message def acct_update(msg): print(msg) con = ibconnection(clientid=1) con.register(acct_update, message.updateaccountvalue, message.updateaccounttime, message.updateportfolio) con.connect() con.reqaccountupdates(true,'du000000') #don't forget disconnect somehow when done #con.disconnect()

Jquery Ajax error: code:19 message:Failed to execute 'send' on 'XMLHttpRequest' -

i have 2 web apps in same domain different ports, e.g.: http://test.com:8888 http://test.com:8787 one used edit content, 1 used show content. when open 2 websites in same browser @ same time, edit content , save ajax post request,it fails error: code:19 message:failed execute 'send' on 'xmlhttprequest' name: "networkerror" please tell me what's happened , how fix it. thanks! from w3: an origin defined combination of uri scheme, hostname, , port number. the port problem. you'll have investigate other alternatives, such jsonp example.

Neo4j Optional Relationship Match -

i want write query returns node (a), nodes directly adjacent (b), , nodes connect (b) not nodes have been identified (b). so... if graph was: d / a<--b \ c i want return { a, [b], [c, d] }. so far, have following query (the 'prop' attribute distinguishes each node each other): match (a)<-[:something]-(b)<-[:something*0..]<-(c) not (c.prop in b.prop) return a.prop, collect(b.prop), collect (c.prop) if graph looks like: a<--b i expect result { a, [b], [] } instead nothing back, due c.prop being in b.prop. tried using optional match did not work either: match (a)<-[:something]-(b) optional match (a)<-[:something]<-(b)<-[:something*0..]<-(c) not (c.prop in b.prop) return a.prop, collect(b.prop), collect (c.prop) any way intended results? when run following query: match (n:crew)-[r:loves*]->m optional match (m:crew)-[r2:knows*]->o n.name='neo' , not (o.name in m.name) return n,m,o ...

angularjs - NodeJS or NGINX for Reverse Proxy -

i'm restructuring project use gulp, bower, npm, , angularjs. current architecture uses javascript mvc served nginx, proxy's requests backend (java). there no changes backend services, since front-end architecture using npm, make sense switch nginx proxy server nodejs? nginx better choice proxy server nodejs? thanks. nginx better choice proxy server node.js. correctly configured, nginx work faster , use less resources. also, nginx standard choice such tasks , has many production-ready modules out of box (such rate-limiting, load balancing, gzip, etc).

c++ - Msgpack packing bools bug -

for c++ project use c++ msgpack library available in ubuntu (14.04) standard repository under name libmsgpack-dev. all works fine except when try pack bools. there things go absolutely bananas. first wrote simple test study pack method. turned out, can not trusted packing bools. here simple test showing problem: #include <msgpack.hpp> test_case("bool packing", "[msgpack1]") { msgpack::sbuffer buf; msgpack::packer<msgpack::sbuffer> p(&buf); std::string key = "boolvalue"; bool value = true; p.pack_map(1); { p.pack(key); p.pack(value); } msgpack::unpacked msg; msgpack::unpack(&msg, buf.data(), buf.size()); std::map<std::string, msgpack::object> m; msg.get().convert(&m); bool loaded_value; m.at(key).convert(&loaded_value); info("we packed: " << value); info("we loaded: " << loaded_value); r...

r - Unique coordinates using GenomicRanges -

how can find unique (non overlapping genomic coordinates) comparing 2 datasets using genomicranges? dataset1 = chr start end cna 1 170900001 171500001 loss 1 11840001 19420001 loss 1 60300001 62700001 gain 1 25520001 25820001 gain dataset2 = chr start end cna 1 170940001 171500001 gain 1 60300001 62700001 gain 1 25520001 25840001 gain 1 119860001 123040001 loss 1 171500001 171580001 gain 1 79240001 84420001 gain expected output chr start end cna 1 170940001 171500001 gain 1 119860001 123040001 loss 1 171500001 171580001 gain 1 79240001 84420001 gain try this: require("genomicranges" ) #data x1 <- read.table(text="chr start end cna 1 170900001 171500001 loss 1 11840001 19420001 loss 1 60300001 62700001 gain 1 25520001 25820001...

html - Sizing the Mega Menu to page width and centering it -

i trying make mega menu width of #header , centered middle. max-width of header 1024px. dropdown menu keeps starting @ edge of parent li. managed hack margins, that's not permanent solution means. i've removed margins sake of question. html <header> <div id="header"> <div class="row"> <div class="medium-3 columns"> <div id="logo"> <a href="#"><img alt="logo" src="http://dummyimage.com/174x114/828282/0011ff.png"/></a> </div> </div> <div class="medium-7 columns"> <ul class="nav clearfix animated"> <li class="border-half"><a href="#">home</a></li> <li class="border-half"> <a href="#">series</a> ...

jquery addClass to trigger -

i have set of trigger divs on click animate nearest div named .animatepanel . i have following jquery want add class click trigger ( .paneltab ) when animated panel shown class being applied animated panel. $('.paneltab').click(function() { var panel = $(this).next() $('.animatedpanel').removeclass('active'); $('.animatedpanel').not(panel).slideup(); panel.addclass('active').slidetoggle({ direction: "up" }, 100); }); $('.paneltab').click(function() { $(this).addclass('someclass'); var panel = $(this).next() $('.animatedpanel').removeclass('active'); $('.animatedpanel').not(panel).slideup(); panel.addclass('active').slidetoggle({ direction: "up" }, 100); }); it sounds want apply addclass clicked paneltab. can use $(this) within listener access clicked paneltab. were looking more complex? like perhaps removing "someclass...

HTML/CSS: Show full size image on click -

i have text + image side side, , want function user can click on image make bigger. i'm new html/css wondering how can approach this. thanks! (demo -> https://jsfiddle.net/dtchh/6634/ ) is there way pure html/css , no javascript? the ones found have been telling me use javascript such as: <script type="text/javascript"> function showimage(imgname) { document.getelementbyid('largeimg').src = imgname; showlargeimagepanel(); unselectall(); } function showlargeimagepanel() { document.getelementbyid('largeimgpanel').style.visibility = 'visible'; } function unselectall() { if(document.selection) document.selection.empty(); if(window.getselection) window.getselection().removeallranges(); } function hideme(obj) { obj.style.visibility = 'hidden'; } </script> is there s...

Place icon left of the text in treeview column using Python and GTK3 -

Image
i'm using code add icons treeview column: def build_tree_view(self): self.explorer_store = gtk.treestore(pixbuf, str, str) icon = gtk.icontheme.get_default().load_icon("folder", 22, 0) connname, conndata in self.config.get('connections', {}).items(): parent = self.explorer_store.append(none, [icon, connname, self.get_dsn(conndata)]) self.tree_view = gtk.treeview(self.explorer_store) renderer_pixbuf = gtk.cellrendererpixbuf() renderer_text = gtk.cellrenderertext() column1 = gtk.treeviewcolumn("column", renderer_text) column1.pack_start(renderer_text, true) column1.pack_start(renderer_pixbuf, false) column1.add_attribute(renderer_pixbuf, "pixbuf", 0) column1.add_attribute(renderer_text, "text", 1) self.tree_view.append_column(column1) and got result: how can align icons left of text? i found solution! when create column not need pass renderer second parame...

c# - How to Convert Unicode Text File With URLs to ANSI using URL Encoding -

i have large text files containing urls. encoded in ucs-2 little endian. contain kinds of links contain: arabian, chinese, japanese, korean, russian , languages can think of in url. my goal create script url encode automatically of these links , save them in ansi encoded file. example: these of original links: http://ejje.weblio.jp/content/あきれて物が言えない https://ru.wikipedia.org/wiki/Дактиль http://zh.wikipedia.org/zh/垃圾食品 http://abunawaf.com/سيارات-الملوك-وورثتهم-صور http://ko.wiktionary.org/wiki/가능해지다 these need become: http://ejje.weblio.jp/content/%e3%81%82%e3%81%8d%e3%82%8c%e3%81%a6%e7%89%a9%e3%81%8c%e8%a8%80%e3%81%88%e3%81%aa%e3%81%84 https://ru.wikipedia.org/wiki/%d0%94%d0%b0%d0%ba%d1%82%d0%b8%d0%bb%d1%8c http://zh.wikipedia.org/zh/%e5%9e%83%e5%9c%be%e9%a3%9f%e5%93%81 http://abunawaf.com/%d8%b3%d9%8a%d8%a7%d8%b1%d8%a7%d8%aa-%d8%a7%d9%84%d9%85%d9%84%d9%88%d9%83-%d9%88%d9%88%d8%b1%d8%ab%d8%aa%d9%87%d9%85-%d8%b5%d9%88%d8%b1 http://ko.wiktionary.org/wiki/%ea%b0%80%eb%8a%...

javascript - Animations in angular js check if an element is being tweened greenscok -

i wondering there better way this? trying find way can check if animation running on element if dis-regard click command causing animation there no duplicate element showing or repeating animations. here code it's working used factory store animating variable , if variable true won't start new animation. index.html <!doctype html> <html lang="en" ng-app="animate"> <head> <meta charset="utf-8" /> <title>js animation</title> <script src="lib/angular/angular.min.js"></script> <script src="lib/angular-animate/angular-animate.min.js"></script> <script src="lib/greensock/src/minified/tweenmax.min.js"></script> <link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap-theme.min.css" /> ...

ruby bundle install error when installing openproject -

i'm trying install open project , i'm stuck @ bundle install part ruby. when run "bundle install", following error: gem::installer::extensionbuilderror: error: failed build gem native extension. /usr/bin/ruby extconf.rb mkmf.rb can't find header files ruby @ /usr/share/include/ruby.h gem files remain installed in /home/openproject/openproject/vendor/cache/ruby/gems/debug_inspector-0.0.2 inspection. results logged /home/openproject/openproject/vendor/cache/ruby/gems/debug_inspector-0.0.2/ext/debug_inspector/gem_make.out error occurred while installing debug_inspector (0.0.2), , bundler cannot continue. make sure gem install debug_inspector -v '0.0.2' succeeds before bundling. i've tried installing gem same error. any appreciated. if need additional info, please let me know command need run information , i'll provide immediately. thanks! i able resolve downgrading centos 7 centos 6.5 — guess didn't ...

Nested projects in multiproject visual studio templates -

i need create vstemplate following structure. ecart - ecart.csproject - modules - folder - mvc.csproject how can add project within project? in case ecart web project , mvc project within modules folder of same project. here trying in template - <projecttemplatelink projectname="ecart"> ecart.vstemplate </projecttemplatelink> <projecttemplatelink projectname="mvc"> modules\mvc\mvc.vstemplate </projecttemplatelink> i did not find way modifying vstemplate file because vstemplate's schema not supporting nested project structure. hence found workaround (not liking though). implemented iwizard. zipped project , added zip file in folder structure wanted project in. programatically in runfinished method unzipped project , added project solution structure.

ruby on rails - Chewy RSpec Test - Expected index `client#person_client` to be updated, but it was not -

i using chewy interacting elasticsearch in rails app. trying add rspec test index (clientindex), think doing wrong here. my model client : class client < activerecord::base update_index('client#person_client') { self } end my clientindex : class clientindex < chewy::index settings analysis: { # ... } define_type client, name: 'person_client' field :id, value: ->(client) { client.id } field :name, search_analyzer: 'str_search_analyzer', index_analyzer: 'index_analyzer' field :name_sorted, value: ->(client) { client.name } field :email, search_analyzer: 'str_search_analyzer', index_analyzer: 'index_analyzer' field :created_at, type: 'date' end end and rspec test: rspec.describe clientindex "update index after save" client = fabricate.build(:client, id: 10) expect { client.save! }.to update_index('client#person_client') end end result: f...

matlab - Preserve blank space while using cellstr -

i'm trying store series of formated numbers strings in table , need preserve white spaces. don't know if there's better way store strings in table (any recommendation appriciated) i'm using. % initialize table mytable = array2table(cell(5,5)); % variables = 0.04; i want store '0.04 ' (with 2 blank spaces @ end) in first cell of mytable. tried: mytable{1,1} = cellstr([num2str(a), ' ']); however, know cellstr() doesn't preserve white spaces. don't know function use store variables. tried char() i'm getting errors. thank you! you might want try strcat : mytable{1,1} = strcat(num2str(a),{' '}) which gives output: mytable = var1 var2 var3 var4 var5 ________ ____ ____ ____ ____ '0.04 ' [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] ...

angularjs - Disabling checkbox with one way binding -

i have 1 checkbox list. need disable elements have model value set false initially. because of 2 way binding have problem when deselect 1 checkbox becomes disabled. how solve it? <div class="item-s" ng-repeat="element in model.elements"> <input id="element{{$index.tostring()}}" type="checkbox" ng-true-value="true" ng-false-value="false" ng-model="element.value" ng-disabled="!element.value" /> <label for="element{{$index.tostring()}}">{{element.name}}</label> </div> adding :: in front of binding expression causes evaluated once. should need: ng-disabled="::!element.value" here's angular's docs on one-time binding.

jquery - JQueryUI Widget extend - subscribe to event inside "_create" -

it long time working jqueryui. overriding autocomplete widget , trying internally subscribe ' select ' event reason (probably doing wrong) never reaches 'select' handler when item in menu selected: $.widget( "myautocomplete", $.ui.autocomplete, { _create: function(){ var element = this.element; this._super(); this._on(element, { 'select': function (){ // note: never riches } }); } }); there's no select event. select option provided convenience; actual name of event going myautocompleteselect : $.widget( "my.myautocomplete", $.ui.autocomplete, { _create: function(){ var element = this.element; this._super(); this._on(element, { 'myautocompleteselect': function (){ // reach } }); } }); the relevant bit in http://api.jqueryui.com/jquery.widget/ under events section: for widgets, when events triggered, names prefixed widget...

linux - get mangled symbol name from inside C++ -

how can mangled name of function inside c++ program? for example, suppose have header: // interface.h #ifndef interface_h #define interface_h typedef void (*foofunc)(int x, int y, double z, ...more complicated stuff...); void foo(int x, int y, double z, ...more complicated stuff...); #endif and have client program can load plugins implement interface: // client.h #include "interface.h" void call_plugin(so_filename) { void *lib = dlopen(so_filename, ...); // how implement next line? static const char *mangled_name = get_mangled_name(foo); foofunc func = (foofunc)dlsym(lib, mangled_name); func(x, y, z, ...); dlclose(lib); } how write get_mangled_name function compute mangled name of foo function , return string? one method comes mind compile interface.o , use nm -a interface.o | grep foo mangled name copy-and-paste hard-coded string client.h , feels wrong approach. another method comes mind force interface.h pure c interface marsha...

ruby on rails - Adding fonts to minimagick -

i'm using minimagick , want add text on images. need know how add additional fonts minimagick use. example, trying use chalkboard, osx font , getting error 'unable read font `chalkboard' @ warning/annotate.c/rendertype/898'. any on how can add in additional fonts.

In isabelle, why is this simplification lemma not being substituted? -

i'm working through isabelle "programming , proving" tutorial, , coming ex2.10, have arrive @ equation discribing number of nodes in "exploded" tree. the approach i've taken create separate expressions internal , leaf nodes in tree, , working on proof number of internal nodes in tree, such: lemma dddq: " a>0 ⟶ (nodes_noleaf (explode b) = (ptser (a - 1) (2::nat)) + ((2 ^ a) * (nodes_noleaf b)))" apply(induction a) apply(simp) apply(simp add:eeei eeed eeej eeek ) and leaves proof state following: goal (1 subgoal): 1. ⋀a. 0 < ⟶ nodes_noleaf (explode b) = ptser (a - suc 0) 2 + 2 ^ * nodes_noleaf b ⟹ suc (2 * nodes_noleaf (explode b)) = ptser 2 + 2 * 2 ^ * nodes_noleaf b now, created (and proved) lemma should replace ptser 2 + 2 * 2 ^ * nodes_noleaf b (suc (2 * ((ptser (a - suc 0) 2) + 2 ^ * nodes_noleaf b)))) , such: lemma eeek: "∀ b . a>0 ⟶ (((ptser 2) + 2 * 2 ^ * nodes_noleaf b) = (suc (2 * ((ptser (a - suc 0) 2) ...

hash - Double Hashing vs Linear Hashing -

i'm writing double hash table takes integer. unsigned int doublehashtable::hashfunction1(unsigned int const data) { return (data % gettablesize()); } unsigned int doublehashtable::hashfunction2(unsigned int const data, unsigned int count) { return ((hashfunction1(data) + count * (5 - (data % 5)) % gettablesize())); } and trying insert data table setdata() void doublehashtable::setdata(unsigned int const data) { unsigned int probe = hashfunction1(data); if (m_table[probe].getstatus()) { unsigned int count = 1; while (m_table[probe].getstatus() && count <= gettablesize()) { probe = hashfunction2(data, count); count++; } } m_table[probe].insert(data); } after put 100 of integer items table size of 100, table shows me of indexes left blank. know, takes o(n) worst case. question is, item should inserted table no empty space takes worst case of search time, right? can't find problem of functions....

php - Correct Object-Oriented Programming (Database Objects) -

my company switched php asp , asp.net. hosting asp, asp.net , php on iis running combined sessions. working on nice reusable database connection class , wanted see thought. tried search no fruitful results. this code non-operational. first attempt @ writing reusable class please bare me. first, is better create new connection object each time want call database? or better have continuous connection , reuse same connection? suggested crash server if created new connection each database call in script. here how doing it. $conn = new connectionclass; $result = $conn->createdataset('select whatever whereever;'); $conn2 = new connectionclas; $result 2 = $conn2->executescalar("insert (whatever) values ('whereever');") i asked set can call in one line on page without having create new object each time want use class functions. like: $result = $conn::createdataset("select whatever whereever"); $result2 = $conn2::insert("insert ...

linux - Regex for searching or gripping complex passwords in code repos -

i need regex use notepad++ "find in files" or find , grep command on linux find $dirs -type f -name '*.php' -o -name '*.sh' -exec grep -rhn "regex" make sure no passwords hard coded in our code repositories passwords should @ least 8 characters long , maximum 12 , should @ least have 1 lowercase,uppercase,digit characters , can have special characters or not here example passwords want match sh@r3d1nh3re f0llowup thanks it pretty impossible distinguish password other text/code, here regex looking for, match match whitespaces, including single , double quotes: [!-~]{8,12} if don't want include quotes , password must have quotes around try (not sure if you'll need escape start parenthesis, shouldn't hurt): ['"][!#-&(-~]{8,12}['"] note, grep, you'll have use -p option , escape double quotes, example: grep -p "['\"][!#-&(-~]{8,12}['\"]" if wanted ensu...

hadoop - How to fork actions in Oozie -

i have many sequence files , workflow of actions execute on each file. workflow same file , number of input file may vary. i'd execute workflow on bunch of input files (let's 10 files) in parallel using fork mechanism in oozie. if number of input files fixed, knew how many workflow should execute , write fork, may vary not know how should write fork. thoughts on that? you can write java oozie client accept number of files parameter , have many number of workflows invoked parallely , return on success of workflow executions. otherwise, might have programmatically generate workflow desired number of fork branches.

date - PHP timestamps & timezone configuration -

my plan: get current timestamp using strtotime("now") convert timezone '0' - part don't know how do. have number represents users timezone, -8 hours example. store in database in timezone '0' retrieve database in timezone '0' convert users timezone in opposite direction use date('', timestamp) function display it how can accomplish conversion? or going wrong? i need able store in database numerically represented time (like strtotime returns) using time() same strtotime("now") , not need worry converting timezone of timestamp, timestamp has no timezone: does php time() return gmt/utc timestamp? time returns unix timestamp, timezone independent. since unix timestamp denotes seconds since 1970 utc it's utc, has no timezone. you can store timestamp in database. when retrieve can convert users timezone. this: date_default_timezone_set('utc'); $timestamp = '1429066967'; ...

Continuous Integration With Gerrit and Xcode Server -

i trying run continuous integration ios xcode server running validation tests against gerrit. in order xcode pull gerrit server had upgrade it's libgit2.dylib version 0.21.5 i downloaded https://codeload.github.com/libgit2/libgit2/zip/v0.21.5 anyone have suggestion on how gerrit trigger xcode builds of particular branches? an easy way create xcode bot perform build. can have bot set poll gerrit’s repository periodically desired hook (most ‘commit’). http://bjmiller.me/post/72937258798/continuous-integration-with-xcode-5-xctest-os-x step-by-step guide on setting xcode bot, keep in mind using gerrit git repository. with xcode bot created, create gerrit hook triggers build in same manner xcode git repository would: custom trigger scripts bot (xcode 5 ci)

Devise Rails 4 RSpec 3 - Validates email with regex ending by @grenoble-em.com -

i stuck trying forbid user registering on devise without email address ending "@grenoble-em.com". validation add in use model ? cheers you don't need use regex that, can use index : "good.mail@grenoble-em.com".index("@grenoble-em.com", -16) where 16 position end of string , number of letters of searched substring.

c++ - Overloading Multiplication Operator -

i working on assignment c++ class. having overload several operators such +, -, !=, =, etc. well, have of them figured out except multiplication. have tried gives overflow or doesn't compile. not sure need it. here header file holds overloads. #ifndef complexnumber_h #define complexnumber_h #include<iostream> using namespace std; class complexnumber{ public: double real, imaginary; complexnumber(){ real = 0; imaginary = 0; } complexnumber(double a, double b){ real = a; imaginary = b; } complexnumber(double a){ real = a; imaginary = 0; } complexnumber & operator= (const complexnumber & rhs){ if(this == &rhs){ return *this; } else{ real = rhs.imaginary; imaginary = rhs.imaginary; } return *this; } complexnumber & operator+= (const complexnumber &rhs){ real += rhs.real; ...

python - Converting numpy array svg image -

i have image want save in svg format. image in form of numpy array. although, there exist many methods save array in different image formats, not find 1 says done in svg. any pointers or python script great! thanks since image in raster format, best can convert vector graphics program potrace . has python bindings pypotrace . example code: import numpy np import potrace # make numpy array rectangle in middle data = np.zeros((32, 32), np.uint32) data[8:32-8, 8:32-8] = 1 # create bitmap array bmp = potrace.bitmap(data) # trace bitmap path path = bmp.trace() # iterate on path curves curve in path: print "start_point =", curve.start_point segment in curve: print segment end_point_x, end_point_y = segment.end_point if segment.is_corner: c_x, c_y = segment.c else: c1_x, c1_y = segment.c1 c2_x, c2_y = segment.c2

Permission error while adding new physical device to QEMU under libvirt? -

i'm trying add usb camera qemu can virtualized guest os. i've added following item in /etc/libvirt/qemu.conf. cgroup_device_acl = [ "/dev/null", "/dev/full", "/dev/zero", ... "/dev/rtc", "/dev/hpet", **"/dev/video0",** ] also, i've mounted cgroup controller below. mkdir /dev/cgroup mount -t cgroup none /dev/cgroup -o devices but i'm getting "permission denied" error(13) in following code. fd = open("/dev/video0", o_rdwr | o_nonblock, 0); strange observation error happens when use virt-manager(libvirt). issue disappears when qemu run command-line. there anyway give device access qemu in libvirt? or more step check libvirt/qemu.conf? very long shot, did had chance go through page on libvirt docs ? it's different issue, it's being stated there, disabling selinux 1 of steps required.

mysql - Mysqli Join unexpected ";" -

im getting error unexpected ";" on code. dont know issue :( $getproducts = $mysqli->query("select orders.id id, orders_items.qty qty, shopping_products.title title orders join orders_items on orders_items.ordersid = orders.id join shopping_products on shopping_products.id = orders_items.shopping_productsid orders.authorid = ".$userid."" );

Rails 4: is it possible to extract complex authentication logic out of the controller? -

conventional rails best practices seek reduce logic code in controllers engineered route , not perform complex tasks. however, if have semi-complex authentication logic, how can reasonably extract logic out of controller? the following seems me "standard" logic basic application. while logic relates directly "routing", seems i'm putting logic controller , isn't small...am going overkill here? is possible extract logic separate class since redirect_to ... method accessible in controllers? class sessionscontroller < applicationcontroller # login page posts here perform authentication logic def create user = user.find_by(email: params[:email]) if user , user.authenticate(params[:password]) # default has_secure_password if user.confirmed? if user.account.active? flash[:notice] = "successfully logged in" redirect_to root_path else flash[:error] = "this account no longe...

java - Insert data into MySQL using JDBC -

i trying insert data mysql database using jdbc. problem in second row data starts end of first! . the picture explains better me . example of code. stored first column , down. public static void main(string[] args) throws sqlexception { connection conn = null; statement stmt = null; try{ //step 2: register jdbc driver class.forname("com.mysql.jdbc.driver"); //step 3: open connection system.out.println("connecting selected database..."); conn = drivermanager.getconnection("jdbc:mysql://83.212.124.175:3306/zadmin_java?useunicode=yes&characterencoding=utf-8","username", "pass.." ); system.out.println("connected database successfully..."); //step 4: execute query system.out.println("inserting records table..."); stmt = (statement) conn.createstatement(); (int j=1; j<=1;j++){ document mobilephones = jsoup.con...

mysql - How to select count over 2 columns in sql -

can suggest me query combined count 2 columns. specific requirement following: a b permission -------------------------- 1 2 accept 2 3 accept 3 4 accept 1 6 accept 1 4 accept 2 1 accept 3 1 accept 4 1 pending i want count of 1 whether belong a or b , permission ' accept '. above example need output 5 you can denormalizing first data using union all , use count achieve desired result: with sampledata(a, b, permission) as( select 1, 2, 'accept' union select 2, 3, 'accept' union select 3, 4, 'accept' union select 1, 6, 'accept' union select 1, 4, 'accept' union select 2, 1, 'accept' union select 3, 1, 'accept' union select 4, 1, 'pending' ) select t.colvalue, valuecount = count(*) ( select col = 'a', colvalue = a, permissi...

php - Why is data I upload getting renamed, and corresponding data added to different rows? -

Image
when insert data database, data submits successfully, have no idea how "success" message display informing me data has been sent successfully; have assume been submitted successfully. then, when check in database, data there, not in way want. upload image, spongebob.png , image gets sent database 15-04-2015-1429064604.png , , image , data corresponding image inserted on separate rows data on row above image... no idea why. i want image name same image uploaded, , on same row other data. a screenshot of i'm getting: here's html: <form action="insert_backend.php" method="post" enctype="multipart/form-data"> <!-- method can set post hiding values in url--> <h2>form</h2> <label for="uploadedimage">small image upload: </label> <input type="file" name="uploadedimage" id="uploadedimage"/><br /> <label>date:</label> <i...

php - MySQL - Build a query string -

i've tried of below yet can't seem working $sql="update filename set weekday = {$_get[wkd]} id = 2"; $sql="update filename set weekday = '$_get[wkd]' id = 2"; $sql="update filename set weekday = '"{$_get[wkd]}"' id = 2"; $sql="update filename set weekday = '."{$_get[wkd]}".' id = 2"; what correct way? thanks the proper way? assuming $link mysqli_connect $wkd = mysqli_real_escape_string($link, $_get['wkd']); $sql = "update filename set weekday = '" . $wkd . "' id = 2"; http://de1.php.net/manual/en/mysqli.real-escape-string.php

workflow - Falcon & Oozie - How to configure job.properties for oozie in falcon -

i have oozie workflow calls sqoop , hive action. individual workflow works fine when run oozie command line. since sqoop , hive scripts vary, pass values workflow.xml using job.properties file. sudo oozie job -oozie http://hostname:port/oozie -config job.properties -run now want configure oozie workflow in falcon. can please me in figuring out can configure or pass job.properties? below falcon process.xml <process name="demoprocess" xmlns="uri:falcon:process:0.1"> <tags>pipeline=degingestdatapipeline,owner=hadoop, externalsystem=svservers</tags> <clusters> <cluster name="democluster"> <validity start="2015-01-30t00:00z" end="2016-02-28t00:00z"/> </cluster> </clusters> <parallel>1</parallel> <order>fifo</order> <frequency>hours(1)</frequency> <outputs> <output name="output" feed="demofeed" inst...

php - Dropzone JS add Remove Button -

sorry im stil newbie dropzone, need create remove button dropzone js after file success upload tried using if(typeof dropzone != 'undefined') { dropzone.autodiscover = true; $(".dropzone[action]").each(function(i, el) { $(el).dropzone(); }); dropzone.createelement("<button>remove file</button>"); } the remove button still not show on buttom of tumbnails. page : <form action="data/upload-file.php" class="dropzone"></form> my php upload file <?php header('content-type: application/json'); #$errors = mt_rand(0,100)%2==0; // random response (demo purpose) $errors = false; $resp = array( ); # normal response code if(function_exists('http_response_code')) http_response_code(200); # on error if($errors) { if(function_exists('http_response_code')) http_response_c...

javascript - Split and group a collection of items in Ember -

i'm trying take collection of records in ember , split them groups of number, 2. so example, {{#each node in model}} <span>node.name</span> {{/each}} i <span>thing</span><span>other thing</span><span>some thing</span><span>one more thing</span> i want able pass node , wrap every 2 nodes div <div><span>thing</span><span>other thing</span></div><div><span>some thing</span><span>one more thing</span></div> in ember 2.0 should component, best place handle logic. should component or controller? given principle things related display, or preparations therefor, belong in component, prefer component. so: partitions: computedpartition('model', 2) then in template {{#each partition in partitions}} <div> {{#each node in partition}} {{node.name}} {{/each}} </div> {{/each}} now remains write com...

How to run multiple update statements in TOAD for Oracle -

i have 800 update statements want run in toad update my_table set col1 = 'a' col2 = '1'; update my_table set col1 = 'b' col2 = '2'; update my_table set col1 = 'c' col2 = '3'; update my_table set col1 = 'd' col2 = '4'; i have tried: hitting f5 selecting , hitting f5 wrapping statements in: begin (update statements) end; / all no avail. pops processing window , says 1 of 800... , never completes first statement. f9 complete first statement nothing else. ideas? toad v11.5.1.2 i have tried hitting f5, selecting , hitting f5, wrapping statements in: you don't need wrap update statements within begin-end block . execute script or press f5 update statements in same worksheet.

Password guessing with Brute force attack -

when key guessing, key length used in cipher determines practical feasibility of performing brute-force attack, longer keys exponentially more difficult crack shorter ones. cipher key length of n bits can broken in worst-case time proportional 2^n , average time of half that. average combination 2^n-1. why formula 2^n consist of 2? the key length measured in bits binary value. either 0 or 1, there's 2 different possible answers each position. a key length of 1 can either 0 or 1. 2 possible combinations. can represented 2^1. a key length of 2bits can 00, 01, 10, 11. 4 possible combinations, or 2^2. the 2 constant, it's number of bits change.

Meaning of enum values starting at 0x0007 -

i'm looking through header files of library i'm using (i don't have implementation source files), , noticed there set of enums proceed (simplified): enum type { type1 = 0x0007, type2 = 0x000a, type3 = 0x000b, type4 = 0x000c, type5 = 0x000d, type6 = 0x000e, type7 = 0x000f, type8 = 0x0010, }; i'm familiar seeing 1,2,4,8... progression using enums bit flags, 7,10,11... kind of standard pattern? know there's not meaning values, seemed oddly specific since of values sequential. it isn't unusual see progression missing numbers. might used internally library, used other external component library interfaces, or reserved future development. to safe, use defined values.

javascript - class selectors for jquery buttons not responsive -

i'm incorporating jquery html file , have had trouble getting button produce action when click on it. i've managed produce alert event whereby click on div, button different matter. <script type = "text/javascript"> alert("i alert box!"); $("div").click(function(){ alert("test1"); }); $(".btn-green").click(function(){ alert("test2"); }); </script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <div class="page-content-wrapper"> <div class="page-content"> <!-- begin page header--> <div class="row"> <div class="col-md-12"> <!-- begin page title & breadcrumb--> <h3 class="page-title"> verification & validation tools <small>statistics , more...