Posts

Showing posts from May, 2011

jquery - (NodeJS + Express) Server isn't reading linked javascript file(s) from html -

i'm stuck, managed server on webhost working on aws + else in express.js have error: root@ip(censored):/home/ubuntu/(censored)# /home/ubuntu/(censored)/routes/index.js:15 $(document).ready(function() { ^ referenceerror: document not defined @ object.<anonymous> (/home/ubuntu/(censored)/routes/index.js:15:3) @ module._compile (module.js:570:32) @ object.module._extensions..js (module.js:579:10) @ module.load (module.js:487:32) @ trymoduleload (module.js:446:12) @ function.module._load (module.js:438:3) @ module.require (module.js:497:17) @ require (internal/module.js:20:19) @ object.<anonymous> (/home/ubuntu/forbiddenground/app.js:12:14) @ module._compile (module.js:570:32) @ object.module._extensions..js (module.js:579:10) @ module.load (module.js:487:32) @ trymoduleload (module.js:446:12) @ function.module._load (module.js:438:3) @ module.runmain (module.js:604:10) @ run (bootstrap_node.js:394:7) ...

How to pass <select> html data in bootstrap modal to jquery -

i'm trying figure out how pass selected value tag located in modal : <div class='row'> <div class='col-md-8'> <form class='form-inline'> <select class='form-control' name='sel1' id='sel1'> <option>1.00</option> <option>1.25</option> <option>1.50</option> <option>1.75</option> <option>2.00</option> <option>2.25</option> <option>2.50</option> <option>2.75</option> <option>3.00</option> <option>5.00</option> <option>inc</option> <option>drp</option> <option>wdrw</option> </select> </div> <div class='col-md-4' align='right'> <input style='display: block; width: 100%;' type='button' class='btn btn-success' value='e...

python - How to change sprite after certain amount of time? -

i'm making game , want change sprite punch image stand image after few frames can figure out. trying find solution last resort. in advance. import pygame import os import time pygame.init() # screen display_width = 1350 display_height = 700 screen = pygame.display.set_mode((display_width, display_height)) # colors white = (255, 255, 255) frame = 0 # constants clock = pygame.time.clock() # images img = pygame.image.load("stand.png") stand_img = pygame.image.load('stand.png') crouch_img = pygame.image.load('crouch.png') jump_img = pygame.image.load('jump.png') punch_img = pygame.image.load('punch.png') class fighter: def __init__(self, x_pos, y_pos, image, health): self.x_pos = x_pos self.y_pos = y_pos self.image = image self.health = health def draw(self): screen.blit(self.image, (self.x_pos, self.y_pos)) def move(self, accel_x, accel_y): self.x_pos += accel_x s...

ios - How to get a NSBatchDeleteRequest to delete and allow you to add back to an object again -

Image
i have following code. let workorderfetchrequest = nsfetchrequest<nsfetchrequestresult>(entityname: "workorders") let deleteworkorderrequest = nsbatchdeleterequest(fetchrequest: workorderfetchrequest) //deletes workorders //question delete references work orders correctly now? try context.execute(deleteworkorderrequest) //save work order objects (overwriting old ones same id if needed) { try context.save() print("saved context workorders") } catch let error nserror { print("could not save \(error), \(error.userinfo)") } catch { print("could not save, unknown error") } print("deleted references") a workorders looks this... import foundation import coredata extension workorders { @nonobjc p...

python 3.x - Py Elisticsearch query slow on laptop -

i running simple python elasticsearch query in script evaluates instantly on workstation, has ~3 second lag on laptop. i'm thinking memory usage thing i'm not sure best way adjust that. def searchdata(query): sdat = es.search(index="roasts", doc_type="roast", q=query) the indexed json files small. thinking instant. help!

windows - dotnet is not recognized as the name of a cmdlet -

