Posts

Showing posts from January, 2010

How to import a module in Python 3 from a string? -

a solution problem available python 2, uses imp module deprecated in python 3. imp has been replaced importlib works file based imports. specifically, importlib.import_module requires file name - not string or file handler. i made workaround dumping contents of url file , importing it def initlog(): modulename = '_mylogging' try: import _mylogging except importerror: r = requests.get('http://(...)/mylogging.py') open(modulename+'.py', "w") f: f.write(r.text) finally: import _mylogging return _mylogging.mylogging().getlogger() but avoid intermediate file. putting security, network performance , availability issues aside - is there way feed string importlib ? (or file handler, in case use io.stringio ) you can adapt exactly same answer 3.x, using the replacement imp.new_module : from types import moduletype foo = moduletype('foo') and the replaceme...

r - VennDiagram without group names and with Arial font -

Image
i have been requested redo following venn diagram in r arial font , without group names... looking @ venndiagram manual not see how can it... this mwe: #install.packages("venndiagram") library(venndiagram) <- c(1,2,3,4,5,6) b <- c(4,5,6,7,8,9,10,11,12) c <- c(1,2,10,11,12,5,13,14,15,16) venn.diagram(list("a" = a, "b" = b, "c" = c), fill = c("red", "blue", "green"), alpha = c(0.5, 0.5, 0.5), cat.cex = .75, cex = .75, lty =2, lwd =0.5, fontfamily ="serif", filename = "test.tiff", imagetype = "tiff", height = 3000, width = 3000, resolution = 1500, units = "px", main="title", main.pos=c(0.1,1.05), main.fontfamily="serif", main.cex=.75) is possible remove group names a, b, , c, , change font family arial, or should think approach instead of r? besides, p...

java - libgdx: Why does my custom actor have a memory leak? -

