Posts

Showing posts from May, 2014

autohotkey - (AHK) Creating variable hotkeys that gets the key names from a 2 char file name of a script -

i'm trying make our employees use dont have alter script define hotkeys. may work hotkeys can defined single character, that's fine, there many combinations can made them, , can easy remember. script @ 2 character ahk files (or 6 if must include extension) in working directory. , variables search defined regex first hotkey, ^. , second .(?=.) once match found, launch matched file. has been done before? seems simple can't seem find on it. edit: elliot brought attention: http://autohotkey.com/board/topic/60630-easy-editmanage-hotkeyshotstrings-plugin-ahk-l/ it's neat script manager, , useful, it's not i'm looking for. i dont not want additional interface. want able change hotkeys using filename. based on answer of forvin . added execution of corresponding ahk script. #persistent settimer, findnewhotkeys, 2000 findnewhotkeys: loop, %a_scriptdir%\* { regexmatch(a_loopfilename, "^(.)(.).ahk$", hk) if (hk)

c# - How to merge two datarow cells into one? -

Image
i trying merge 2 datarow cells one. here initializing code: datatable dt = new datatable(); datacolumn dc; datarow dr; dc = new datacolumn(); dc.datatype = system.type.gettype("system.string"); dc.columnname = "col1"; dt.columns.add(dc); dc = new datacolumn(); dc.datatype = system.type.gettype("system.string"); dc.columnname = "col2"; dt.columns.add(dc); dc = new datacolumn(); dc.datatype = system.type.gettype("system.string"); dc.columnname = "col3"; dt.columns.add(dc); dc = new datacolumn(); dc.datatype = system.type.gettype("system.string"); dc.columnname = "col4"; dt.columns.add(dc); dc = new datacolumn(); dc.datatype = system.type.gettype("system.string"); dc.columnname = "col5"; dt.columns.add(dc); this code have each column in excel: dr = dt.newrow(); dr["col1"] = ""; dr["col2"] = "quarter 1"; dr["col3"] = "&quo

python - Save log files in the user home directory -

i have logging.conf [1] file configure logging in python application. ... [handler_file_log_handler] class=logging.handlers.timedrotatingfilehandler level=info formatter=simple args=('/var/log/myapp/myapp.log',) as can see, i'm storing log file in /var/log/myapp directory. what store in user (the user manages application) home directory (/home/myuser/.myapp/log). so, question is: what should configure in logging.conf in order able save log file of python application in user home directory? [1] - https://docs.python.org/2.6/library/logging.html#configuring-logging the user's home directory can found (on os) using: os.path.expanduser("~")

javascript - Angular Select Dropdown with an option to let the user add a custom option -

i have html select dropdown in form asks user pick question out of pre-selected security questions. (such "what's favorite city", "what's color of car" etc.) how can add option list such "write own" , when user selects it, new input box shown user write his/her own question. one strategy can think of create input element ng-show hide/show based on value of select. there better way it? your best bet write custom directive simulate select box (likely using styled radio buttons), add option in there input. i've done similar several projects , thought isn't particularly difficult, there lot consider (including accessibility , keyboard controls). or can find 1 of many open-source directives online. while might not you're looking ui-select might option.

python - How to get utf-8 from forms in Bottle? -

i trying use bottle.py input information users in web page. everything works fine except when have latin characters (accents mostly). have try using utf-8 , latin-1 coding on first 2 lines of code, won't work. #!/usr/bin/env python # -*- coding: utf-8 -*- import bottle @bottle.post('/newpost') def post_newpost(): subject = bottle.request.forms.get("subject") body = bottle.request.forms.get("body") tags = bottle.request.forms.get("tags") and html code page is: <html> <head> <meta charset="utf-8" /> <title>new posts</title> </head> <body> <form action="/newpost" method="post"> <h2>post title</h2> <input type="text" name="subject" size="120" value="{{subject}}" ><br> <h2>post<h2> <textarea name="body" cols="120" rows="20">{{body}}</

multithreading - python socketserver: how to shutdown server with open client connection? -