we have downloaded , run dotnetcore.1.0.1-sdk.1.0.0.preview2-003133-x64.exe . after having closed , reopened our command prompt, running dotnet gives following output. the term 'dotnet' not recognized name of cmdlet, function, script file, or operable program. we have tried following: uninstall versions of visual studio. uninstall versions of .net core. repair c++ redistributable 2015 x86 & x64 restart computer. then reinstall .net core sdk. this contents of c:/program files/dotnet host fxr sdk 1.0.0-preview2-003133 shared microsoft.netcore.app swidtag microsoft .net core 1.0.1 - sdk 1.0.0 preview 2-003133 (x64).swidtag our path includes c:\program files\dotnet\ after again coming across problem, found answer here . open programs , features, choose microsoft visual c++ redistributable (x86), click uninstall , choose repair. after repairing (and x64 version if have it), reinstall or repair installation of .net core sdk 1.0.1. ...

java - Comparing two elements of a string array with .equals() -

i'm working on project , need compare 2 elements of same array private void checkimports() { //import tester for(int = 0; i<theclass.length;i++) { for(int j = 0; j<i; j++) { if(theclass[i].equals(theclass[j])) { system.out.println("there double import @ line " +i); adderror("double import @ line ",i) } } } } the array filled following strings: "import java.x;" //0 "import java.y;" //1 "import java.z;" //2 "import java.x;" //3 for reason when call equals() method never evaluates true when = 3 , j= 0. explanation why adderror method never called appreciated there 2 possible explanations (i mean, there many explanations, these 2 lend checking first, think): the comparison i==3 , j==0 never performed (even though think is). the values...

forms - How to use EL with <ui:repeat var> in id attribute of a JSF component -

i have following code: <ui:repeat var="class2" value="#{bean.list}" varstatus="status"> <h:form id="#{class2.name}"> <h:outputtext value="#{class2.name}" /> </h:form> </ui:repeat> however, when open page, errors follows: component identifier must not zero-length string but printed in <h:outputtext> . how caused , how can solve it? you can use el in id attribute of jsf component, el variable has available during view build time , while jsf component tree built. however, <ui:repeat> runs during view render time , while html output generated based on jsf component tree. <ui:repeat var> not available during view build time , #{class2.name} evaluates null totally explains error got. works in <h:outputtext> because runs during view render time. if replace <ui:repeat> <c:foreach> , runs during view build time, it'll work intented. ...

python 3.x - Giving multiple pipelines as input to Voting Classifier - sklearn -

