Posts

Showing posts from April, 2011

Django REST - separating valid data from non-valid and serializing the former with many=True -

i using django rest framework come rest api app. in 1 of views, trying use many=true when initializing serializer object in order bulk_insert multiple rows @ once. problem if 1 of records in dataset invalid, serializer's is_valid() method return false , rejecting entire dataset. whereas desired behavior inserting valid records , ignoring invalid ones. have succeed in achieving using following code, have terrible feeling junk code , rest framework has native way this. my code below (that consider junk code :)): serializers.py class myserializer(serializers.modelserializer): class meta: model = calendareventattendee fields = '__all__' view.py def my_view(request): validated_data = [] # separate valid data invalid record in request.data: if myserializer(data = record).is_valid(): validated_data.append(record) # bulk_insert valid data serializer = myserializer(data=validated_data, many=true) i

java - Convert JPA model classes into the MongoDB model class? -

i new mongodb , looking implement below 3 classes in mongodb. have annotated model class @document, not sure how can implement relationship ? how can implement relationship here ? authority.java @entity @table(name = "authority") public class authority { @id @column(name = "id") @generatedvalue(strategy = generationtype.sequence, generator = "authority_seq") @sequencegenerator(name = "authority_seq", sequencename = "authority_seq", allocationsize = 1) private long id; @column(name = "name", length = 50) @notnull @enumerated(enumtype.string) private authorityname name; @manytomany(mappedby = "authorities", fetch = fetchtype.lazy) private list<user> users; user.java @entity @table(name = "user") public class user { @id @column(name = "id") @generatedvalue(strategy = generationtype.sequence, generator = "user_seq&quo

r - prop.test function in a loop -

i wanting 2 sample proportions test in r using loop , split health center , measure. below link show example of how data set (the website not allow me upload image of dataset) basically, want compare health center a's measure a's using prop.test function , repeat health centers (29 of them) , measures (14 of them). not sure on code loop proportion tests want , split how want. any appreciated! i went ahead deleted 0's. however, code worked did not split data how wanted to. hoping split health center , measure instead splits health center have 28 measures prop.test analyzing instead of health center measure a. see output example below: click here see output you can perform split , prop.test using this lapply(split(df, df$health_center), function(x) prop.test(as.matrix(cbind(x[,3], x[,4]-x[,3])))) output $a1 2-sample test equality of proportions continuity correction data: as.matrix(cbind(x[, 3], x[, 4] - x[, 3])) x-squared = 1.713, df = 1,

Formatting html object to make card using css -

so i'm working on project , i'm having trouble css/formatting since i've never heavily used css before. below code snippet. in snippet text kinda far below image. need same height image , have same line spacing between lines (right bettween bold text , regular text there large space) prevent text wrapping under image. see link example of how need css make look. i'm not sure how , appreciated. <head> <style> * { box-sizing: border-box; } #myinput { background-image: url('/css/searchicon.png'); background-position: 10px 12px; background-repeat: no-repeat; width: 100%; font-size: 16px; padding: 12px 20px 12px 40px; border: 1px solid #ddd; margin-bottom: 12px; } #myul { list-style-type: none; padding: 0; margin: 0; } #myul li { /*border: 1px solid #ddd;*/ /* not needed @ point */

xamarin - I can not run my project on iphone -

Image
always when run project direct on iphone following error occurs what can cause since error, use visual studio 2017 , xamarin updated, xcode in mac updated. can not identify, know solution?

unit testing - How do I test Django views when they don't return values -

i'm new django. i've worked through tutorials, written models, views, forms etc. don't understand how can tested since either nothing returned, or whatever returned tightly bound doesn't make sense in terms of test. for example here 2 view classes: class listblogpostview(listview): model = blogpost template_name = 'app/blogpost_list.html' class createblogpostview(createview): model = blogpost template_name = 'app/blogpost_edit.html' form_class = blogpostform def get_success_url(self): return reverse('blogpost-list') def get_context_data(self, **kwargs): context = super(createblogpostview, self).get_context_data(**kwargs) context['action'] = reverse('blogpost-new') return context the first, listblogpostview, doesn't return anything. how can ever check working correctly? the second has couple of functions return values not things can test assert how

javascript - Glassdoor API 404 error chrome extension -

i'm writing chrome extension retrieves ratings companies on glassdoor. accomplish have content script send message background script make xmlhttprequest. the url used request was "http://api.glassdoor.com/api/api.htmv=1&format=json&t.p=177556&t.k=kvtuqd0ashs&userip=" + address + "&actions=employers&q=" + companyname + "&useragent=" + navigator.useragent both address , companyname defined before this. i got message: failed load resource: server responded status of 404 (not found) when ran script. in addition, got message: xmlhttprequest cannot load [above link]. no 'access-control-allow-origin' header present on requested resource. origin 'chrome-extension://maonbpchkpdlcpobmfdkkephdbniognp' therefore not allowed access. response had http status code 404. i checked format of api call several times, , can't find problem it. changed permissions in manifest file "all_urls" got ri

java - Load Python module to Jython from a dynamic library (.so) source -

i'm trying embbed python code inside java code. that, i'm using org.python.util.pythoninterpreter class (jython). i noticed when import modules have add path of modules (nltk, pywsd , others). to discover path necessary modules opened python console (2.7.12 , got file property module , added through sys.path.append method on jython (2.7.0). solution worked, when import _sqlite3 (implicit inside sqlite3 import), had trouble: no module named "_sqlite3" exists. the directory structure that: path add nltk module: /usr/local/lib/python2.7/dist-packages/ path add sqlite3 module: /usr/lib/python2.7/ path .so file (_sqlite3. file ): /usr/lib/python2.7/lib-dynload/_sqlite3.x86_64-linux-gnu.so some observations: _sqlite3 .__ file__ pointed dynamic library (.so) on linux; the statement import _sqlite3 works correctly on python console, not work on jython code. anybody knows how load module in different way .so file? my import stack displayed below.

rotation - Is it possible to make diagonal column headers in JavaFX? -

Image
my javafx tableview looks this: it more pleasing , efficient if labels @ top diagonal save space. i imagine so: the goal make column fit closely content despite long header label. can done?

sql - Add unique constraint to an existing PostgreSQL index -

i have index in postgresql 9.3 database: create index index_foos_on_bar_and_baz on foos using btree (bar, baz); (from schema migration using ruby on rails) the index present , made things faster. i've cleaned duplicate foos, i'd make index unique: create unique index index_foos_on_bar_and_baz on foos using btree (bar, baz); is there way alter existing index , make unique? or easier/faster delete existing index , create new, unique one? there no way change index unique index. can see can change index @ alter index document . in case need drop , create new unique index.

coldfusion core java instead of cffile -

i using cffile tag in coldfusion 2016 app(website) upload images user server. i have been ordered stop using cffile , start using underlying java instead because more efficient. i given code shows how take dir of files , zip them core java . not smart enough use needs. i need page receive simple post , move file posted specific directory on server. on "action" page of website use: cffile action="upload" filefield="fieldnamefrompostedform" destination="mydirectoryonserver" can point me in direction see under hood of coldfusion can end magic like: fileoutputstream = createobject("java", "java.io.fileoutputstream"); in function. thanks! progress report: closer told do. file written server getting error afterwards missing piece of puzzle <cfscript> function bj_script(source, server_dest_path) { try { fileoutputstream = createobject("java", "java.io.fileoutputstream");

Is it possible to use Java Lambdas to implement something like Groovy's SwingBuilder? -

it occurred me lambdas might possible build swingbuilder in native java--but seems if possible have been done now. is there reason couldn't done, or has been done? i realize similar swingbuilder gui syntax java? , hoping add lambdas mix. swingbuilder built on lambdas absolutely wasn't possible before java 8. uses bit of dynamic programming , can't used won't ever clean, think it's possible... first, have identify issues want solve. biggest issue creation of simple event bindings needed use of inner classes in previous java versions. can replaced lambda expression single-method listener interfaces in cases, multi-method interfaces, you’d need adapters, discussed in this or that q&a, has done once. the other issue structure of initialization code. in principle, imperative code works fine, if want modify properties of component you’re going add container, have change container.add(new componenttype()); introduce new local variable used subseq

Different filters for Palette on Android O notifications -

the new android o notifications mediastyle use content big picture art , use letters , background of entire notification. the end result looks great sometimes, , bit on top in regards color contrast. since palette api has filters allow configure behavior ( https://developer.android.com/training/material/palette-colors.html ), possible set filters when building notification mediastyle? know if build own notification remoteview can set things manually, imply lot of overhead 1 thing. suggestions welcome. no, there no api controlling colorations chosen mediastyle notifications. built in styles notifications, templates manufacturers can customize liking (although many stick closely aosp style). given users expecting new style (including 'bit on top' colors) , consistency across apps, should continue use mediastyle .

java - What does a "Cannot find symbol" compilation error mean? -

please explain following "cannot find symbol" error: what error mean? what things can cause error? how programmer go fixing error? this question designed comprehensive question "cannot find symbol" compilation errors in java. 1. "cannot find symbol" error mean? firstly, compilation error 1 . means either there problem in java source code, or there problem in way compiling it. your java source code consists of following things: keywords: true , false , class , while , , on. literals: 42 , 'x' , "hi mum!" . operators , other non-alphanumeric tokens: + , = , { , , on. identifiers: reader , i , tostring , processequibalancedelephants , , on. comments , whitespace. a "cannot find symbol" error identifiers. when code compiled, compiler needs work out each , every identifier in code means. a "cannot find symbol" error means compiler cannot this. code appears referring compiler does

node.js - npm packaged installed but can not be found when running nightwatch Jenkins -

i building node.js project on jenkins , came across wired error. detail description following (full console log shown @ end of question): on jenkins , after npm install , tried run nightwatch e2e testing, following error message showed up: iam-ui@0.0.1 test:e2e-chrome /users/shared/jenkins/home/workspace/e2e-iam-practice node_modules/nightwatch/bin/nightwatch --env chrome [0;31mthere error while starting test runner: [0;90merror: cannot find module 'q' @ function.module._resolvefilename (module.js:469:15) @ function.module._load (module.js:417:25) @ module.require (module.js:497:17) @ require (internal/module.js:20:19) @ object.<anonymous> (/users/shared/jenkins/home/workspace/e2e-iam-practice/node_modules/nightwatch/lib/runner/cli/clirunner.js:3:9) @ 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) npm err! darwi

Mapping Middle Mouse Button to the End key using Autohotkey -

my goal map "delete" key middle mouse, aka clickable wheel on mouse. i'm on windows 10 machine. currently, no matter do, clicking on wheel within browser , other apps, produces cross-hair. i tried: mbutton:: send, {end} also tried wheeldown:: send, {end} both did not work. thoughts? if remapping mbutton::end isn't working you, try this *mbutton:: keywait, mbutton return *mbutton up:: send, {mbutton up}{end} return

payment - Square PHP API - Record Data -

i new @ payment api , understanding of arrays().... using squares php api script expample... it, however, when processes payment, want catch data , record sql (mysqli)... can't make script echo specific data want... lost... me in right direction? here form: (index.php) <?php require '../composer/vendor/autoload.php'; # replace these values. want start sandbox credentials # start: https://docs.connect.squareup.com/articles/using-sandbox/ # access token use in connect api requests. use *sandbox* access # token if you're testing things out. $access_token = 'sandbox-xxxxxx'; # helps ensure code has been reached via form submission if ($_server['request_method'] != 'post') { error_log("received non-post request"); echo "request not allowed"; http_response_code(405); return; } # fail if card form didn't send value `nonce` server $nonce = $_post['nonce']; if (is_null($nonce)) { echo "invalid

javascript - Track tiles as they are requested and rendered in MapboxGL -

background: i'm using mapboxgl display data-heavy maps users. vector tile sources take while load , render screen. to provide user feedback things happening, i've implemented spinner based off of map.loaded() . map.on('render', () => { if (!map.loaded()) { showspinner(); } else { hidespinner(); } }); however, can take minutes tile return server , render screen. users have complained map spinner hanging when there still work being performed! so instead of spinner, i'd show progress bar updates tiles render screen. should give user sense of how work left before map has rendered. where i'm @ far to accomplish this, need know mapboxgl events responsible signaling when tile request sent out , when tile rendered screen. const pendingtiles = {}; // marks tiles loading, works! map.on('dataloading', data => { if (data.tile) { pendingtiles[data.tile.uid] = data.tile.state; } }); // triggered on every render event, // ther

ios - Swift: Can't subclass SCNNode? Fatalerror -

ok, need subclass scnnode because have different scnnodes different "abilities" in game (i know people don't subclass scnnode need to) i have followed every other question subclassing scnnode , creating subclass of scnnode continue error: fatal error: use of unimplemented initializer 'init()' class 'littledude.dude' where dude name of scnnode subclass. following second question, because of classing issues how attempt scnnode .dae scene , assign dude() : var thedude = dude(geometry: scnsphere(radius: 0.1)) //random geometry first var modelscene = scnscene(named: "art.scnassets/ryderfinal3.dae")! if let d = modelscene.rootnode.childnodes.first { thedude.transform = d.transform thedude.geometry = d.geometry thedude.rotation = d.rotation thedude.position = d.position thedude.boundingbox = d.boundingbox thedude.geometry?.firstmaterial = d.geometry?.firstm

scala - Partial Read from StdIn or String -

suppose have mathematical expression, such 1 + 5.4 * 2 ^ 3, , i'm trying tokenize it. in scala, able "peek" @ next character in stdin before deciding whether read number, or operator. in c++, can things like double val = 0; char letter = ' '; std::cin >> val; std::cin >> letter; and on input "54.6ff", val have value '54.6', , letter have value 'f'. moreover, in c++, can @ next character in string, , call cin.putback if decide want read upcoming characters number, rather operator. so in scala, there way peek @ next character in stdin, or put characters stdin? additionally, calling stdin.readdouble() crash on inputs such "54.6ff" numberformatexception. in scala.io.stdin docs, readdouble annotated "reads double value entire line of default input". possible in scala partially read stdin? finally, option read entire input string, , process string. there way of converting leading numbers in string d

r - pass objects to nested functions using environments -

i want pass objects 1 function nested function assigning environments. below sample of code not work. how can happen assigning environments in function? sumi <- function(x,y) { my.env <- new.env() my.env$rumi <- function() { my.env$k <- x[1] my.env$f <- y[1] } k <- get("k", my.env) f <- get("f", my.env) z <- k+f return(z) } the code defines never runs rumi objects have created if run never are. adding line marked ### works: sumi <- function(x,y) { my.env <- new.env() my.env$rumi <- function() { my.env$k <- x[1] my.env$f <- y[1] } my.env$rumi() ### k <- get("k", my.env) f <- get("f", my.env) z <- k+f return(z) } sumi(1, 2) ## [1] 3

pinvoke - AdjustTokenPrivilege c# 0x80070057 -

i trying write uefi properties. appears need raise token privileges. have used http://www.pinvoke.net/default.aspx/advapi32.adjusttokenprivileges guide this. i keep getting error e_invalid arguments public static void enabledisableprivilege(string privilegename, bool enabledisable) { //gets process token handle using pinvoke var intokenhandle = intptr.zero; if (!openprocesstoken(process.getcurrentprocess().handle, tokenaccesslevels.adjustprivileges | tokenaccesslevels.query, out intokenhandle)) { marshal.throwexceptionforhr(marshal.gethrforlastwin32error()); return; } //enumerates current privileges of token handle var innewstate = new token_privileges { privilegecount = 1, privileges = new luid_and_attributes[1] }; //attempts lookup inputed privilege luid luid; if (!lookupprivilegevalue(null, privilegename, out luid)) { marshal.throwexceptionfo

python: how can i make my function stop reading through a list once its done what i want -

i need able paste 4 sheets on billboard background using data list, here small segment of list: data_sets = [ # these 2 initial data sets don't put sheets on billboard # data sets 0 - 1 ['o'], ['x'], # these data sets put sheet in possible locations , orientations # data sets 2 - 9 ['o', ['sheet a', 'location 1', 'upright']], ['o', ['sheet a', 'location 2', 'upright']], ['o', ['sheet a', 'location 3', 'upright']], ['o', ['sheet a', 'location 4', 'upright']], ['o', ['sheet a', 'location 1', 'upside down']], ['o', ['sheet a', 'location 2', 'upside down']], ['o', ['sheet a', 'location 3', 'upside down']], ['o', ['sheet a', 'location 4', 'upside down']] ] i'm trying turtle draw sheet once draws it, keeps on

Python: Getting the Index of a list -

i'm trying create program take input of sentence , word , check sentence word , return index of beginning of word i.e. sentence = "random set of words" word = "of" result = 9 this tried sentence = (input("enter sentence: ")) word = (input("enter word: ")) result = sentence.split() x in sentence: if x == (word): boom = enumerate(word) print(boom) assuming word appears once, i'd this: sentence = sentence.split(word) sentence[0] = sentence[0].replace(" ","") result = len(sentence[0])

javascript - Firebase retrieve from array of keys -

i'm working on project, using firebase, , i'm trying users ids intersect provided array. while javascript, i've added typescript types in order make things little easier follow. const getusers = (userkeys: string[]) => { // each id in `userkeys`, go user } my data looks following: { "qwertyuiop": { "firstname": "bob", "lastname": "test", "emailaddress": "bob@test.com", }, "asdfghjkl": { "firstname": "jake", "lastname": "alsotest", "email": "jake@email.com", } } obviously, have more data, goal provide array of ids getusers function, , either make successive calls, or batch users ids match. have decent experience in firebase, , project, using firebase-admin , , have little-to-no experience using admin sdk javascript. i've experimented using bluebird promise library, couldn't past

weight - Pounds and Ounces in Python -

i started learn coding , i'm having issue trying pounds converted on ounces. we're suppose allow user input data 6 pounds 2 ounces. i'm stuck @ moment , i'm not sure if i'm going right. appreciated. your program accept input weights in pounds , ounces set of rabbits fed 1 type of food. let user provide name of food. accept input until user types 0 weight. make life easier converting weights ounces. compute arithmetic mean (average) of each set of rabbits. determine set of rabbits weighs most, reporting average weight. this orignal code before using pounds , ounces , worked fine using simple number 13. f1 = input("name of food:") print (f1) counter = 0 sum = 0 question = input('''enter weight? type "yes" or "no" \n\n''') while question == "yes" : ent_num = int(input("weight of rabbit:")) sum = sum + ent_num counter = counter + 1 question = input('''ente

Replace One Line of Multiline String In Python? -

i have multi-line string in python, , want replace specific line number of it. have loop goes through each line , increments line number 1, do when reach line need replace? suggestions? yourstring = yourstring.split("\n") yourstring[lineyouwant] = edit yourstring = "\n".join(yourstring) lineyouwant 0 indexed

r - Plotting polygons and lines of lat and lon on the map -

so have following colums in dataset: lat =c(10, 20-30, 40, 60-70) lon=c(15, 35-45, 50-60, 70) num=c(4,5,2,3) data= data.frame('dec_lat'=lat, 'dec_lon'=lon,'value' =num) i have these lat/lon coordinates want plot on map. however, of them points, polygons , lines. in addition, have 5 5 dehree grid on map, want fill squares based on number num column. when lat , lon in form of point- easy do. not sure how fill in squares of grid line or polygon overlap. i appriciate ideas on how that. using grid , map following example : http://www.iobis.org/manual/processing/ everything works points not sure how adjust polygons , lines #create quick world map world <- map_data("world") #this creates quick , dirty world map - playing around themes, aesthetics, , device dimensions recommended! worldmap <- ggplot(world, aes(x=long, y=lat)) + geom_polygon(aes(group=group)) + scale_y_continuous(breaks = (-2:2) * 30) + scale_x_continuous(b

javascript - Ajax call not working on search query -

i have github profile viewer react application allows search profile username. in default state have provided own github username landing page own github profile. can search profile entering name in search bar, ajax call not working whenever try search user, same function returning valid data own username. error getting follows:- uncaught typeerror: $.ajax not function my main app.jsx class follows class app extends component{ constructor(props){ super(props); this.state = { username: 'kinny94', userdata: [], userrepos: [], perpage: 5 } } getuserdata(){ $.ajax({ url: 'https://api.github.com/users/' + this.state.username + '?client_id=' + this.props.clientid + '&client_secret=' + this.props.clientsecret, datatype: 'json', cache: false, success: function(data){ this.setsta

c++ - Memory leak with shared pointers? -

i have structure of code : class base { //maps, sets on stack //maps, set shared pointers }; int main() { for(int i=0;i<10;i++) { try { boost::shared_ptr<base> b(new base(....)); b.func() } catch exception { print exception } //some more functionality } } in case, func throws exception (assume always), getting continuous increase in memory leak of ~15-16 mb each iteration. can point out may helpful? is because of throwing exception? have checked code, don't see fishy.

importing audio file onto python-3 -

i getting error when try import audio file, how import audio file?: filenotfounderror traceback (most recent call last) <ipython-input-13-ce3f03976f66> in <module>() ----> 1 fs, oooh = wavfile.read('oooh.wav') #my vowel sound 2 audio(oooh, rate=fs) /anaconda/lib/python3.6/site-packages/scipy/io/wavfile.py in read(filename, mmap) 231 mmap = false 232 else: --> 233 fid = open(filename, 'rb') 234 235 try: filenotfounderror: [errno 2] no such file or directory: 'oooh.wav' and code have written far: import numpy np import matplotlib.pyplot plt %matplotlib inline scipy.io import wavfile import scipy.signal sig scipy.fftpack import fft, ifft ipython.display import audio np.set_printoptions(precision=3, suppress=true) fs, oooh = wavfile.read('oooh.wav') #my vowel sound audio(oooh, rate=fs)

c# - Asp.net core localization - how to pass to translators if there's no default resource -

i studied new approach localization in asp.net core using istringlocalizer , using _localizer["about title"] . then it's stated that for many developers new workflow of not having default language .resx file , wrapping string literals can reduce overhead of localizing app. it reduce overhead, pass translators then? usually, have default resource.resx in english, able translate , give me resource.fr.resx . what's workflow new "not having default language .resx" mechanism?

With GNU GZIP environment variable deprecated, how to control ZLIB compression via tar? -

currently have script sets compression using gzip environment variable. with gzip 1.8 warning: warning: gzip environment variable deprecated; use alias or script how should tar invoked compression level set? current command: gzip=-9 tar -zcf ... files compress ... depends on os, , version of tar ships it. if it's bsd and/or macos, can just: tar --options gzip:compression-level=9 -czf foo.tar.gz foo.txt otherwise, take compression stage own hands: tar -cf - foo.txt | gzip -9 > foo.tar.gz

java - Android studio error: app:mergeDebugResources -

Image
i have problem error:execution failed task ':app:mergedebugresources'. error: file crunching failed, see logs details i saw people tell it's because image format installed android studio didn't upload picture it, or wrote code, in starting code: this 2 probability makes error: maximum 260 characters file path. here excerpt windows naming files, paths, , namespaces documentation : maximum path length limitation in windows api (with exceptions discussed in following paragraphs), maximum length path max_path, defined 260 characters. local path structured in following order: drive letter, colon, backslash, name components separated backslashes, , terminating null character. example, maximum path on drive d "d:\some 256-character path string" "" represents invisible terminating null character current system codepage. (the characters < > used here visual clarity , cannot part of valid path string.) your user

c++ - Why doesn't library source file include its header -

i trying explore opencv. when looked mat class, can see defined in mat.hpp , located in include folder. however, when attempted search corresponding mat.cpp , found class definition located in matrix.cpp . suppose difference in file name not problem, long includes mat.hpp . however, header mat.hpp wasn't included either. know compiler still able compile, far know, bad programming practice. so, question is, true bad practice not include header file in source file? there reason why should not included? i understand not need explore detailed implementation of library, question out of curiosity. here #include part of matrix.cpp #include "precomp.hpp" #include "opencl_kernels_core.hpp" #include "bufferpool.impl.hpp" and here #include part of mat.hpp #include "opencv2/core/matx.hpp" #include "opencv2/core/types.hpp" #include "opencv2/core/bufferpool.hpp" the short answer is: that's how project e

php - How to require a package installed via Composer -

i installed emanueleminotto/simple-html-dom via composer . how can use classes package without getting error? note : use xampp run php scripts. error message: php fatal error: uncaught error: class 'simple_html_dom' not found in c:\xampp\htdocs\practice\php\scrape_1.php:3 stack trace: 0 {main} thrown in c:\xampp\htdocs\practice\php\scrape_1.php on line 3 fatal error: uncaught error: class 'simple_html_dom' not found in c:\xampp\htdocs\practice\php\scrape_1.php:3 stack trace: 0 {main} thrown in c:\xampp\htdocs\practice\php\scrape_1.php on line 3 after running $ composer install require autoloader generated in vendor/autoload.php @ top of script file (or, web application, in front controller). then have autoloaded classes available in script. <?php require_once __dir__ . '/vendor/autoload.php'; $htmldom = new simple_html_dom_node(); for reference, see https://getcomposer.org/doc/01-ba

subprocess call in python -

i need execute following command in terminal multiple files setfile -c "" -t "" <filename> created python script take filenames arguments , use call function execute command. don't know how put "" marks in call pipe. here code from subprocess import call import sys # sys.argv def main(): l = len(sys.argv) l = l - 1 if(l>0): in range(l): termexecute(sys.argv[i]) def termexecute(argument): call(["setfile", "-c ","","-t ","","argument"]) if __name__ == '__main__': main() i pretty sure call(["setfile", "-c ","","-t ","","argument"]) wrong hope know right way of writing it. edit: akuls-macbook-pro:~ akulsanthosh$ python3 /users/akulsanthosh/documents/simple/setfile.py /volumes/akul/stuff/1.jpg /volumes/akul/stuff/2.jpg /volumes/akul/stuff/3.jpg invalid type or creato

caching - Changes made to web-app/css not reloaded in browser? -

i using grails 2.2. have few css files in web-app/css folder. when make change these files , run application or deploy application changes made these files not reflected. need explicitly load file in browser , click on refresh button in browser new css file obtained. clear css files being cached preventing new files show up. there fix problem? how can force browser detect changes in css files , reload if changed? i appreciate help! thanks! the way workaround problem making change in html page evey time update js or css. this ensures latest js or css loaded browser. you can add version field after name of css or js file while including in html <link href="/site.css?version=3" rel="stylesheet" type="text/css" /> just update version number in html every time make changes in css.

javascript - How to make function run once inside setInterval -

hi friends have trouble while doing .. getsocketpersecond = function () { interval_persecond = setinterval(function () { $.ajax({ url: "/asset/ashx/getsocket.ashx", type: "post", success: function (data) { switch (status) { case "opendoor": opendoor(); break case "closedoor": closedoor(); break } }, error: function () { } }) }, 500) } function opendoor(){ console.log('open door');} function closedoor(){ console.log('close door');} the console log coming ajax request // opendoor string open door ajax request open door ajax request open door ajax request // closedoor string close door ajax request close door ajax request

javascript - Base64 value is not working with video tag? -

i adding src video source base64 value not working here html <video id="video" controls> <source type="video/mp4" id="jh"> </video> and js is $("#vd").click(function(){ $.ajax({ url:"retrivevedio", method: "get", datatype: 'text', success:function(response){ console.log(response); var src = 'data:video/mp4;base64,'+response; $("#video").find("#jh").attr("src", src); // $('#video').load(); $("#video").trigger('load'); $("#video").trigger('play'); } }); }); base64 value coming server aaaaggz0exbtcdqyaaaaag1wndfpc29tbnjldm1kyxqaaaaaaaaaeaa= value getting added source <sourc

node.js - Mongoose populate data key remove in got data -

i'm using relation between 2 collection , have collection schema follow. // room database entry. { "_id" : objectid("59b77082f7da4b1b3f64d927"), "room_id" : "c3wqqkfndg9cnmi", "room_name" : "bcmvnxbcnvsjkfhkjdh", "users" : [ { "_id" : objectid("59b77082f7da4b1b3f64d926") } ], "__v" : 0 } //user database entry, related above room entry. { "_id" : objectid("59b77082f7da4b1b3f64d926"), "user_id" : "dyr1qlrtso47vi", "__v" : 0 } when pass query room find , populate data found result follow. // query room find , populate. room .findone({ room_id: result.data.room_id }) .populate("users._id") .exec(function(err, data){ }); //result follow { "_id":"59b77082f7da4b1b3f64d927", "room_id":"c3wqqkfndg9cnmi",

os.path.exists is not working as expected in python -

i trying create directory in home path , re-check if directory exists in home path before re-creating using os.path.exists(), not working expected. if os.access("./", os.w_ok) not true: print("folder not writable") dir_name_tmp = subprocess.popen('pwd', stdout=subprocess.pipe, shell=true) dir_name_tmp = dir_name_tmp.stdout.read() dir_name = dir_name_tmp.split('/')[-1] dir_name = dir_name.rstrip() os.system('ls ~/') print "%s"%dir_name if not os.path.exists("~/%s"%(dir_name)): print "going create new folder %s in home path\n"%(dir_name) os.system('mkdir ~/%s'%(dir_name)) else: print "folder %s exists\n"%(dir_name) os.system('rm -rf ~/%s & mkdir ~/%s'%(dir_name, dir_name)) else : print("folder writable") output first time: folder not writable desktop downloads perforce bkp doc project hel

html - Custom checkboxes, aligning label middle -

i'm having problem aligning labels middle of checkboxes. have tried seems , after hours of testing i'm giving up. i have tested display: inline-block, vertical-align: middle; nothing seems work. have found out putting characters content:'' makes text float top. i think i'm missing something... jsfiddle .styled-checkbox { position: absolute; opacity: 0; } .styled-checkbox + label { position: relative; cursor: pointer; padding: 0; color: inherit; font-size: inherit; } .styled-checkbox + label:before { content: ''; margin-right: 10px; display: inline-block; width: 28px; height: 28px; background: #cad1d9; border-radius: 3px; } .styled-checkbox:hover + label:before { background: #f35429; } .styled-checkbox:focus + label:before { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.12); } .styled-checkbox:checked + label:before { background: #f35429; } .styled-checkbox:disabled + label { color: #