i have been looking time solution terminate socketserver.streamrequesthandler spawned separate thread class threadingmixin when main tread terminates. problem socketserver thread, although being daemonic, not terminate long there open client connection, when calling shutdown() method @ program shutdown. therefore, main tread did not terminate. none of suggestions in how stop basehttpserver.serve_forever() in basehttprequesthandler subclass? or similar posts worked me. i have found solution: class threadingmixin has property daemonic_threads, default true: class threadingmixin: """mix-in class handle each request in new thread.""" # decides how threads act upon termination of # main process daemon_threads = false in subclass, which, of course, overrides method handle(), defines override in init daemon_threads = true now client requests daemonic , when main thread terminates, terminate. nice ! helps similar problem.

hadoop - ERROR 2245: Cannot get schema from loadFunc org.apache.hive.hcatalog.pig.HCatLoader -

i try load files partitioned hive table. lkr_bu = load 'basename.tablename' using org.apache.hive.hcatalog.pig.hcatloader(); after running following error: 2016-07-04 15:01:58,743 [uber-subtaskrunner] error org.apache.pig.tools.grunt.grunt - error 2245: cannot schema loadfunc org.apache.hive.hcatalog.pig.hcatloader for information, have required libraries , hcatalog {loader, storer} works oozie launcher. someone encountered kind of problem ? there many steps need follow make hcatalog work in pig. overall, assume have configured paths (hcatalog) , have included required jars in classpath. if not, please follow post :- http://www.thecloudavenue.com/2013/11/installingandconfiguringhcatalogandintegratingwithpig.html#comment-form or, can follow below post :- https://acadgild.com/blog/loading-and-storing-hive-data-into-pig/ after have followed steps above, need start following services :- hiveserver2 --> hive --service hiveserver2 hive metas

getting error when using wso2 ldap connector -

i'm using wso2 ldap connector retrieving data ldap server.so getting following error when calling service.try searchentry operation. { "error": { "errormessage": "missing 'equals'", "errorcode": 7000001 } } also refer wso2 documentation above scenario. is there reason this? this seems authentication error ldap. can recheck request sending , see if credentials correct?

android - Firebase null pointer exception -

i getting null pointer exception in firebase knows there not value database reference giving wants when value generated shown automatically... wants single value everytime created on firebase giving me null pointer exception on line string val =..... please me ... final databasereference dtt = database.getreference("/trial/trials/"); dtt.addvalueeventlistener(new valueeventlistener() { @override public void ondatachange(datasnapshot datasnapshot) { string val= datasnapshot.child("myvalue").getvalue().tostring(); if(val!=null) { log.e("not null------","---------------"); }else { log.e("null------","---------------"); } } @override public void oncancelled(databaseerror databaseerror) { } }); please me.....please .. you using getvalue() in wrong way.

android - Responsive activity -

Image
i'm learning develop android application 2 months now. have lot of question according layouts on android. i read this article , others on official documentation website (can't find link). understand in order screen size of elements matches resolution of phone, need use density-independent pixel (dp) element. let's imagine order layout according documentation : res/layout/main_activity.xml # handsets (smaller 600dp available width) res/layout-sw600dp/main_activity.xml # 7” tablets (600dp wide , bigger) res/layout-sw720dp/main_activity.xml # 10” tablets (720dp wide , bigger) just talk handset configuration. read in documentation the density-independent pixel equivalent 1 physical pixel on 160 dpi screen, baseline density assumed system "medium" density screen . maximum height , width can use in res/layout/main_activity.xml in dp ? if have same layout 4, 5, 6" phones, how possible me set image @ 50% of screen length using dp example

excel - Find maximum of row, return column name -

i have 4 rows , 6 columns of random numbers between 1 , 10 . headers atop named a through f accordingly. want populate range (a1:a6) on sheet maximum number each row. easy max function. however, in range ( b1:b6 ), want put column name number belongs. an hlookup() won't work because maximum value in 1 row not unique number across entire sheet. thinking match index type function, understanding of functions, in conjunction, poor. a b c d e f 1 0 2 10 9 8 9 3 7 6 9 10 10 3 0 2 1 4 9 4 7 8 6 3 assuming array in sheet1 , columns labelled, please try in sheet, copied down suit (to row 4 since there 4 rows of numbers in data): =index(sheet1!a$1:f$1,match(max(sheet1!a2:f2),sheet1!a2:f2,0)) this return first column label row maximum row occurs more once.

scala - Set Cassandra Clustering Order on TableDef with Datastax's Spark Cassandra Connector -