i trying build voting classifier multiple pipelines input. pretty new @ this. following code using: clf1 = multinomialnb(alpha= 0.99, fit_prior= true) clf2 = pipeline([('vect', countvectorizer(max_features=5000,ngram_range=(1,2))), ('tfidf', tfidftransformer(use_idf= true)), ('clf', sgdclassifier(alpha=0.001,learning_rate='optimal',loss= 'epsilon_insensitive' ,penalty= 'l2',n_iter = 100, random_state=42))]) clf3 = pipeline([('vect', countvectorizer(max_features=3500)), ('tfidf', tfidftransformer(use_idf=false)), ('clf', svc(random_state= 42,kernel="linear",degree=1,decision_function_shape=none))]) clf4 = pipeline([('vect', countvectorizer(max_features = 4000)), ('tfidf', tfidftransformer(use_idf=false)), ('clf', rand...

swift3 - What is the Swift equivalency of NS_VALID_UNTIL_END_OF_SCOPE? -

Image
scenario: i'm translating objective-c sample code supplied apple swift 3.0.1. came across code requires need prevent presentationcontroller being released prior calling preventviewcontroller. hence use of ns_valid_until_end_of_scope (see image below). what's best alternative using swift? ...without it... nil transitioningdelegate value upon access afterwards. one thing can try using withextendedlifetime(_:_:) : override func perform() { let sourceviewcontroller = self.destination let destinationviewcontroller = self.destination // presentations use custom presentation controller, // possible presentation controller // transitioningdelegate. // // transitioningdelegate not hold strong reference // destination object. prevent presentationcontroller being // released prior calling -presentviewcontroller:animated:completion: // ns_valid_until_end_of_scope attribute appended declaration. let presentationcontrol...

html - Display in Chat -

to display chat window, ended code : function baja_el_chat() { var height = 0; $('div#my-conversation .message').each(function(i, value){ height += parseint($(this).height()); }); height += ''; $('div#my-conversation').animate({scrolltop: height}); } i did chat window scratch few weeks ago. way browser builds stack of divs make recent messages hidden below window's limits expected. same happened me built javascript/jquery function: function baja_el_chat() { var height = 0; $('div#my-conversation .message').each(function(i, value){ height += parseint($(this).height()); }); height += ''; $('div#my-conversation').animate({scrolltop: height}); } basically measure height of content based on sum of chat bubbles , scroll amount. call function every time user hits enter or receives new message.

spring - Java Config same annotation bean in multiple config classes -

i trying switch java config xml. we have core library, , implementations use core library. have webapp , cli in each implementation. trying modularize config. use component scanning packages. running circular dependency issue in config classes. need inject same @component beans created in multiple java config classes. configs follows: @configuration @componentscan(basepackages = {"my.components"}) @importresource({ "classpath:data-access-config.xml" }) @propertysource(value = "classpath:core.props", ignoreresourcenotfound = true) public class coreappconfig { @autowired environment env; @autowired componentbean bean; @bean public mybean mybean() { return new mybean(bean); } } @configuration @import({coreappconfig.class}) @propertysource(value = "classpath:my-app.props") public class myappconfig { @autowired environment env; @autowired componentbean bean; @bean public...

javascript - How to deconstruct an ES6 module joint export -

i've run little hiccup export scenario , not sure why. may need babel plugin address not sure which. // a.js export function froma() {} // b.js export function fromb() {} // index.js import * './a' import * b './b' export default { ...a, ...b} // test.js import './index' const { froma } = // works import { froma } './index' // not work. why? i running through babel. here's rc: { "plugins": [ "transform-object-rest-spread", "transform-class-properties", "transform-export-extensions", "transform-decorators-legacy" ], "presets": ["latest", "react"] } it seems should able destucture in test.js within import statement usual no. if, in index.js, export individual functions woks. in: import { froma } './a' import { fromb } './b' export default { froma, fromb } however i'd avoid that. though im...

java - How to read a file created at runtime? -

using java 8. basically, in unit test (junit) have code: callsomecode(); asserttrue(new file(this.getclass().getresource("/img/dest/someimage.gif").getfile()).exists()); in callsomecode() , have this: inputstream = bodypart.getinputstream(); file f = new file("src/test/resources/img/dest/" + bodypart.getfilename()); //filename being someimage.gif fileoutputstream fos = new fileoutputstream(f); byte[] buf = new byte[40096]; int bytesread; while ((bytesread = is.read(buf)) != -1) fos.write(buf, 0, bytesread); fos.close(); the first time test runs, this.getclass().getresource("/img/dest/someimage.gif") returns null although file created. the second time (when file created during first test run overwritten), non-null , test passes. how make work first time? should configure special setup in intellij automatically refresh folder file created? note have basic maven structure: --src ----test ------resources as comment n...

javascript - Get Js FormData() In Web Api -

is there trick getting formdata post request in web api? can't seem able use namevaluecollection or formdatacollection when submitting form on frontend using js formdata(). have checked http request verify form data being passed server. js form submit var formdata = new formdata(); formdata.append('email', 'email@notarealemail.com'); formdata.append('password', '123'); // submit data using xmlhttprequest controller web api public ihttpactionresult checkuser(formdatacollection formdata) { //formdatacollection , namevaluecollection don't seem return key based values } actually, in web api controllers should check property request information post page. next can data using appropriate method: request.content.readasbytearrayasync or request.content.readasformdataasync (it's case) or request.content.readasstreamasync , etc. depends on sent data format. or can create class respective fields , send in...

c# - How do I take the data from a .json file, use only some of the items in it, and populate a combobox with that data? -

what i'm looking take .json file, grab items file, , populate items in combobox filtered data (using newtonsoft / json.net). i'll give example: (some of the) json file data: [ { "name": "kerbol", "radius": 261600000, "mass": 1.7565670e+28 }, { "name": "moho", "radius": 250000, "mass": 2.5263617e+21 }, { "name": "eve", "radius": 700000, "mass": 1.2244127e+23 }, ] this isn't of data, of it. it's info on planets in game "kerbal space program". thing i'm interested in (right now) grabbing every "name" item in .json file. want populate items property in combobox of names (on each line). i've tried lot of other code filter out, don't understand enough rewrite work how need. edit: want more .json data later on, i'm trying 1 step @ time. edit2: windows forms. ...

rstudio - Rmarkdown: pandoc document conversion failed with error 43 because of large number -

i ran problems while knit pdf in rstudio via rmarkdown. suppose stems many digits value of quoted r variable outside chunk of code. --- title: "r notebook" output: pdf_document: default html_notebook: default --- ```{r} x <- 11111111111111 ``` testing `r x`. error ! missing $ inserted. <inserted text> $ l.133 testing 1.1111111\times pandoc: error producing pdf error: pandoc document conversion failed error 43 execution halted hope can me out here. this happens because long numbers transformed scientific notation (like 1.1e11) when printed, , because scientific notation makes use of latex math symbol \times . there 2 workarounds: disable scientific notation. can done options() . add chunk @ beginning of document: ```{r, echo=false} options(scipen = 99) ``` print number in math environment $ (this preserve scientific notation): testing $`r x`$.

php - Installing different Eclipse IDE distro vs. installing plugins to existing Eclipse IDE -

currently, i'm using eclipse neon , i'm thinking coding in php. usually, add appropriate plugins; 1 got me thinking on whether should install eclipse php developers instead. any thoughts on difference between installing php plugins vs. installing eclipse distro php? i prefer have eclipse installation tailored actual needs. therefore, if workspace holds php projects, i'd recommend using eclipse php developers package in case, ideally, wouldn't matter having many (unrelated) plug-ins within single installation. in reality, installing many plug-ins may increase time needed @ startup, because extensions of plug-ins need read increase likelihood of plug-ins not working together increase ui clutter caused contributions of many plug-ins

Get the top left coordinate of the each screen in C#, ignoring where the "Main" screen is located -

Image
i working on project (hobby) whereby draw stuff on 3 monitors. however, because of way drawing, if set monitors main screen center screen, when ask top left of each screen windows, adjusted coordinates - wrong, unless main monitor leftmost, , end 1 form missing, long 1 supposed centered on left, , window supposed leftmost, kinda spread across 2 monitors. does have ideas? i've been working @ particular problem day. vs (should noted middle monitor 16:10 , side monitors @ both 5:4) right pass screen object each form while setting up, , sets it's own location match screen - this.location = screen.bounds.location;

cpanel - How to increase WHM Max Files Upload Limits -

i purchased dedicated server , installed linux centos cpanel. i'm able increase file upload size limit 2gb maximum. have 6 tb space available. dedicated server purchased ovh.com, whm, how increase 10gb or more ? whm, how increase max files upload in 1 operation, there 6 files simultaneously allowed upload through cpanel. how change it? login inot whm goto software >> multiphp ini editor select php version dropdown want edit directives. once make necessary changes in directive, click on apply the changes applied websites using php version. if looking increase connection single ip goto service manager >> ftp server configuration >> maximum connections per ip address . allow increase concurrent connection single ip. maximum connections show number of concurrent ftp connection can made. hope helps.

loops - How To List Numbers on a Reverse Triangle on Java -

how can print out triangles listed numbers using loops. far manage print this: 1 x 2 x x 3 x x x 4 x x x x 5 x x x x x my next assignment same except must print "x" in reverse order user this: 1 x x x x x 2 x x x x 3 x x x 4 x x 5 x i manage make code print triangles number not in right place. printout this: 5 x x x x x 4 x x x x 3 x x x 2 x x 1 x 0 is there wrong doing? there else need do? here current code: public class problem4 { private static scanner input; public static void main(string[] args) { input = new scanner(system.in); system.out.print("enter number: "); int n = input.nextint(); (int = n; >= 0; i--) { system.out.println(" " + i); (int j = i; j > 0; j--) { system.out.print(" x"); } } system.out.println(""); } } modify code this: i...

ios - Switch tab bar view in subview programmatically (custom tab bar controller) -

because want redesign tab bar ui, wrote custom tab bar controller according https://github.com/codepath/ios_guides/wiki/creating-a-custom-tab-bar in tabbarviewcontroller 's viewdidload(), define several subviews corresponding each tab bar homeviewcontroller = storyboard.instantiateviewcontrollerwithidentifier("homeviewcontroller") ... viewcontrollers = [homeviewcontroller, searchviewcontroller, accountviewcontroller, trendingviewcontroller] and main method when tapping tab @ibaction func didpresstab(_ sender: uibutton) { let previousindex = selectedindex selectedindex = sender.tag tabbuttons[previousindex!].isselected = false let previousvc = viewcontrollers[previousindex!] // remove previous vc previousvc.willmove(toparentviewcontroller: nil) previousvc.view.removefromsuperview() previousvc.removefromparentviewcontroller() // set current vc sender.isselected = true let...

javascript - setInterval for input slider does not work properly -

my code house smoke coming out chimney. tthe smoke controlled setinterval function connects slider on html page suppose control speed @ smoke blows out when move slider, restarts smoke function. how set slider control speed of smoke? here code: /* draws each floor of canvas. */ function drawfloor() { ctx.fillstyle = "white"; ctx.fillrect(0, 250, 500, 250); } /* draws front side of house. */ function drawfront() { ctx.fillstyle = "#91aeac"; ctx.beginpath(); ctx.moveto(275,256); //tip ctx.lineto(325,350); //mid-right ctx.lineto(319,400); //bot-right ctx.lineto(250,387); //bot-left ctx.lineto(230,325); //mid-left ctx.closepath(); ctx.fill(); } /* draws side of house. */ function drawside() { ctx.fillstyle = "#6f978f"; ctx.beginpath(); ctx.moveto(325,350); //top-left ctx.lineto(412,325); //top-right ctx.lineto(400,375); //bot-right ...

laravel - ’Call to a member function make() on null‘ When installing Eloquence -

i'm trying install eloquence on laravel project. eloquence installation i'm following installation, , i've done following: require package in composer.json add eloquence trait model add sofa\eloquence\serviceprovider config/app.php providers array problem : post::search('jarek sofa')->get(); results in fatalthrowableerror in builder.php line 77: call member function make() on null here code possible reasons: the eloquence service provider wasn't registered properly maybe composer thanks in advance finally got work! solution : add \sofa\eloquence\builder::setparserfactory(new \sofa\eloquence\searchable\parserfactory); in appserviceprovider boot method this: <?php namespace app\providers; use illuminate\support\serviceprovider; class appserviceprovider extends serviceprovider { /** * bootstrap application services. * * @return void */ public function boot() { \sofa\elo...

javascript - Separating the POST requests of a Suitelet -

my goal attach custom submit button suitelet sends post request external server. problem having when rendering page function send() within custom button in form.addbutton('submit','submit', send(form)); running when page loaded. because of this, no data being sent send() function , therefore not being handled properly. from understand, problem has original post request rendering suitelet , interfering post request want send. need separate or differentiate post request renders form 1 sends form. ideal have done in user event script forms can used in suitelets in ss1.0... is there way possible? should use suitescript 2.0 achieve this? below how code looks: function main(request, response){ var form = nlapicreateform('submission form'); form.addfield('one', 'text', 'field 1'); response.writepage(form); form.addbutton('submit','submit', send(form)); } function send(form){ pro...

"Create project from template" missing for Spring MVC in IDEA 2016? -

Image
i remember before used able make spring mvc applications using idea , prompt me template, , if checked have application folders webapp, config xml files, etc. created in maven directory structure. right now, i'm trying make springmvc application using intellij idea 2016. set application follows: however afterwards prompted option: instead of option: i've tried go through settings, can't find how create springmvc application template in maven structure used able to. how can make can "create project template" option in intellij idea 2016?

Delphi reproduce OLE_COLOR -

trying reproduce ole_color translating value can use in delphi. particular need reproduce outlook olcategorycolor. can read integer: yellow gives 4641276, example, doesn't resemble equivalent of yellow can find. gather system.drawing has colorconverter method should trick, version of delphi (10 seattle) doesn't seem have system.drawing. appears available in delphi 7, , 1 add delphi 8 adding .dll project references, seattle doesn't seem have project references. thank always. the helper function colortorgb graphics unit converts ole color rgb. tests high bit being set, , if calls getsyscolor passing index encoded in rest of value. however, color value of 4641276 not of form. in hex $0046d1fc . plain rgb value.

r - Using SVM and mapreduce for text classification -

i'm new hadoop , mapreduce , trying use mapreduce train model using svm classify messages categories. currently, can on small set of data without mapreduce , rtexttools , e1701 use mapreduce train model larger training data. below code have used on small dataset. library("e1071") library("rtexttools") predicttest <- function(test_text, mat, classifier){ train_mat = mat[1:2,] train_mat[,1:ncol(train_mat)] = 0 test_matrix = create_matrix(test_text, language="english",removestopwords=t, removenumbers=t,stemwords=t, tolower=t, removepunctuation=t) test_mat <- as.matrix(test_matrix) for(col in colnames(test_mat)){ if(col %in% colnames(train_mat)) { train_mat[2,col] = test_mat[1,col]; } } #test_mat = as.matrix(t(test_mat)) row.names(train_mat)[1] = "" row.names(train_mat)[2] = test_text p <- predict(classifier, train_mat[1:2,]) as.character(p[2]) } #using smaller set of training data (large memory requirements) training_da...

openerp - How to create server actions in Odoo 10? -

in odoo 8, able define server action using xml such as: <?xml version="1.0" encoding="utf-8" ?> <odoo> <data> <record id="action" model="ir.actions.server"> <field name="name">my action</field> <field name="model_id" ref="model_module_model"/> <field name="code">self.action(cr, uid, context=context)</field> </record> </data> </odoo> this execute module.model.action() method. in odoo 10, code throws exception: error:odoo.http:exception during json request handling. traceback (most recent call last): file "/usr/share/odoo/lib/python2.7/site-packages/odoo/http.py", line 638, in _handle_exception return super(jsonrequest, self)._handle_exception(exception) file "/usr/share/odoo/lib/python2.7/site-packages/odoo/http.py", line 675, in dispatch result = self._call_function(*...

Using linux tc-ingress on android -

i'm trying use tc (traffic control) linux on android. far managed create qdisc root can't create qdisc ingress. following error. 2|root@dior:/ # tc qdisc add dev wlan0 handle ffff: ingress rtnetlink answers: no such file or directory is because of code or system not have ingress functionality?

xml - Show Feed with PHP -

want ask, see script thread. script still working fine want include many feed , bring on website, how can solve it? example: web1.domain.com/feed web2.domain.com/feed web3.domain.com/feed ... i want show feed subdomain top level domain. $rss = new domdocument(); $rss->load('http://web.domain.com/feed/'); $feed = array(); foreach ($rss->getelementsbytagname('item') $node) { $htmlstr = $node->getelementsbytagname('description')->item(0)->nodevalue; $html = new domdocument(); $html->loadhtml($htmlstr); //get first image tag description html $imgtag = $html->getelementsbytagname('img'); $img = ($imgtag->length==0)?'noimg.png':$imgtag->item(0)->getattribute('src'); $item = array ( 'title' => $node->getelementsbytagname('title')->item(0)->nodevalue, 'category' => $node->getelementsbytagname...

python - Int not iterable error -

i learning python online , need submit solution, have tried code locally , on repl.it , code runs unittest of online grader throws error: "there error/bug in code results: internal error: runtests aborted: testoutcomeevent(handled=false, test=, result=, outcome='error', exc_info=(, typeerror("'int' object not iterable",), ), reason=none, expected=false, shortlabel=none, longlabel=none) not json serializable" my code below: def calculate_tax(income2tax): zeropercentrate = 0.0 tenpercentrate = 0.1 fifteenpercentrate = 0.15 twentypercentrate = 0.20 twenty5percentrate = 0.25 thirtypercentrate = 0.30 ten = 9000 fifteen = 10200 twenty = 10550 twenty5 = 19250 taxedincome = {} rate = 0 name in income2tax: if (income2tax[name] <= 1000): rate = 0 taxedincome[name] = rate elif (income2tax[name] >= 1001) , (income2tax[name] <= 10000): ra...

How to Download database from hosting server plesk-web13 -

Image
i have database on plesk web hosting server, , i'd download it. how can achieve this? you can download database via domain's backup. here example plesk 12: