Posts

Showing posts from March, 2012

sql - How to prevent a user from using space in a tablespace? -

i tried following commands,but can still insert table on appts. why? michael@orcl@sql> alter user michael quota 0m on appts; user altered. michael@orcl@sql> select tablespace_name,max_bytes user_ts_quotas; tablespace_name , max_bytes ------------------------------,---------------- appts , 0 michael@orcl@sql> select tablespace_name,table_name user_tables; tablespace_name ,table_name ------------------------------,------------------------------ appts ,test_d .... michael@orcl@sql> insert test_d values(292,'test',500,2100); 1 row created. what using alter tablespace make read only? enter: alter tablespace appts read

Creating a secure login script in PHP and MySQL without HTTPS -

question is this post on wikihow reference create secure login script in php , mysql? in warnings section, author(s) emphasizes code can used https. not able use https, need implement relatively secure login script in php , mysql, , therefore wondering if script implemented http connection well. solved a third party solution best solution create secure login script in php , mysql. utilizing php framework (e.g. symfony, ulogin) or external parties (e.g. facebook, google), need create entirely new working login script plus authorization (the remember-me functionality) can avoided. if others have done thorough research , gained experience create login functionalities, safer , easier use work. although create login system yourself, recommended let external parties you. it takes lot of experience right, , done wrong. although tutorial looks okay me, there many factors consider, , seems semi-old. php 5.5 offers password_hash , password_verify , recommend on page su

asp.net - Using java script code in MVC5 - where to put it -

im having mvc5 application , in view index.cshtml need use java script code ,currently put script code inside view , working fine. question should put code (from best practice) , how should refer view?please provide example. the approach i've written down below way of extracting javascript views. better maintain (js issues -> in js files , not in views) modular approach clear separation better understand design in html5, use data attribute pass along variables model . helps tremendously in porting variables mvc (your viewmodel) javascript. allows keep javascript stored in separate files in mvc environment. 1.1 binding c# html <div class="news" data-js-params="websitename=@locationwebsitehelper.currentlocationwebsitename()&amp;languagename=@languagename&amp;page=0&amp;itemsperpage=@model.maxnumberofitems"> 1.2 js helper functions convert data object literals although built on jquery, i've written 2 small f

javascript - Initiate click event automatically on a specified time interval -

how can make automatic click event on time interval set <div class="nav"> <img class="logo" src="images/logo.png" alt="logo" /> <ul class="navright"> <li><a class="navlink select ho" href="#">home</a>•</li> <li><a class="navlink ab" href="#">about us</a>•</li> <li><a class="navlink pg" href="#">products</a>•</li> <li><a class="navlink ps" href="#">services</a>•</li> <li><a class="navlink cs" href="#">contact us</a></li> </ul> </div> and jquery this $(document).ready(function () { var myinterval = true;

Issues in getting the output when calling a python script from Java -

i've java program call python script. i've used exec method. please find code snippet below: python program (which gather portion of text wikipedia), when run separately, gives me proper output. when called java, i'm not getting complete output python program. i checked status of bufferedreader object using ready() method ( explained here , , code entered infinite loop. i think others have faced similar problems- https://stackoverflow.com/a/20661352/3409074 can me? public string enhancedata(string name,string entity) { string s = null; stringbuffer output = new stringbuffer(); try{ string command="python c://enhancer.py "+name+" "+entity; process p = runtime.getruntime().exec(command); bufferedreader stderror=new bufferedreader(new inputstreamreader(p.geterrorstream())); bufferedreader stdinput = new bufferedreader(new inputstreamreader

c# - preceding 0's in integer value -

i using answer question in order view 0's in binary value byte binary string c# - display 8 digits int = 00010 and converting string with: string b = convert.tostring(a).padleft(5, '0'); this works , can print 00010 instead of 10. however, need convert integer in order populate integer array. using convert integer: int c = convert.toint32(b); console.writeline(c); howwever, when print preceding 0's missing, , printing '10'. there way convert integer , keep preceding 0's? thanks. an integer doesn't have leading zeros. integers numeric values, don't carry display information them. if you're storing value integer you're not storing display information. in case apply display information when display value: int = 10; console.writeline(convert.tostring(a).padleft(5, '0')); if want display information retained part of value itself, make string: string = "00010"; console.writeline(a); if needs s

Use `before` or `require` in Puppet manifests? -

okay, started learning puppet , working through docs. see: require same before subscribe same notify obviously these added @ opposite sides of dependency relationship, point. from code readability , maintainability aspect, using 1 (of each pair) better other? should use both maximum clarity or make maintenance cumbersome? thoughts? either variant works equally fine. have concrete uses though. make intentions more clear e.g. exec { "initialize-footool": require => package["footool"] } file { "/etc/default/footool": before => exec["initialize-footool"] } read more english requires on exec. build relations other resources don't know resource in question e.g. include apache exec { "apache2ctl graceful": require => package[apache] } # package inside class apache the latter pretty bad practice though. found 1 of definite benefits lie in these metaparameters' ability target whole cla

python - Multiply Numpy arrays by distributing terms -

i have 2 one-d numpy arrays in files. 'test1'=(2,3) 'test2'=(5,6,7) i multiply them get t=(10, 12, 14, 15, 18, 21) i using program import numpy np a=open('test1') b=open('test2') c=open('test3','w+') t1=np.loadtxt(a) t2=np.loadtxt(b) t=t1*t2 print >> c, t when run program, following error.. valueerror: operands not broadcast shapes (2) (3) what should desired result? using numpy.outer , numpy.ravel >>> import numpy np >>> = np.array((2,3)) >>> b = np.array((5,6,7)) >>> np.outer(a,b).ravel() array([10, 12, 14, 15, 18, 21]) edit: subraction: can't use numpy.outer , can use numpy.newaxis : >>> (a[:, np.newaxis] - b).ravel() array([-3, -4, -5, -2, -3, -4])

add listener to radio field in sencha -

i creating radiofields in web app programatically checked. trying add listener radio field, listens ''uncheck' event. on getting unchecked want destroy radio field. the radio field added , created fin on unchecking field following error. uncaught typeerror: cannot call method 'replace' of null the code initialising radio field. var radiofield= ext.create('ext.field.radio',{ id:fieldname, checked:true, label:fieldname, listeners: { uncheck: function() { console.log('destroy'); destroy(); } } }); ext.getcmp('filterlistfield').add(radiofield); i believe name required property radiobox. did , seems work. var radiofield = ext.create('ext.field.radop', { id: fieldname, checked: true, name:fieldname, label: fieldname, listeners: {

Android: Reading a large CSV file efficiently? -

i have large csv file (about 12000 lines) need parse , display in listview. i don't want load entire file in memory, want read in 10 lines groups , when user clicks "load more" button, next 10 lines read , on. any recommendations on how achieve in efficient way ? thanks well, here's starting point: step #1: create arrayadapter , data model array of read-in rows step #2: override getcount() return array size plus 1, accommodate "load more" row step #3: override getviewtypecount() return 2 (or more, if listview rows csv rows not same -- assume same rest of answer, 2 types "regular row" , "'load more' row") step #4: override getitemviewtype() return 1 when position equal array size, or 0 lower that step #5: override getview() return appropriate row, including returning "load more" row step #6: when user clicks "load more" row, run through logic read in next csv lines, adding the

html - Create two large text areas encompassing the entire screen -

i have 2 gigantic text areas encompass entire screen. tried adjusting number of rows , columns , did not work prefer have responsive screen. open using bootstrap want keep simple possible. here t he project , relevant code: enter 2 text blocks compare: <form action="/" method="post"> <textarea name="a"></textarea> <textarea name="b"> </textarea> <input type="submit" value="execute" /> </form> here entire document. <!doctype html> <html> <head> <title>ven diagram</title> <style type=”text/css”> form{ width: 100%; position: relative; } textarea:first-child{ width: 50%; float:left; } textarea:nth-child(2){ width: 50%; float:right; } </style> </head> <body> program allows match text. enter 2 text blocks compare: <form action="/" meth

Finding Area Of Triangle In Java -

public class righttriangle { private double leg_1; private double leg_2; public righttriangle () { leg_1 = 1; leg_2 = 1; } public righttriangle (double s1, double s2) { leg_1= s1 ; leg_2= s2 ; } public double findarea () { double area= ((leg_1+leg_2)/2); return area; } public double findperimeter () { double s3squared= math.pow(leg_1,2) + math.pow( leg_2,2); double s3= math.sqrt(s3squared); double perimeter=(leg_1 + leg_2 + s3); return perimeter; } public void dilate (double factor) { } righttriangle t1 = new righttriangle (3, 4); t1.findarea(); } for java program, constructor should construct triangle default 2 legs length of one. other constructor allows choose length of triangles 2 legs. i'm trying test program's methods running "findarea" method t1 triangle object, when try run prog

How can I create a database for my site from excel/google sheets? -

i have created datasheet of fashion stores, (where based, sell) , want able add searchable database website visitors can search data can find want. i know creating websites nothing databases? there relatively easy way this... i'm pretty sure i'm asking quite simple. have found paid web apps don't want pay £20 month... i have both excel sheet , google sheet. , want visitors able search through store location, items want, etc.. text search. thank you! you want consider sql or mysql these sort of operations.

javascript - How can I put this code in an external file? -

i've made little chat nodejs, want put part of code https://github.com/p-pariston/nodechat/blob/698ced0afc77e359a2bd32618baf66a873241816/app.js#l112-402 (in yellow) in external file called commands.js. actually, i've tested this: app.js command.prototype.parser = require('./commands.js'); commands.js module.export = function (){...} it doesn't work, have: "mongoclient not defined". all modules not passed in commands.js can see (socket.io) thanks ! it doesn't include context mongoclient has been set require @ top of first set of code (outside commands file) mongoclient = require('mongodb').mongoclient,

java - displaying several lines of two-word strings on a JTextComponent with Justified alignment -

Image
as picture below shows, i'm trying display text 1 in table of contents. "items" start @ same position. doesn't matter me wether "values" end @ same position, start @ same position, or centered in right-column of textpane. also, don't strictly need use jtextpane - if it's possible achieve effect using jtextpane, i'd most. i'd different font types items , values. i add item/value pairs calling textpane.append("\nitem1: value1"); can change too. have tried experimenting justified alignment, can't make work in desirable way.

Prevent Google App Script Memoization -

Image
i have function want use demonstrate flipping coin 100 times: function simulateflips(n, pheads){ var head_count = 0; var h; for(var i=0; < n; i++){ h = 0; if (math.random() < pheads){ h = 1; } head_count += h; } return head_count; } however, looks standard google app behavior "memoize" custom functions called same inputs, not want kind of demo: know hacky (like modify pheads small amount), hoping there cleaner way desired behavior. here's explanation of behavior: script summarise data not updating read comments see suggestions on how workaround it.

MySQL per-user table or common? -

i need make library of products (this can large), should make table per-user ( lib_$user_id$ ) or common 1 ( libs )? better in term of versatility , performance? thanks. different table each user not idea increase table per user. use unique table libs where userid forigen key

procedure from another unit in delphi shows undeclared identifier -

i can't seem link procedure unit work in main unit's form. tried adding procedure declaration below interface, mentioned in question how run procedure unit? , didn't work. keeps showing [dcc error] main.pas(27): e2003 undeclared identifier: 'sayhi' here codes both units: main.pas: unit main; interface uses winapi.windows, winapi.messages, system.sysutils, system.variants, system.classes, vcl.graphics, vcl.controls, vcl.forms, vcl.dialogs, unit2; type tform1 = class(tform) procedure formcreate(sender: tobject); private { private declarations } public { public declarations } end; var form1: tform1; implementation {$r *.dfm} procedure tform1.formcreate(sender: tobject); begin sayhi(); end; end. and unit2.pas unit unit2; interface uses dialogs; procedure sayhi(); implementation procedure sayhi(); begin showmessage('hi'); end; end. here's dpr file project: program gl; uses vcl.forms, main in 'm

android - Card Game App - Random card but not the same card twice -

i making card game app, when user clicks card image turn random other card. here example: public class mainactivity extends activity { int[] cards={r.drawable.aceofspades,r.drawable.aceofhearts,r.drawable.aceofclubs}; static random r = new random(); @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } public void imageclick(view view) { int n=r.nextint(cards.length); { imageview image = (imageview) findviewbyid(r.id.imagedice1); image.setimageresource(cards[n]); } } } i alter code won't possible same card show twice, not untill cards passed. in case when card "aceofspades" next card , card after should not "aceofspades". first image users see "r.drawable.cardback". code changes image "cardback" when cards have been shown. appreciated. you need put cards (or values 1 52) in array or list, shuffle

javascript - Cant Get jQuery hide working -

Image
i running search @ starts displays image , title etc when more info button clicked title , plot of selected movie shows when button clicked want hide other results using jquery hide function none of attepmts have worked i have inclued code , sample image u can see coming code here <html> <head> <title>sample seach</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var url = 'http://api.themoviedb.org/3/', mode = 'search/movie', input, moviename, key = '?api_key=api key here'; $('#search').click(function() { var input = $('#movie').val(), moviename = encodeuri(input); $.ajax({ url: url + mode + key + '&query='+moviename , datatype: 'jsonp', success: function(

ruby - Logging GET request URL's with Mechanize -

is there way capture various requests when mechanize loads given url. example when watching console in firefox's dev tools see various requests loading pages' media, etc... i'm wondering if there way access , log same info using mechanize you can enable logging: require "logger" log = logger.new "log.txt" log.level = logger::debug require "mechanize" agent = mechanize.new{ |a| a.log = log }

ios - iOS7.1 keyboard blur -

Image
i developing app , ran issue. how achieve keyboard background blur 1 in youtubes iphone/ipad app? can't figure out. awesome! set keyboard appearance property uikeyboardappearancedark . example [textfield setkeyboardappearance:uikeyboardappearancealert]; from documentation // // uikeyboardappearance // typedef ns_enum(nsinteger, uikeyboardappearance) { uikeyboardappearancedefault, // default apperance current input method. uikeyboardappearancedark ns_enum_available_ios(7_0), uikeyboardappearancelight ns_enum_available_ios(7_0), uikeyboardappearancealert = uikeyboardappearancedark, // deprecated };

web services - Unsupported Media Type error in SoapUI -

i checked of kind of problems in stackoverflow met. couldn't match mine. so, wanna test webservice soapui. in wsdl link there no type definiton inputs (it says string. wants loginname, username , password). and have real inputs check it, on right side of request window there sentence: "the server cannot service request because media type unsupported." in every test. i checked raw tabs, content-types text/xml;charset=utf-8 , think should too. and during test, using first soap. this problem can what? web browser? client? internet settings? should do? note: tried trial webservices found webservicex.net, test them without error...

php - invalid MySQL argument in mysql_fetch_array -

warning: mysql_fetch_array(): supplied argument not valid mysql result resource in /rideanddrive/_classes/__base.php on line 45 my code : public static function selectspecific($obj, $data_base, $cond) { self::$query = "select $obj " . self::$baseprefix . "$data_base $cond"; $out = self::execute(); $array = mysql_fetch_array($out); // line warning line return $array[$obj]; } execute function, if needed : private static function execute() { $out = mysql_query(self::$query); return $out; } code's works fine. don't warning on localhost (running wamp, might have turned them off ?), works on live server, i'm getting above warning, how correct warning gone ? on selectspecific function embed if check see execute function returning proper resource result .. if not echo sql run on server separately if can find error if there error sql ,here updated function if embedded public static function selectspecific($

ios - Updating tableview view for a chat application -

i'm implementing real time chat in app using firebase , and if keyboard shown , user sends me 10 messages in row, messages start hiding behind keyboard or go out below tableview view (if keyboard isn't shown). believe has adjusting view adjust number of rows within tableview. ultimately, need latest cell right above textfield (whether keyboard shown or not) every time send message or receive latest message. tips? took @ firechat on github , don't seem have code this: https://github.com/firebase/firechat-ios/blob/master/firechat/viewcontroller.m - (void)viewwillappear:(bool)animated { [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwillshow:) name:uikeyboardwillshownotification object:nil]; [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(keyboardwillhide:) name:uikeyboardwillhidenotification object:nil]; } - (void)keyboardwillshow:(nsnotification*)notification { [self movevie

How to create this kind of layout for android -

Image
i have design of andorid layout have no idea how start ui use (grid, table layout or ). please give me example. here design! one way nested linearlayouts: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" > <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="2" android:background="#dddddd" > <linearlayout android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:gravity="center" > <imagebutton android:layout_width="100dp"

authentication - LDAP vs SAML Authorization -

i'm investigating moving asset tracking system ldap saml. there 2 main areas our software uses ldap. first authentication. in order access system today need authenticate ldap , member of specified ldap group. part simple move on saml. we've utilized library handle of dirty work. , on idp can add claim authorize user. our second use of ldap throwing me loop. today, each asset maintain has ability linked username. example, particular printer may belong 'someuser'. 1 of options our software gives administrator view/interact assets based on ldap user groups. administrator, may want update printers owned people in particular department. accomplish this, administrator create rule scoped ldap group 'departmentinquestion'. our software use service account connect ldap, create query see users our system in 'departmentinquestion', execute , use results determine assets should update. so far searching have not been able find saml workflow analogous this. ap

java - missing return type compile error -

i have tostring method bunch of nested if statements. think have right i'm getting "missing return statement" error. can see why? thanks. public string tostring() //to tell user card/s have //c.tostring() { //for printing?// // arraylist<string> forprint = new arraylist<string>(); getsuit(); getvalue(); for(int = 0; < 5; i++) { if(suit == 1) { if(value == 11) { return "jack of clubs"; // forprint.add("jack of clubs"); } else if(value == 12) { return "queen of clubs"; // forprint.add("queen of clubs"); } else if(value == 13) { return "king of clubs"; // forprint.add("king of clubs"); } else if(value == 1) { return "a

postgresql - Deploying Web2py to Heroku (Psycopg2 Error) -

i'm trying deploy web2py app on heroku , although works fine on local server, keep getting same ticket when deploy it. i'm stuck on few time now, trying , solution several forums. please! traceback (most recent call last): file "/app/gluon/restricted.py", line 217, in restricted exec ccode in environment file "/app/applications/processos/models/db.py", line 21, in <module> db = get_db(name=none, pool_size=10) file "/app/gluon/contrib/heroku.py", line 25, in get_db db = dal(os.environ[name], pool_size=pool_size) file "/app/gluon/dal.py", line 7787, in __init__ raise runtimeerror("failure connect, tried %d times:\n%s" % (attempts, tb)) runtimeerror: failure connect, tried 5 times: traceback (most recent call last): file "/app/gluon/dal.py", line 7766, in __init__ self._adapter = adapters[self._dbname](**kwargs) file "/app/gluon/dal.py", line 2756, in __init__ if do_connect: self.f

Scala: How to get the result of a Future -

i've method returns future this... def istokenexpired(token: string): future[boolean] = { ... } ... , i've method invokes istokenexpired returns boolean this: def isexpired(token: string): boolean = { var result = true istokenexpired(token).oncomplete { case success(r) => result = r case failure(_) => result = true } result } is there better way write isexpired method? edit as requested eecolor, let me provide more details. play application i've implemented authorization mechanism based on json web token (jwt). claims contained in jwt except expiration time, stored in mongodb collection. here below summary of how token class looks like: class token { ... def id: string = { ... } def issuetime: localdatetime = { ... } def issuer: string = { ... } ... def isvalid: boolean = { ... } def isexpired: boolean = { /* uses reactivemongo access mongodb */ } } as can see, jwt properties self-contained except expiration i

android - How to get rid of Force Close After adding Facebook Sdk for Tracking Mobile App Install Ad? -

i running facebook ad mobile install, that's why added facebook sdk app track installs, , added code per instructions. getting force close, checked in new , old android versions. when comment code working fine. here code added:- ... @override protected void onresume() { super.onresume(); if (adview != null) { adview.resume(); } //below code added. com.facebook.appeventslogger.activateapp(context, "263969900451122"); } ... all working fine when add code per instructed add in onresume, app force closing : com.facebook.appeventslogger.activateapp(context, "263969900451122"); as per requested log cat:- 04-07 04:04:54.591: d/dalvikvm(345): dexopt: couldn't find field landroid/content/res/configuration;.smallestscreenwidthdp 04-07 04:04:54.591: w/dalvikvm(345): vfy: unable resolve instance field 48 04-07 04:04:54.591: d/dalvikvm(345): vfy: replacing opcode 0x52 @ 0x0012 04-07 04:04

python - Pyramid/SQLAlchemy displaying objects -

i'm creating record system, student can enrolled class. # model class association(base): __tablename__ = 'association' class_id = column(integer, foreignkey('classes.id'), primary_key=true) student_id = column(integer, foreignkey('students.id'), primary_key=true) theclass = relationship("class") class student(base): __tablename__ = 'students' id = column(integer, primary_key=true) name = column(string(30)) classlist = relationship("association", backref='student') class class(base): __tablename__ = 'classes' id = column(integer, primary_key=true) name = column(string(20), nullable=false) teacher_id = column(integer, foreignkey('teachers.id')) enrolled_students = relationship("association") i want display of students not yet enrolled in class, i've used following code in program , template, displays of students on page. currentclass = session.query(class).filter_by(id=class_id).firs

feed - How to make facebook custom story with custom structure like strava? -

i understand can make custom facebook feeds custom actions , objects (doc: facebook custom stories ) however, can't seem find documentation making custom-structured output feed strava below example. clarify, miles, minutes, mins/mi , elevation info not part of image; it's table tag. (also, route in image seems svg) edit: don't have enough stackoverflow reputation post image, here imgur link: strava feed

Upload resized image on amazon S3 with PHP SDK -

i have script wich resize , crop image , upload image on amazon s3 on fly. the problem error message when try run script because guess sourcefile not recognized direct path disk ($filepath). have idea through situation? fatal error: uncaught exception 'aws\common\exception\invalidargumentexception' message ' you must specify non-null value body or sourcefile parameters. ' in phar:///var/www/submit/aws.phar/aws/common/client/uploadbodylistener.php:... $myresizedimage = imagecreatetruecolor($width,$height); imagecopyresampled($myresizedimage,$myimage,0,0,0,0, $width, $height, $originewidth, $origineheight); $myimagecrop = imagecreatetruecolor(612,612); imagecopy( $myimagecrop, $myresizedimage, 0,0, $posx, $posy, 612, 612); //save image on amazon s3 require 'aws.phar'; use aws\s3\s3client; use aws\s3\exception\s3exception; $bucket = 'yol'; $keyname = 'image_resized'; $filepath = $myimagecro

Scala import problems - error: not found: value -

i'm haskeller looking scala. i'm meeting frustration not code, imports/packages. i have 2 files, test.scala , lists.scala . // lists.scala package problems object lists { def last(list: list[any]): option[any] = list match { case nil => none case x :: nil => some(x) case _ :: xs => last(xs) } } and: // test.scala import problems._ object test extends app { println("starting tests...") println(last(list(1,2,3,4,5))) } test.scala not compile. running scalac test.scala lists.scala yields: test.scala:5: error: not found: value last println(last(list(1,2,3,4,5)) yet rewriting last lists.last makes succeed. doesn't defeat point of import problems._ wildcard? notice math functions can written without preceeding math. doing import math._ . why won't work files well? real aim: want able make package, test functions println in file. what's best way that? can not away object {...} in test.scala , ru

php - Getting average in MySQL -

i have question using mysql. have 2 tables, 1 names of games , 1 different ratings games. want able search game name , see average ratings each game. far kind of managed average rating, see rating of 1 game instead of multiple entries. here's query far: select games.name, cast(avg(reviews.rating) decimal(6, 1)) average_rating games join reviews on games.id = reviews.game games.name '%spider%' , type = '7' , rating != 0 i hope of smart people can me out this! thanks, robert you have use group by clause on proper field average each group, otherwise calculate average of all rows. guess it's games.id , depends on table schemata. select games.name, cast(avg(reviews.rating) decimal(6, 1)) average_rating games join reviews on games.id = reviews.game games.name '%spider%' , type = '7' , rating != 0 group games.id; read more called aggregate functions

Remove attribute from all MongoDB documents using Python and PyMongo -

in mongodb, bunch of these documents exist: { "_id" : objectid("5341eaae6e59875a9c80fa68"), "parent" : { "tokeep" : 0, "toremove" : 0 } } i want remove parent.toremove attribute in every single one. using mongodb shell, can accomplish using: db.collection.update({},{$unset: {'parent.toremove':1}},false,true) but how do within python? app = flask(__name__) mongo = pymongo(app) mongo.db.collection.update({},{$unset: {'parent.toremove':1}},false,true) returns following error: file "myprogram.py", line 46 mongo.db.collection.update({},{$unset: {'parent.toremove':1}},false,true) ^ syntaxerror: invalid syntax put quotes around $unset , name parameter you're including ( multi ) , use correct syntax true: mongo.db.collection.update({}, {'$unset': {'parent.toremove':1}}, multi=true)

java - How do I access variables within a Handler? Setting them public did not work -

i not know how use variables handler in different method. tried set variables(readbuf, readmessage, , msg) public, did not work. how access these variables in separate method? want variables listed including .arg1 , .obj in handler. the code commented out processing data was. public handler handler; public byte[] readbuf; public string readmessage; public object msg; handler = new handler(); private final handler mhandler = new handler() { @override public void handlemessage(message msg) { switch (msg.what) { case message_state_change: if(d) log.i(tag, "message_state_change: " + msg.arg1); switch (msg.arg1) { case message_read: //for(int = 0; a< 8000; a++) //{ try { byte[] readbuf = (byte[]) msg.obj; string readmessa

python - Too many values to unpack when creating a data frame from two lists -

i have list c , p , both have 35300 elements. try create pandas data frame there´s error message when run code. how can fix this? import pandas pd e=pd.dataframe.from_items(['company',c],['id',p]) --------------------------------------------------------------------------- valueerror traceback (most recent call last) <ipython-input-284-89427a7d8af3> in <module>() 1 import pandas pd 2 ----> 3 e=pd.dataframe.from_items(['company',c],['id',p]) c:\users\toshiba\anaconda\lib\site-packages\pandas\core\frame.pyc in from_items(cls, items, columns, orient) 1195 frame : dataframe 1196 """ -> 1197 keys, values = zip(*items) 1198 1199 if orient == 'columns': valueerror: many values unpack since c , p lists, sounds want define dataframe 2 columns, company , id : e = pd.dataframe({'company':c, 'id':p}

html - Removing "www" from the domain directs to different site -

a novice here. support mediatemple , current host have been quite unhelpful, stackoverflow may hero. my problem entering "www" before domain , leaving out direct different servers. the background on first registered domain mediatemple , had plan gridhosting, after finding service unsatisfactory, cancelled gridhosting plan , moved host. problem occurs after updating nameservers. in short, web server hosted prominecrafthost, domain registered under mediatemple. support both sides it's due dns , nameservers needing 24-48 hours update, i'm skeptical cause. summarizing, www.mscraft.org directs correct server, mscraft.org (mscraft.org) alone not. if me, i'd appreciate it. thanks in advance. it's possible have old dns info in cache. try clearing browser's cache, , flushing dns. on windows ipconfig /flushdns in command prompt. try pinging both addresses (with , without www). should see same ip address both, got 198.154.108.107 w

java - Multiple Jtextfields to be filled before Jbutton enable -

hi badly need search jtextfield filled before jbutton enables, documentlistener people use determined if jtextfield being populated. tried documentlistener , works want jtextfield must not empty before jbutton enables here code. ftext.getdocument().adddocumentlistener(new documentlistener() { @override public void insertupdate(documentevent e) { change(); } @override public void removeupdate(documentevent e) { change(); } @override public void changedupdate(documentevent e) { change(); } private void change(){ if (ftext.gettext().equals("") && mtext.gettext().equals("") && ltext.gettext().equals("") && addtext.gettext().equals("")) { savebutton.setenabled(false); } else { savebutton.setenabled(true); } } });

php - Create dynamic HTML ID based off wordpress query -

i wondering how can create dynamic set of ids based off amount of custom posts queried given post. i'm using advance custom fields plugin , i"m querying custom fields in given post. if take below you'll see have custom fields being queried each 1 wrapped in div id "section-1". need "section-1" update "section-3", "section-4" each time new field name queried. if 5 fields queried each have own id. <?php // check if repeater field has rows of data if( have_rows('repeater_field_name') ): // loop through rows of data while ( have_rows('repeater_field_name') ) : the_row(); // display sub field value <div id="section-1"> the_sub_field('sub_field_name'); </div> endwhile; else : // no rows found endif; ?> just set index variable before loop , increment @ each iteration. use inside id . <?php $index = 1; while ( have_rows('repeater_field_name

git - Merged a branch with gitignored files, can't find those files anymore -

i had large log files in project, added log directory .gitignore after had made few logs (so there's log file directory few old logs in git, new ones ignored). had more logs in branch , merged master, along branch had been working on. newer logs don't show in master, , when switch branch they're not there either. there way recover these?

ruby on rails - Live Twitter Stream -

i'm programming application in ruby on rails v(2.0.0/4.0.0) , trying integrate live twitter feed specific source (@u101) onto basic html page , don't understand how. after googling around few hours i've seen few different gems seem integrate twitter (tweetstream, twitter api, twitter), however, can't of these work. i've followed guides such http://www.phyowaiwin.com/how-to-download-and-display-twitter-feeds-for-new-year-resolution-using-ruby-on-rails , 1 in particular gives me error: irb(main):002:0> tweet.get_latest_new_year_resolution_tweets nameerror: uninitialized constant twitter::search c:/sites/easybakeoven/blog/app/models/tweet.rb:6:in `get_latest_new _year_resolution_tweets' which don't understand. if walk me through necessary steps accomplish goal or point me in right direction i'd thankful. update: model: tweet.rb class tweet < activerecord::base #a method grab latest tweets twitter def self.get_latest_new_

pandas - How to Add a New Column With Selected Values from Another Column In Python -

Image
i have been trying figure out day. new python. i have table 50,000 records. table below explain trying do. i add third column called category. column contain values based results conditions set on movies column. ----------------------------------------- n | movies ----------------------------------------- 1 | save last dance ----------------------------------------- 2 | love , other drugs --------------------------------------- 3 | dance me --------------------------------------- 4 | love --------------------------------------- 5 | high school musical ---------------------------------------- the condition this; search through movies column these words {dance, love, , musical). if word found in string, return word in category column. this produce new dataframe @ end; ----------------------------------------- n | movies | category ----------------------------------------- 1 | s