every time try create new table in cassandra new tabledef end clustering order of ascending , i'm trying descending. i'm using cassandra 2.1.10, spark 1.5.1, , datastax spark cassandra connector 1.5.0-m2. i'm creating new tabledef val table = tabledef("so", "example", seq(columndef("parkey", partitionkeycolumn, texttype)), seq(columndef("ts", clusteringcolumn(0), timestamptype)), seq(columndef("name", regularcolumn, texttype))) rdd.saveascassandratableex(table, somecolumns("key", "time", "name")) what i'm expecting see in cassandra is create table so.example ( parkey text, ts timestamp, name text, primary key ((parkey), ts) ) clustering order (ts desc); what end create table so.example ( parkey text, ts timestamp, name text, primary key ((parkey), ts) ) clustering order (ts asc); how can force set clustering order descending?

c++ - Is it safe to store a changing object in a stl set? -

i want container store unique std::weak_ptrs. std:set requires operator<, presumably because stores items in tree. worry if implement operator< in obvious way (destroyed ptr = null ptr < valid ptr) result can mutate after items added container, may break it. is in fact safe? if not, suggestions container? thanks you cannot use weak_ptr s keys unless use owner based comparison (against value based one, not defined weak_ptr , trying use operator< results in error). problem can expire , ordering of containers (a set map ) wouldn't consistent anymore. as correctly pointed out kerrek sb (forgive me, mobile app not let me correctly link users) , can read link in comments, can rely on std::owner_less starting c++11. a valid approach use set defined follows: std::set<std::weak_ptr<c>, std::owner_less<std::weak_ptr<c>>> note owner_less can less verbose, deduces type automatically. keep in mind approach not keep invoking exp

python 2.7 - Is there a Javascript equivalent to urllib.quote and urllib.unquote? -

according answer given identical question several years ago, encodeuricomponent(str) in javascript should equivalent urllib.quote(str, safe='~()*!.\'') in python. extension, have guessed decodeuricomponent(str) equivalent urllib.unquote(str). this not case experience. i'm writing networking code communicate python server client on website , i'm getting different results. i'm generating unique id , sending on tcp using identical following code: import urllib import struct import random def sendid(): id = random.systemrandom().getrandbits(128) upper = id >> 64 lower = id & 0xffffffffffffffff packed = struct.pack('<b2q', 0x00, upper, lower) encoded = urllib.quote(packed, safe='~()*!.\'') # below line sending on established tcp connection # code irrelevant working expected sendtoclient(encoded) the message received on clientside in following websocket object callback: this.websocket.

php - POST form with JQuery using $.post() -

i have following form <form id="colortest" method="post"> <input type="text" id='responsetext' name="responsetext" value=""> <input type="button" id='confirm' name="confirm" value="confirm"> <input type='text' id="idnum" name="idnum"> <input type='text' id='correct' id="correct"> </form> only value #responsetext typed in, #idnum passed page, while other fields filled function: <script type="text/javascript"> var arr = [2,5,6,7,10,16,29,42,57]; x = 0 /* idnum passed page 1 */ $(document).ready(function() { document.getelementbyid('idnum').value = localstorage.memberid; /* when typed in form */ $('#responsetext').on('input', function() { /* value stored */ var response = docume

c# - Anybody got a good way to ATOMICALLY create a temporary directory in .net managed code? -

the .net framework has gettempfilename, goes straight windows api procedure of same name, , far know threadsafe way create temporary file name not in use. it's hilariously outdated , limited, far know works, long keep temp directory filling up. but don't see that'll work creating temporary folders. in contentious parallel environment such web server, don't see way avoid race conditions between testing whether folder name in use, , creating it. suppose doable unmanaged api code, there may institutional resistance such solution. there better way? and if there is, can extended temp file creation, don't have use gettempfilename 4 hex digits of variation? -- think duplicate: linked other question did not address thread safety. , have develop situation thread safety serious concern -- have 32 cores running every 1 of them attempting create batches of hundred or thousand temp files apiece. -- update: book secure programming static analysis chess , west s

c# - Generic object for two different classes -