i have created following custom actor draw lines on libgdx public class linewidget extends actor implements disposable { private position posa; private position posb; public final vector2 _a; public final vector2 _b; private textureregion linetexture; private final textureregion linetexturegreen = assets.instance.images.linegreen; private final textureregion linetextureorange = assets.instance.images.lineorange; private final textureregion linetexturered = assets.instance.images.linered; public linewidget(position a, position b) { this._a = a.getpositionvector(); this._b = b.getpositionvector(); this.posa = a; this.posb = b; } @override public void act(float delta) { super.act(delta); } @override public void draw(batch batch, float parentalpha) { super.draw(batch, parentalpha); setlinecolor(posa, posb); float xdif = _b.x-_a.x; float ydif = _b.y-_a.x; float l2 = xdif*xdif+ydif*ydif; float invl = (float)(1/math.sqrt(l2)); //di...

Django Class-based Views with Multiple Forms -

by default django’s class-based views support single form per view. i need more forms per view because want combine foreignkey relations various modelform instances , appear in formmodel. in django documentation , other tutorials found formsets, in default examples repeat same form multiple times, not need. inline formsets looks need , didn't found example gcbv createview. can give me examples, link tutorial ? for example: class product(models.model): name = models.charfield(max_length=200,db_index=true) class productimage(models.model): # foreign key product = models.foreignkey('products.product', on_delete=models.cascade) image = models.imagefield(upload_to=upload_to) class productcreateview(createview): model = product form_class = productmodelform success_url = '../' class productmodelform(forms.modelform): class meta: model = product in template want appear in same form product form fields, image field, can repeated multi...

html - File Attachment not going in mail in php -

i making form in html in there upload button , details of user.i want send details of form along file uploaded user.but not working.i posting both code of html code , php code also. tell me missing. <!doctype html> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> <body> <div class="element"> <a href="index.php"><img src="logo.gif"></a> <br><br> <div class="new"></div> <center><h2>submit information below</h2></center> <form name="registration" method="post" action="fromaction.php" enctype="mutipart/form-data" autocomplete="off"> <!-- <span class="erorr"> ---> <div class="image"></div> <label>name:</label> ...

c# - Tracing variables passing on a multi class level -

i working on c# static source code analysis tool roslyn , need ideas on how implement/keep track of path of variables passing. given: a = request.query; b = a; c = a; somesink(b); i must able provide path a->b, b->somesink(b) . basic idea program should take account complex cases such variables passing through multi-class files, variables additional i.e a = b + c . scope of project c# project, library works c# do, using roslyn parse source codes , doing analysis it.

java - How to define gradle "runtime" -

i using spring boot gradle. gradle pack application jar these tasks: bootrepackage { mainclass = 'tv.mukamuka.api.application' } jar { destinationdir = file(destpath) basename = project.name } and dependencies below: compile('com.eclipsesource.j2v8:j2v8_macosx_x86_64:3.1.6') runtime('com.eclipsesource.j2v8:j2v8_linux_x86_64:3.0.0') however, bootrepackage task doesn't build jar runtime dependencies. how can define "runtime" in build?

java - running gradle "war" doesn't include dependent intellij project -

i have intellij project 2 modules: web-services (my api), library-services (business logic). build.gradle of web-serivces: apply plugin: 'java' apply plugin: 'war' apply plugin: 'maven-publish' apply from: ext.gradledir + '/common.gradle' apply from: ext.gradledir + '/integration_test.gradle' sourcecompatibility = 1.8 targetcompatibility = 1.8 project.version = '1.0.' + getbuildnumber() dependencies { compile project(':library-services') compile('com.waze.automation:common:1.0.80') compile('com.sun.jersey:jersey-bundle:1.19') compile('com.sun.jersey:jersey-json:1.19') compile group: 'org.codehaus.jackson', name:'jackson-jaxrs', version: '1.1.1' compile('com.google.guava:guava:18.0') testcompile group: 'junit', name: 'junit', version: '4.11' testcompile('org.hamcrest:hamcrest-all:1.3') testc...

c# - PropertyChanged is ignored when Binding to IEnumerable where reference stays the same -

i created minimal example illustrate binding issue. ienumerable<string> newreference gets updated expected. ienumerable<string> samereference not updated, presumably because reference same. raise("samereference"); not enough make wpf update reference. is there can done make wpf framework revaluate samereference though has same reference? xaml: <window x:class="stackoverflow.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525"> <grid background="azure"> <grid.rowdefinitions> <rowdefinition height="5*"/> <rowdefinition height="1*"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition/> ...

angular - Async form validation with debounce? -

i wondering how can implement debounce time on async validator. i have following: ... password: ['',validators.compose([validators.required, this.passwordvalid])] ... where: passwordvalid(control:control):{ [key: string]: any; } { return new promise(resolve => { this._http.post('/passwordcheck', control.value) .subscribe( success=>{ resolve(null); }, error=>{ resolve({passwordvalid: false}) } ) }) } however now, validation triggered @ each keystroke. need add debounce functionality. how can that? it's not possible out of box since validator directly triggered when input event used trigger updates. see line in source code: https://github.com/angular/angular/blob/master/modules/angular2/src/common/forms/directives/default_value_accessor.ts#l23 if want leverage debounce time @ level, need ...

c++ - linux linking to a .so , but still getting undefined reference -

i trying create executable uses code both static libraries , shared library: the static libs several boost .a , pthread , libbus.a . shared lib libwrap.so . note libwrap , uses code libbus , libbus uses code pthread . finally, executable uses code libwrap , boost . since order of libraries included in linker matters trying find "winning" sequence. the linking stage following (pasted in multiple lines convenience): $ /usr/bin/c++ -wall -wextra -fpic -fvisibility=hidden -fno-strict-aliasing -wno-long-long -m64 -rdynamic -d_unicode -dunicode cmakefiles/wrapper_test.dir/test.cpp.o /usr/local/lib/libboost_log.a /usr/local/lib/libboost_system.a /usr/local/lib/libboost_filesystem.a /usr/local/lib/libboost_date_time.a /usr/local/lib/libboost_thread.a /usr/local/lib/libboost_log_setup.a /usr/local/lib/libboost_chrono.a -pthread /home/nass/dev/data_parser/trunk/external/lib/linux64_g...

ruby on rails - Failed in deploying to Heroku -

when deploying ruby on rails app heroku, an application error page , here when typing heroku logs in terminal line, following information not know how process? can tell me need solve issue? 2016-07-11t11:12:32.333185+00:00 heroku[api]: release v2 created nicholas.wenzel@internsgopro.com 2016-07-11t11:12:32.333065+00:00 heroku[api]: enable logplex nicholas.wenzel@internsgopro.com 2016-07-11t11:13:09.721816+00:00 heroku[slug-compiler]: slug compilation failed: failed compile ruby app 2016-07-11t11:13:09.721807+00:00 heroku[slug-compiler]: slug compilation started 2016-07-11t11:17:24.819913+00:00 heroku[api]: set lang, rack_env, rails_env, rails_serve_static_files, secret_key_base config vars nicholas.wenzel@internsgopro.com 2016-07-11t11:17:24.820006+00:00 heroku[api]: release v3 created nicholas.wenzel@internsgopro.com 2016-07-11t11:17:25.503120+00:00 heroku[api]: attach database (@ref:postgresql-rectangular-14432) nicholas.wenzel@internsgopro.com 2016-07-11t11:17:25.503211+00:0...

Python HTML fill and submit form -

i trying write python script goes form on internal website (with name "defaultform") , fills in input name="username" field in form 'user001', input name="password" field 'pass001' , click on submit tried doing selenium , works. want accomplish same task requests(and beautifulsoup html scraping later on) code wrote not work! url = 'http://server:port/dashboard/portal' payload = {'username':'user001','password':'pass001'} r = requests.get(url, params=payload) print(r.text) i check content in r.text before , after requests.get(..) , both same. can me on how ? edit/update: tried submit form using lxml there seems error can't seem head around page = parse(url).getroot() page.forms[0].fields['username'] = 'user001' page.forms[0].fields['password'] = 'pass001' result = parse(submit_form(page.forms[0]).encode('utf-8')).getroot() print(result.text...

Elixir 1.3.0: String.strip/1 and String.strip/2 API documentation missing. -

it seems elixir 1.3.0 doesn't show anymore documentation string.strip/1 , string.strip/2: iex(1)> h string.strip no documentation string.strip found they missing in current online documentation (v1.3, master, stable), functions still recognized compiler: iex(2)> string.strip(" hallo, world! ") "hallo, world!" so i'm wondering if bug in string documentation, or if these functions going become deprecated. can't find better information googling. these functions have been soft deprecated. means have been marked @doc false . plan deprecate warnings 1.5 . https://github.com/elixir-lang/elixir/blob/v1.3/changelog.md#3-soft-deprecations-no-warnings-emitted [string] confusing string.strip/2, string.lstrip/2 , string.rstrip/2 api has been soft deprecated in favor of string.trim/2, string.trim_leading/2 , string.trim_trailing/2

Ruby on Rails: Braintree::AuthenticationError -

hello there have problem braintree implementation! created sandbox account on braintree websites , added gem gemfile: gem 'braintree', "~> 2.62.0" create file /initializers/braintree.rb: braintree::configuration.environment = :sandbox braintree::configuration.merchant_id = env['merchant_id'] braintree::configuration.public_key = env['public_key_b'] braintree::configuration.private_key = env['private_key_b'] (i use figaro gem handle constant: application.yml merchant_id : "xxxxxxxxxxxxxxxx" public_key_b : "xxxxxxxxxxxxxxxxx" private_key_b : "xxxxxxxxxxxxxxxxxxxxxxxxxx" ) added route following documentation in routes file: scope '/api' scope '/v1' scope '/client_token' '/' => braintree::clienttoken.generate end ... end end now if start server via command rails s following error: ...

Gulp Useref Nested Directories -

i'm gulp novice directory structure this: .tmp │ file001.html │ file002.html | ... │ |───js | │ file1.js | │ file2.js └───css │ file1.css │ file2.css | └───folder1 │ file011.html │ file012.html │ ├───subfolder1 │ │ file111.html │ │ file112.html │ │ ... │ └───folder2 │ file021.html │ file022.html | here useref task gulp.task('useref', function() { return gulp.src('.tmp/**/*.html') .pipe(useref()) .pipe(gulpif('*.js', uglify())) .pipe(gulpif('*.css', cssnano())) .pipe(gulp.dest('dist')); }); and here html <!--build:css /css/styles.min.css--> <link rel="stylesheet" href="/css/file1.css"> <link rel="stylesheet" href="/css/file2.css"> <!--endbuild--> <!--build:js /js/main.min.js --> <script src="/js/file1.js"></script> <script src="/...

c# - Smooth Expanding and Collapsing Animation for WinForms -

im trying smooth expanding , collapsing animation form. current animation jittery , non consistent. heres gif of animation . there way doesnt freeze form? private void showhidetoggle_checkstatechanged(object sender, eventargs e) { if (showhidetoggle.checked) //checked = expand form { showhidetoggle.text = "<"; while (width < originalwidth) { width++; application.doevents(); } } else { showhidetoggle.text = ">"; while(width > 24) { width--; application.doevents(); } } } create timer : timer t = new timer(); t.interval = 14; t.tick += delegate { if (showhidetoggle.checked) { if (this.width > 30) // set form.minimumsize otherwise timer keep going, permanently try decrease size. this.width -= 10; ...

Office add-in - on key pressed - installer -

i develop office add-in microsoft word using html5/javascript api , need following questions: does word javascript api have event "on key pressed"? time user typing in document able catch event on add-in? is possible install word add-in directly without using office store? can bundle add-in own installer (for example nsis installer) thanks shai there's no api on on-key-pressed event. the closest option documentselectionchanged api event, fires every time user's selection changes. in word, event fires on key presses, such as: any arrow key press enter tab clicking position cursor in document (not key press) the first key press of kind (letter, number, etc.) follows 1 of above types of key press. here's sample: var doc = office.context.document; doc.addhandlerasync(office.eventtype.documentselectionchanged, function(eventargs){ // when selection changes }); -michael saunders, program manager office add-ins

angular - Internationalize and Localize option using Ionic2/Angular2 -

i developing ionic2/angular2 app android mobile. i want provide option user choose language option in login page. is there way app level internationalization using ionic2/angular2? i have not seen many examples device level internationalization. you need these: translate_providers, translateservice, translatepipe, translateloader, translatestaticloader you can find them here, example: import {http_providers} '@angular/http'; import {component, injectable} '@angular/core'; import {translate_providers, translateservice, translatepipe, translateloader, translatestaticloader} 'ng2-translate/ng2-translate'; import {bootstrap} '@angular/platform-browser-dynamic'; bootstrap(appcomponent, [ http_providers, // not required, recommended have 1 unique instance of service translate_providers ]); @component({ selector: 'app', template: ` <div>{{ 'hello' | translate:{value: param} }}</div...

mapping - How many 5-input LUT functions are mappable to two cascaded 4-input LUTs? -

the questions can made more precise: out of 2 2 5 = 0x100000000 different functions realizable in 5-input lut, 0x3c1d3c82 functions realizable 2 cascaded 4-input luts? background one of standard building blocks in fpgas 4-input look-up table. 1 such table can realize 2 2 4 functions. standard method construct arbitrary 5-input lut use 3 4-input luts, 2 levels of logic, , use second level lut 2-to-1 multiplexer. arbitrary function f5(i4,i3,i2,i1,i0) may represented ff5(i4,g4(i3,i2,i1,i0),h4(i3,i2,i1,i0)), illustrated below. ___ ___ i3 ---|i3 | ---|i3 | i2 ---|i2 | i4 ---|i2 |--- ff5 i1 ---|i1 |------- h4 ---|i1 | i0 ---|i0_| +--- g4 ---|i0_| ___ | i3 ---|i3 | | i2 ---|i2 |---+ i1 ---|i1 | i0 ---|i0_| more compact representation however, many 5-input functions can represented 2 cascaded 4-input luts, gg(hh4(j4,j3,j2,j1),j2,j1,j0) j n 's permutation of i n (n 0 4). graphically...

php - Call to undefined function MYSQL_NUM_ROWS() -

this question has answer here: deprecated: mysql_connect() 15 answers i trying validate login php getting error : fatal error: uncaught error: call undefined function mysql_num_rows() in /opt/lampp/htdocs/social/index.php:100 stack trace: #0 {main} thrown in /opt/lampp/htdocs/social/index.php on line 100 here code if(isset($_post['login'])){ $studentid = $_post['studid']; $pass = $_post['password']; $query2 = mysqli_query($con, "select * members student_id = '$studentid' , password = '$pass' ") or die (mysqli_connect_error()); while($studid = mysqli_fetch_object($query2)) { echo "$studid->member_id"; } $numberofrows = mysql_num_rows($query2); if ($numberofrows == 0) { ...

c - Different even and odd sorting in Quicksort -

i've got such algorithmic problem: need make quicksort work this: 1) indexes of array odd numbers should sorted smallest largest 2) indexes should sorted largest smallest. so if we've got array: 2 5 1 3 4 0 6 2 5, should sth like: 6 0 5 2 4 3 2 5 1 here implementation of quicksort in c: void quicksort(int tab[], int start, int end) { int i=start; int j=end; int x=tab[(i+j)/2]; { while(tab[i]<x) i++; while(tab[j]>x) j--; if(i<=j) { int tmp=tab[i]; tab[i]=tab[j]; tab[j]=tmp; i++; j--; } } while(i<=j); if(start<j) quicksort(tab,start,j); if(i<end) quicksort(tab,i,end); } is possible make using 1 quicksort or should try sth creating 2 functions: 1 sort odd indexes , second 1 indexes? is possible make using 1 quicksort or should try sth creating 2 functions: 1 sort odd indexes , second 1 indexes? quick sort ...

reactjs - Redux: the previous state received by the reducer has unexpected type of "Function" -

when add middleware chrome extension, reducers stop working on site (but chrome/redux debug tool works) + following error in console: the previous state received reducer has unexpected type of "function". expected argument object following keys: "auth", "common", "home" here code: import { applymiddleware, createstore } 'redux'; import { promisemiddleware, localstoragemiddleware } './middleware'; import reducer './reducer'; const middleware = applymiddleware(promisemiddleware, localstoragemiddleware); const store = createstore(reducer, middleware, window.devtoolsextension ? window.devtoolsextension() : f => f); export default store; if remove chrome part: ,window.devtoolsextension ? window.devtoolsextension() : f => f if works normal again. createstore takes 3 arguments. if second argument function assumes second argument store enhancer. if object or there 3 arguments present a...

php - how to search result in codeigniter using age and cast -

this model have search result using mysql , codeigniter result searching fine show male not showing age , cast properly public function get_selected($age, $cast) { $this->db->select('*'); $this->db->from('bride_groom_register'); $this->db->like('age', $age); $this->db->or_like('cast', $cast); $this->db->where("gender='male'"); $data = $this->db->get(); if ($data->num_rows() > 0) { return $data->result_array(); } else { return false; } } remove like , or_like use inside condition. if want provide gender give in same line. $this->db->where("age %$age% or cast %$cast%");

ms access - About SQL-injection in C# -

i visited link sql-injection. way use parameters is: cmd.commandtext = "update [something_table] set = @something id = 1;"; var pparameter = new oledbparameter("@something", oledbtype.int); pparameter.value = something; cmd.parameters.add(pparameter); but link says .parameters.addwithvalue method simpler: cmd.parameters.addwithvalue("@something", something); what's main different between these? can choose addwithvalue instead without consequences?

Puppet: Evaluating variables inside onlyif close -

i have variable set @ stage, variable boolean, @ point want exec command based on fact if variable true or false, this: exec { 'update-to-latest-core': command => "do something", user => 'root', refreshonly => true, path => [ "/bin/bash", "sbin/" , "/usr/bin/", "/usr/sbin/" ], onlyif => 'test ${latest} = true', notify => exec["update-to-latest-database"], } so command doesn't work ( onlyif => ['test ${latest} = true'], ) tried several other ways too, didn't work. simple cannot hard do. can me this, , explain rules behind getting commands execute inside onlyif close. (also cannot use if-close on higher level because have other dependencies ) since $latest puppet variable, not useful defer checking value until catalog applied. technically, in fact, cannot so: puppet interpolate variable's value ex...

html - Bootstrap carousel full screen on every device -

so want carousel should take full height , width of display monitor , scroll down. this , , images inside should fill parent while maintaining ratio. problem either have provide fixed height or take height of largest image. how can make carousel of full screen every device. $(document).ready(function() { $("#my-slider").carousel({ interval : 3000, pause: false }); }) .container-fluid { padding-right: 0px; padding-left: 0px; margin-right: 0px; margin-left: 0px; } <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mtjoasx8j1au+a5wdvnpi2lkffwweaa8hdddjzlplegxhjvme1fgjwpgmkzs7" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-flw2n01lmqjakbkx3l/m9eahuwpsfenvv63j5ezn3uzzapt0u7eysxmjqv+0en5r" ...

html - Jquery crop using canvas not working -

hi given below code. 1 html file. trying crop image box. when draw canvas resolutions coming wrong. please help. i need cut portion of image box lies. <html> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <style> body, html { height: 100%; margin: 0; padding: 0; width: 100%; } #container { width: 100%; height: 100%; position: fixed; } .cover-container { display: table; height: 315px; margin: 5% auto 0; width: 90%; position: relative; } #camera { height: 100%; position: fixed; width: 100%; } #camera2 { height: 100%; position: fixed; width: 100%; } #cover { display: block; height: 315px; left: 0; /* position: absolute; */ top: 0; width: 100%; } #capturebtn { z-index: 9999; width: 100%; height: auto; } #capturebtn input { width: 100px; height: 50px; margin: 0 auto; ...

html - CSS: Force a column to always have full height -

this question has answer here: how can make bootstrap columns same height? 29 answers i have following html : <div style="height: 80px"> ... </div> <div class="container-fluid"> <div class="row"> <div class="col-xs-2 col1">...</div> <div class="col-xs-10 col2">...</div> </div> </div> both col1 , col2 having height: auto; however, col2 gonna bigger col1 . don't want col2 have specific height. however, col1 full height , match whatever height col2 has. how can achieve in css/sass ? yes can using either flexbox or table : .row.equal { display: table; } .row.equal .column { display: table-cell; /* demo purposes */ max-width: 5em; border: 1px solid #fff; background-color: red; } .row.equal....

google api - Get Oauth token of googleAPI with REST client -

i going use google sheet api. want test rest client, so, first @ all, want example of how oauth token. no need give me google api doc because didn't me much. for example don't know put in "redirect_uri" or "state". can provide me full example of how token http rest client? i going use google sheet api. want test rest client, so, first @ all, want example of how oauth token. no need give me google api doc because didn't me much. i'll give quick sample on how use rest client sheets api v4 , generate token well. you'll learn how perform basic sheets v4 operation . go oauthplayground . scroll down google sheets v4. choose https://www.googleapis.com/auth/drive permission. click authorize apis , allow access. on step 2, click exchange authorization code tokens . generate access tokens. token has lifecycle of 3600 seconds. in request uri textfield, paste this: https://sheets.googleapis.com/v4/spreadsheets/ {spreadsheetid}/val...