i have class acquisition device. want create class generates random samples when acquisition device not connected. this object: private object amplifierobj; and want create that if (ampsettingsobj.daqdevice == "noamp") ampobj = new noampmanager(samplerate: samplerate); else ampobj = new usbampmanager(optcalibrationflag: calibrationflag, serialnumbers: serialnumbers, samplerate: samplerate); however, when call 1 of methods error "object" not contain definition method . both classes have same methods implemented. best way of implementing it? should use generic class placeholder? if both classes have same methods should have interface (iamplifier) , both classes should implement interface. this can done right clicking 1 of classes , selecting refactor / extract interface. assuming interface name iamplifier, have both classes implement same interface such as: public class noampmanager : iamplifier { ...

html - How to make a hidden border side inherit border properties in CSS -

i came across unusual issue dynamic borders in css. trying "restore" / show side of border has been disabled either setting width 0 border-left-width:0; or using border-left:none; the problem don't want repeat same border properties since should adaptive dynamic solution hidden border should inherit element's set border. example code: jsfiddle /* ================== chic ================== */ body, html { margin: 0; padding: 0; font-family:verdana, sans-serif; height: 100%; text-align: center;font-weight: bold; background:#62726b; color:#abd4b1; } div { padding:50px; position: absolute; left:0; right:0; margin: 0 auto; width:50%; top:50%; transform:translatey(-50%); } /* ============= setting border ============= */ div { border:5px dashed #abd4b1; border-right:none; /* hide right border */ border-left-width:0; /* hide left border setting width 0

ios - Is it possible to override action method for UIButton in Swift? -

i have 1 uibutton . want use same uibutton execute multiple actions. first i'm setting action button programmatically. button1.addtarget(self, action: #selector(viewcontroller.function1), forcontrolevents: .touchupinside) next, want discard funtion , want add other action. button1.addtarget(self, action: #selector(viewcontroller.function2), forcontrolevents: .touchupinside) is possible override existing target button? the case suggested wont override previous action add second action button resulting in viewcontroller.function1 , viewcontroller.function2 being called. you need remove previous action target before adding new 1 using button1.removetarget(self, action: #selector(viewcontroller.function1), forcontrolevents: .allevents) or remove previous actions before adding new one button1.removetarget(nil, action: nil, forcontrolevents: .allevents)

postgresql - Mass instantiate or build objects in ActiveRecord quickly in Ruby -

i have financial app generates dynamic data database. projected daily revenue numbers, example, generated , outputted sql records ( pg:result in postgresql 9.4). how instantiate or build thousands of activerecord objects quickly? loop through each sql record taking long. note not database issue, because not need save database (in case mass insertion sql statement work). these numbers dynamic don't have create , save objects. reason want build activerecord objects can sort , filter through numbers using ar methods such where , find (for example, sorting objects sheet id and/or date). noticed keeping pg:result saves time, sorting through results (which array of hashes) requires messy code. sample object, flow , below: flow.new value_subunit: 10, sheet_id: 1, is_actual: true, period_start: '2015-01-01' end the sql query output looks following: sheet_id value_subunit is_actual period_start ---------------------------------------------- 1 10

php - Codiginter prevent direct access to method used by form action -

i new codeigniter framework, , have encountered issue unsure how solve properly. most of application requires authentication, have 1 public non authenticated controller form. uri form encoded single use token. form can accessed once. the code form action... <?php echo form_open('my_form/submit_form' . $id , 'id=”theform”'); … i want prevent accessing/visiting http://my-site.com/my_form/submit_form/someid , instead throw message. below way have working now, not sure if secure. using codeigniter's csrf protection, each $_post submitted csrf_token. class my_form extends mx_controller { … public function submit_form($id){ // attempt prevent direct access if (!isset($_post["input_id"])) { exit('sorry page inaccessible.'); } } so if value of hidden input field on form not set script exits. secure way handle this? try this, public function submit_form($id){

angularjs - How to display data from AJAX in Angular JS calendar? -

i use following calendar in angular js: angular-bootstrap-calendar i have ajax method returns dates calendar: $scope.showschedule = function () { apposervice.getschedule().then(function (response) { calendarservice.set(response.data.calendar, function (){ $scope.refleshcalendar(); }); }); }; inside callback can see method $scope.refleshcalendar(); : $scope.refleshcalendar = function () { angular.foreach(calendarservice.get(), function (item) { $scope.vm.events.push(item); }); }; this methos prepares data native object $scope.vm.events , adds dates calendar. at response ajax array of objects as: [{title: "ola", type: "info", startsat: "2015-10-31 17:00:00", resizable: true,…},…] full object is: {incrementsbadgetotal: true recurson: "year" resizable: true

java - How to add internal frame to menu -

i have gui has 3 menus:read files, add, finish. under add menu specifically, have 3 menu items called add owner, add residential property , add commercial property. when clicking of these menu items have internal frame come not want internal frame same menu items. trying add few more text fields commercial , residential property compared owner. not qant internal frame same unique each menu item , having trouble. here code import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class propertyguitest { public static void main(string[] args) { propertygui obj = new propertygui(); obj.setdefaultcloseoperation(jframe.exit_on_close); obj.setsize(400,300); obj.setvisible(true); obj.setlocation(100,50); } } class propertygui extends jframe { private int countframes = 0; public propertygui() { super("property gui"); jmenubar bar = new jmenubar(); setjme

node.js - Use nodejs short time write large amounts of data can't work -

i wrote crawlers using nodejs, go catch on key words of 100000 website, , writes results in txt file.but when second climb 100 websites , written file, cannot written file, program didn't work. may write fast. how solve? sorry english poor! 'use strict'; let fs = require('fs'); let http = require('http'); var writable = fs.createwritestream(__dirname + '/write.txt'); var sitelist = ['engineeringcircle.com/']; let count = 0; setinterval(function() { doreq(); } , 10); function doreq() { http.get('http://' + sitelist[0], function(res) { console.log(count++); let findata = ''; res.setencoding('utf8'); res.on('data', (data) => { findata += data; }) res.on('end', () => { writable.write(findata); }) }) } i'm using same website, don't errors if interval 10 ms, increase if still getting errors

c++ - Why don't compilers make unsigned vs signed comparison safe? -

this question has answer here: would break language or existing code if we'd add safe signed/unsigned compares c/c++? 6 answers as know, code generate warning: for (int = 0; < v.size(); ++i) the solution auto = 0u; , decltype(v.size()) or std::vector<int>::size_type pretend we're forced have both signed , unsigned value. compiler automatically cast int unsigned int (the actual type doesn't matter). using explicit cast, static_cast<unsigned int>(i) makes warning go away, bad because did same thing compiler did , silenced important warning! the better solution is: if ((i < 0) || (static_cast<unsigned int>(i) < v.size())) understandably, c "closer metal" , consequence more unsafe. in c++, there's no excuse this. c++ , c diverge (as have been doing many years), hundreds of improvements c++ have increased

c# - Entity Framework Execute Query on Multiple Servers -

i developing first c# web app , needs import data multiple servers on demand. i have server names stored in table (dataserver). need connect each server , run query, results of want add data model. this have in repository public void scanserver(int serverkey) { var servername = findbykey(serverkey).servername; var sqlquery = "select name ,description mytbl"; context.database.sqlquery<names>(sqlquery); } i know using context incorrect, i'm hoping replace connection string held in dataserver table. the results need added names datamodel. am on right track this? you should able open connection using connection string thus: foreach(string connectionstring in servers) { using (var context = new dbcontext(connectionstring)) { //query code } }

Javascript/PHP string equality -

i'm running ajax call has success function takes in variable returned php page so. ajax: $.ajax ({ type: "post", url: "loginrequest.php", data: 'username=' + username + '&password=' +pass, success: function(html){ console.log(html); // returns login console.log(typeof html); // returns string console.log(html === "login"); //returns false if(html === 'login'){ window.location.href = 'index.php'; } else if(html === 'false'){ alert("login failed"); } } }); php: if($count == 1){ $_session['user'] = $myusername; $return = "login"; echo json_encode($return); } else { $return = "false"; echo json_encode($return); } as can see i'm trying implement simple login page , redirect user or display alert depending on outcome of number of rows retu

html5 - get around cross-origin resource sharing on Amazon Aws -

i creating virtual reality 360-degree video website using krpano html5 player. this going great until testing on safari , realised didn't work. reason because safari not support cors (cross-origin resource sharing) videos going through webgl. to clarify, if videos on same server application files work, because have files hosted on amazon s3 , cors. i'm unsure because have built application on digital ocean connects amazon s3 bucket, cannot afford droplet storage need(which around 100gb start , increase in future terrabytes , video collection gets bigger). so know way can around make seem video not coming different origin or alternatively can past obstacle? is there way set amazon s3 , amazon ec2 dont see each other cross-origin resource sharing? edit: i load videos this: <script> function showvideo(){ embedpano({ swf:"/krpano/krpano.swf", xml:"/krpano/videopano.xml", target:"pano", h

mysql - sql how to use this syntax more light weight? -

hello i'm getting message: [the select examine more max_join_size rows; check , use set sql_big_selects=1 or set max_join_size=# if select okay] on syntax: select concat(v2.meta_value, ' ', v3.meta_value) name, a.usr, a.vagtdato, b.timeloen, c.provision, d.kursus, e.trappetur, f.sygedag $main_table left join (select usr, count(vagt_type) timeloen $main_table vagt_type = 'timeloen' , vagtdato between date('$start') , date('$end') group usr ) b on b.usr=a.usr left join (select usr, count(vagt_type) provision $main_table vagt_type = 'provision' , vagtdato between date('$start') , date('$end') group usr ) c on c.usr=a.usr left join (select usr, count(vagt_type) kursus $main_table vagt_type = 'kursus' , vagtdato between date('$start') , date('$end') group usr ) d on d.usr=a.usr left join (select usr, count(vagt_type) trappetur $main_table vagt_type = 'trappetur' , vagtdato betwe

git - How do you merge and close a pull request that has a conflict? -

say merge in 1 pull request, makes 1 out of date , unable merged in. i following: $ git remote add <username> <url> $ git fetch <username> $ git co -b <pull-request-branch> <username>/<pull-request-branch> $ git rebase master make appropriate changes $ git add . $ git rebase --continue $ git checkout master $ git merge <pull-request-branch> $ git push origin master but not automatically close pull request. is there way directly fetch pull request itself, merge in, , push master automatically close pull request? as documented, pr closed when merged master branch . except here, changed pr branch, rebasing on top of master. not role. contributor submitting pr supposed (rebasing on top of upstream/master , upstream being remote referring original repo) you should merge pr branch, , merge should fast-forward one. is there way directly fetch pull request itself, merge in, , push master ? that started do: git

C++ Makefile 3 files -

i have makefile problem. know how create makefile two, not 4 different files including header files... there 4 files, main.cpp dictionary.h dictionary.cpp , cinco.h cincotest: main.o cinco.o g++ -o p3 main.o cinco.o main.o: main.cpp cinco.h g++ -c main.cpp dictionary.o: dictionary.cpp dictionary.h g++ -c .cpp # clean clean: rm -f p4 *.o *~ do need other files code or here?? if know answer , input new code perfect ;) it looks me standard way of organizing code - .cpp , .h header file go it. the rules have sufficient. unless main.cpp #include-s dictionary.h header file, or dictionary.cpp #include-s cinco.h , in case: main.o: main.cpp cinco.h dictionary.h g++ -c main.cpp dictionary.o: dictionary.cpp cinco.h dictionary.h g++ -c .cpp a makefile dependency list. each *.o file, it's dependencies source files needed compile it. if in main.cpp #include dictionary.h , change dictionary.h means main.cpp needs recompiled, of cou

css - Wordpress: Why isn't my stylesheet being enqueued? -

i'm modifying existing wp plugin making separate plugin extend it. i'd write css override plugin. however, when try enqueue stylesheet doesn't work. know doesn't work because added simple form in includes() , tried style words red in order see change. why isn't working?? note - i'm using action hook plugins_loaded , read in codex happens before wp_enqueue_script . don't suspect enqueueing missing timing, i'm new wp dev correct me if i'm wrong. update - please see updated css code below. #id selector wasn't coloring text red by itself , when added p (paragraph selector) worked. neither selector worked itself, worked when added both. why this? find-do-for-anspress.php if (! defined('wpinc')) { die; } class find_do_for_anspress { /** * class instance * @var object * @since 1.0 */ private static $instance; /** * active object instance * * @since 1.0 * * @access publ

compiler errors - I keep getting 'Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 30? -

this edhesive class, , works fine when use eclipse compiler. reason when enter edhesive's compiler, error keeps popping up. import java.util.scanner; class main { public static void main(string[] args) { scanner scan = new scanner(system.in); system.out.println("what month born in? (number)"); int month = scan.nextint(); system.out.println("what day? (number)"); int day = scan.nextint(); string[] arraym = { "january", "february", "march", "april", "june", "july", "august", "september", "october", "november", "december" }; string[] arrayd = { "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eight", "ninth", "tenth", "eleven

reactjs - Class extends React.Component can't use getInitialState in React -

i'm tring es6 syntax in react, , write components like: export default class loginform extends react.component { getinitialstate() { return { name: '', password: '' }; }; } but browser throws me waring about: warning: getinitialstate defined on loginform, plain javascript class. supported classes created using react.createclass. did mean define state property instead? i can handle traditional syntax var loginform = react.createclass what's correct es6 syntax? another little thing, think in traditional syntax react.createclass object, functions in separated comma, extends class require semicolon, don't understand well. you don't need semicolons or commas between es6 class method declarations. for es6 classes, getinitialstate has been deprecated in favor of declaring initial state object in constructor: export default class loginform extends react.component { constructor(p

tomcat - Try to run a web application with a html page in Intellij IDEA but get 404 error -

i want simple thing: let user input username , password, show on second page. use tomcat 8 server. here key codes: login.html: <!doctype html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html" charset="utf-8"> <title>login</title> </head> <body> <div align="center"><h1>login in</h1> <form method="post" action="getpostdata" name="login form" align="center"> <table align="center" width="232" border="2"> <tr> <td>username</td> <td><input type="text" name="username"></td> </tr> <tr> <td>password</td>

Recurly PHP client. How to customize error messages? -

i'm trying customize error messages. handling errors used "try/catch" block according this recurly documentation, example: try { $account = recurly_account::get('my_account_id'); $subscription = new recurly_subscription(); $subscription->account = $account; $subscription->plan_code = 'my_plan_code'; $subscription->coupon_code = 'my_coupon_code'; /* .. etc .. */ $subscription->create(); } catch (exception $e) { $errormsg = $e->getmessage(); print $errormsg; } i wanted use code in catch block this: catch (exception $e) { $errorcode = $e->getcode(); print $myerrormsg[$errorcode]; // array of custom messages. } but getcode() method returns 0 possible errors. my question recurly team (or there in theme): how error code errors? or please explain me how can resolve topic. thanks! if @ php client on github , search "throw new" done when exception thrown you'll see don't set e

css - autoprefixer not prefixing @keyframes? -

i copied sample @ https://www.npmjs.com/package/gulp-autoprefixer after installed gulp , gulp-autoprefixer : var gulp = require('gulp'); var autoprefixer = require('gulp-autoprefixer'); gulp.task('default', function () { return gulp.src('src/a.css') .pipe(autoprefixer({ browsers: ['last 2 versions'], cascade: false })) .pipe(gulp.dest('dest')); }); and have following in a.css : @keyframes x { { left: 0; } { left: 100%; } } after gulp , a.css in desc, exact same code original. no -webkit- added, http://caniuse.com/#search=keyframes should prefixed android browser, target device. am missing something? the caniuse site specifies keyframes supported 4.3 without need prefix. in gulp have specified prefixing should occur last 2 versions of browsers. meaning prefixing based on rules set out browsers 2 versions previous: browsers: ['last 2 versions&#

Node.js, express and socket.io : socket.on doesn't receive message socket.emit from the server to the client -

this function doesn't work in app. i can't receive message (socket.emit) from server client (socket.on). don't have problem in inverse (client server). i use cloud9 , chat example them works fine. here code server : var http = require('http'); var path = require('path'); var async = require('async'); var socketio = require('socket.io'); var express = require('express'); var router = express(); var server = http.createserver(router); var io = socketio.listen(server); router.use(express.static(path.resolve(__dirname, 'client2'))); io.on('connection', function (socket) { socket.emit('hello', 'i changed'); // !!! }); server.listen(process.env.port || 3000, process.env.ip || "0.0.0.0", function(){ var addr = server.address(); console.log("chat server listening at", addr.address + ":" + addr.port); }); and code html page : <html> <head>

sql - is this functional dependency derivation correct? -

let's say, have 2 functional dependencies a -> ef b -> gh is there axiom through can deduce relationship below? ab -> efgh you can derive: ab -> efgh from: a -> ef b -> gh with following steps: 1. -> ef (by hypothesis) 2. b -> gh (by hypothesis) 3. ab -> bef (by augmentation, adding b left , right part of 1) 4. ab -> agh (by augmentation, adding left , right part of 2) 5. ab -> abefgh (by union) 6. ab -> efgh (by decomposition) using armstrong axioms , both base axioms (augmentation) , derived ones (union, decomposition).

java - Generating a pre-signed PUT url for Amazon S3 with a maximum content-length -

i'm trying generate pre-signed url client can use upload image specific s3 bucket. i've succesfully generated requests files, so: generatepresignedurlrequest urlrequest = new generatepresignedurlrequest(bucket, filename); urlrequest.setmethod(method); urlrequest.setexpiration(expiration); where expiration , method date , httpmethod objects respectively. now i'm trying create url allow users put file, can't figure out how set maximum content-length. did find information on post policies , i'd prefer use put here - i'd avoid constructing json, though doesn't seem possible. lastly, alternative answer way pass image upload api gateway lambda can upload lambda s3 after validating file type , size (which isn't ideal). while haven't managed limit file size on upload, ended creating lambda function activated on upload temporary bucket. function has signature below public static void checkupload(s3eventnotification event) { (this nota

python - How to get scraped items from main script using scrapy? -

i hope list of scraped items in main script instead of using scrapy shell. i know there method parse in class foospider define, , method return list of item . scrapy framework calls method. but, how can returned list myself? i found many posts that, don't understand saying. as context, put official example code here import scrapy tutorial.items import dmozitem class dmozspider(scrapy.spider): name = "dmoz" allowed_domains = ["dmoz.org"] start_urls = [ "http://www.dmoz.org/computers/programming/languages/python/", ] def parse(self, response): href in response.css("ul.directory.dir-col > li > a::attr('href')"): url = response.urljoin(href.extract()) yield scrapy.request(url, callback=self.parse_dir_contents) def parse_dir_contents(self, response): result = [] sel in response.xpath('//ul/li'): item = dmozitem()

wpf - Char Password box as in TextBox -

how set characters in textbox in password box or how make binding password box ? <textbox text="{binding passwordadmin, mode=twoway}" grid.row="5" grid.column="1" style="{dynamicresource ltb.textbox}"/> use control passwordbox: <passwordbox x:name="passwordbox" grid.row="5" grid.column="1" /> here usefull links: http://www.wpftutorial.net/passwordbox.html https://msdn.microsoft.com/en-us/library/system.windows.controls.passwordbox(v=vs.100).aspx a link risk of binding password: http://gigi.nullneuron.net/gigilabs/security-risk-in-binding-wpf-passwordbox-password/

if statement - JavaScript Conditionals not working -

i'm sorry didn't search topic thought bit specific, ok that's out of way! when run missionbutton.click(); ran, though checkhealth() = 0 it's it's skipping on original if statement, normal javascript (i'm used other languages) //__action_functions__ // when you're @ 0 health. function hospital(){ location.assign("http://www.gangwarsmobile.com/index.php?p=hospital"); var hospitaluse = hospitalid; hospitaluse.click(); settimeout(location.assign("http://www.gangwarsmobile.com/index.php?p=crimes"),5000); } //__does mission__ function start(){ var missionbutton = crimeid; //crimeid buttonid /crimes page/ variables @ top of script. if(checkhealth() === 0){hospital();} else if (checkstamina() > 0);{missionbutton.click();} } i can't see reason why not work. extra i'm using tampermonkey, if makes difference. did forget take out ; after () > 0 ? original: if(checkheal

How do i properly compare dates in moment.js using node.js + mongoose -

i have 2 dates compare , current date , future date in mongodb database (i'm using mongoose orm) var user = mongoose.schema({ future_month: string }); this futuremonth value future_month = moment().add(1, 'm').format('dd-mm-yyyy'); and tried compare current date , future date exports.istrue = function() { var currentdate = moment().format("dd-mm-yyyy"); if (currentdate <= req.user.future_month) { console.log("still active"); } else { console.log("you have pay"); } } i "you have pay" though currentdate = 31-10-2015 req.user.future_month = 30/11/2015 it supposed run "still active" because currentdate less req.user.future_month value and 1 more thing typeof currentdate , future_month both strings, that's why put mongoose field string type. let guys know. you trying compare strings. won't work in cases, format you're using. instead,