Posts

Showing posts from July, 2012

javascript - Implement social buttons on unlimited/infinite scrolling website? -

i'm using jquery social-likes plugin implement social buttons on index page of ruby on rails based website. index page infinitely scrollable, when new content loaded, newly loaded item doesn't display social buttons. how can make re-rendering of these social buttons when new item loaded on runtime. thanks!

How to use Interceptor.Dll in C# and Kinect SDK to send keypresss event to DirectX Games? -

Image
i want send keyboard key events directx games using kinect. i using c# + kinect sdk, have tried interception.dll wrapper. but cannot implement interception in c# code. here code getting error: input input = new input(); input.keyboardfiltermode = keyboardfiltermode.all; input.load(); input.sendkeys(keys.up,keystate.down); input.unload(); screenshot:

php - UTF-8 all the way through -

i'm setting new server, , want support utf-8 in web application. have tried in past on existing servers , seem end having fall iso-8859-1. where need set encoding/charsets? i'm aware need configure apache, mysql , php - there standard checklist can follow, or perhaps troubleshoot mismatches occur? this new linux server, running mysql 5, php 5 , apache 2. data storage : specify utf8mb4 character set on tables , text columns in database. makes mysql physically store , retrieve values encoded natively in utf-8. note mysql implicitly use utf8mb4 encoding if utf8mb4_* collation specified (without explicit character set). in older versions of mysql (< 5.5.3), you'll unfortunately forced use utf8 , supports subset of unicode characters. wish kidding. data access : in application code (e.g. php), in whatever db access method use, you'll need set connection charset utf8mb4 . way, mysql no conversion native utf-8 when hands data off applicati

analytics - How to perform approximate (fuzzy) name matching in R -

i have large data set, dedicated biological journals, being composed long time different people. so, data not in single format. example, in column "author" can find john smith, smith john, smith j , on while same person. can not perform simplest actions. example, can't figure out authors wrote articles. is there way in r determine if majority of symbols in different names same, take them same elements?

oop - Do "return success" methods violate the single responsibility principle? -

public class foolist { public boolean add(foo item) { int index = indexof(item.getkey()); if (index == -1) { list.add(item); } return index == -1; } } since adds item and returns success value, violate single-responsibility principle? if so, matter? an alternative throw exception: public class foolist { public boolean add(foo item) throws fooalreadyexistsexception { int index = indexof(item.getkey()); if (index == -1) { list.add(item); } else { throw new fooalreadyexistsexception(); } } } but this, too, violate single-responsiblity principle? seems method has 2 tasks: if item doesn't exist, add it; else, throw exception. bonus question: methods can return null violate single-responsibility principle? here's example: public class foolist { public foo getfoo(string key) { int index = indexof(key); return (index == -1) ? null

php - Syntax error or access violation: 1064 ' brandname -

i'm getting error in magento script: product not added exception:exception 'pdoexception' message 'sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near 's secret'' @ line 1' some background info: i have php script running on cron job add , update products. runs while now, got error. think it's because manufacturers name got apostrophe in it. have no clue how fix it. changing manufacturer's name not option. function addmanufacture($pid,$men){ $resource = mage::getsingleton('core/resource'); $readconnection = $resource->getconnection('core_read'); $query = "select manufacturers_id p1_manufacturers m_name='".$men."'"; $lastid = $readconnection->fetchone($query); $write = mage::getsingleton("core/resource")->getconnection("core_write&quo

java - Google Map V2 shows blank screen when downloded from google play store -

Image
i made simple maps project, works great when installing form eclipse onto tablet, however, when uploded google play store, turns out when download store, map blank, tried , realized true this how app looks when installing form eclipse device and how looks when downloded device google play store. this manifest <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.zivkesten.find_a_place" android:versioncode="5" android:versionname="1.4" > <uses-sdk android:minsdkversion="11" android:targetsdkversion="19" /> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name=&q

windows phone 7 - Getting ApplicationId and AdUnitID from new pubcenter website -

ms pubcenter has updated website modern. wanted add ads wp application created new 1 banner 480 80. found (i not sure) appunitid cant find application id ? choose application pubcenter , scroll down website , right can see application id , unit id

python - Parsing xml with simple structure -

for reasons can't extract content of xml below: can please point me in right direction? f='''<features> <name>michael</name> <age>81</age> <dob>20/10/1925</dob> </features>''' attempt: tree=et.parse(stringio(f)) root=tree.getroot() x in root: print x.tag, x.attrib output: name {} age {} dob {} ideal output: name {michael} age {81} dob {20/10/1925} not @ xml python, suggestions? your elements not have attrib s. try x.text instead, although need add curly braces if want text in curly braces. >>> import xml.etree.celementtree et >>> root = et.fromstring(f) >>> x in root: print x.tag, x.text name michael age 81 dob 20/10/1925

java - Best way to store temporary QuestionID-AnswerID data -

Image
i'm developing quiz app , want find efficient way save user's answers. each quiz has 30 questions , need save is: questionnumber , questionid , answerid , either answer correct or not. i thought array solution. example: each row represents question ( questionnumber ). first column represents questionid , second answerid . third column contain either 0 (incorrect) or 1 (correct). the third column (correct) needed sum number of correct answers (it's faster sum third column instead of checking each answer time). this isn't sql table - info temporary , destroyed user finishes quiz. i want know if have other solutions, maybe better. thank you! why not class? class answer { private int questionid; private int answerid; private boolean correct; public answer(int questionid, int answerid, boolean correct) { this.questionid = questionid; this.answerid = answerid; this.correct = correct; } } a

c# - Display all child records of a parent in DataGridView -

i new .net, , don't understand how works. have project have , i'm asked display parent records, , when select parent record there should displayed children. far managed display parent records, using datagridview. private void display_btn_click(object sender, eventargs e) { dg.datasource = data_set.tables[0]; } the following code works displays records child. know should compare somehow primary key parent foreign key child , display child equal pk parent, don't know how write it. private void dg_cellcontentclick(object sender, datagridviewcelleventargs e) { dg2.datasource = data_set.tables[1]; } the code creating relation datacolumn parentcolumn = data_set.tables["airline"].columns["airline_id"]; datacolumn childcolumn = data_set.tables["plane"].columns["airline_id"]; rel_pln_air = new datarelation("fk_pln_air", parentcol

string - How do I write to a specific line of file in c? -

so have project doing , have created program allows user write file, shown below: #include <stdio.h> #include <stdlib.h> file *fd; file *fw; struct store { char word[512]; char nword[512]; } stock; struct store2 { char definition[512]; } stock2; char done='y'; int count=1; int c=0; int d=0; int main(void) { fw=fopen("test z w.txt","w"); fd=fopen("test z d.txt","w"); { printf("word %d: ",count); gets(stock.word); while((c= getchar()) != '\n' && c != eof); printf("definition %d: ",count); gets(stock2.definition); while((c= getchar()) != '\n' && c != eof); fprintf(fw,"%s\n", stock.word); fprintf(fd,"%s\n", stock2.definition); count=count+1; sys

CSS files are not showing on server - ASP.NET MVC Bundles error. 403 - Forbidden: Access is denied -

my mvc 4 application works fine on local computer. however, css files not working after publish (are not affecting layout of website). i can see css files on server. when @ source code, can see <link href="/content/css?v=fxcdhaogpdvcroxkmfewgqggo9ucfzckn3pan8boizi1" rel="stylesheet"/> where on local computer, source code shows as <link href="/content/css/myfile.css" rel="stylesheet"/> <link href="/content/css/myfile02.css" rel="stylesheet"/> so, in source code view on server, clicked on content/css?v=fxcdhaogpdvcroxkmfewgqggo9ucfzckn3pan8boizi1 , browser took me 403 - forbidden: access denied. i adding css files bunldeconfig.cs class public class bundleconfig { // more information on bundling, visit http://go.microsoft.com/fwlink/?linkid=254725 public static void registerbundles(bundlecollection bundles) { bundles.add(new scriptbundle("~

ios - UIActivityViewController not working after Cancel -

i using instance of uiactivityviewcontroller in universal app. works absolutely on ipad. nearly, not quite on iphone. i present using: [self presentviewcontroller:self.activityviewcontroller animated:yes completion:nil]; it displays available activities correctly , if choose one, works. can tap on share button again , repeat same or different activity like, long complete activity. if cancel uiactivityviewcontroller , well; if cancel from, say, mail or message, next time tap on share, nothing happens. if impatient , tap again, following error: 'application tried present modally active controller .' i've tried dismissing controller before presenting second time, doesn't think dismissible. i've tried presenting root/navigation controller tableviewcontroller, equivalent error (i.e. app tried present root controller). i see there lots of 'odd' problems uiactivityviewcontroller , can't see relevant problem. the problem due examp

android - Sending string arrays to php -

i want send string array php json , retrieve there. string[] books = {"book1", "book2", "book3", "book4",..}; in json: list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>; namevaluepairs.add(new basicnamevaluepair("books", books)); httppost.setentity(new urlencodedformentity(namevaluepairs)); ... in php side: $books = $_post['books']; $result = json_decode($books); // ok? or can use below? $book1 = $result[0]; $jsonstring = '["xxx@gmail.com","yy@gmail.com","rr@gmail.com"]'; $arrayofyouremails=json_decode($jsonstring); or $jsonstring = "[\"xxx@gmail.com\",\"yy@gmail.com\",\"rr@gmail.com\"]"; $arrayofyouremails=json_decode($jsonstring); and yes code right $books = $_post['books']; $result = json_decode($books);

Asp.net MVC: Save on repetitive markup with EditorForModel vs Flexibility -

i'm quite new asp.net mvc developer , current question editorformodel htmlhelper i'm indulged use save on repetitive markup within application. but i'm hesitant because seems bit unflexible when comes layout of form. one of cases rather large form surely 30+ fields user enter. naturally kind of form divided different sections , sections distributed between columns. use editorformodel assume have create subclasses members of viewmodel class , create partial views each member can call editorformodel render part of overall model. in essence think question this: should viewmodel classes represent actual user interface view strictly or should view self (.cshtml) responsible final layout of form? also, if have fields break repetitive markup of [wrapper label , input field], example combination of postal code , city fields should line beside each other instead of after each other, supposed wrap properties (probably entire adress) within own class , create specific edit

dns - http://[DOMAIN].de.de:443/ always shows the same site -

i played around urls , found out requesting http://[domain].de.de:443/ always shows message: bad request browser sent request server not understand. reason: you're speaking plain http ssl-enabled server port. instead use https scheme access url, please. hint: default-62_116_182_44 apache server @ default-62_116_182_44 port 443 opening ip "62.116.182.44" shows "parallels plesk". try domains: test.de.de:443/ stuff.de.de:443/ dasjkdsakjdsajkjkdsa.de.de:443/ my question: responsible this? denic? you request http resource on port 443, https servers reside. server catches invalid usage (because request not start of ssl handshake, instead http request) , replies in way browser can understand, e.g. responding error message inside http response. this has nothing denic, setup of web server owner of host.

movement - Unity3D move a sprite when pressing a key -

i'm trying move sprite when hit w key. have been using tutorial found on youtube , don't seem able make work. here code. perhaps i'm having problem transform; can see x position increments sprite doesn't anything. #pragma strict var startpoint : vector3; var endpoint : vector3; var speed : float; private var increment : float; var ismoving : boolean; function start () { startpoint = transform.position; endpoint = transform.position; } function update () { if (increment <= 1 && ismoving == true) { increment += speed/100; debug.log("moving"); } else { ismoving = false; debug.log("stopped"); } if (ismoving == true) transform.position = vector3.lerp(startpoint, endpoint, increment); if (input.getkey("w") && ismoving == false) { increment = 0; ismoving = true; startpoint = transform.position; endpoint = new ve

c++ - A more elegant way to copy std::string into a vector<char> -

this question has answer here: converting std::string std::vector<char> 2 answers i can't see find answer this, sorry in advance if there duplicate. is there more elegent way of creating vector<char> string . std::string s("i'm afraid. i'm afraid, dave."); std::vector<char> temp; (size_t x = 0; x < s.size(); x++) { temp.push_back(s[x]); } thanks construct range iterator this: std::vector<char> temp(s.begin(), s.end());

java - Vertical alignment of checkboxes -

Image
could me understand how set left vertical alignment checkboxes. mean each checkbox on own row. tried imagine , have come end of wit. public class displayframe extends jframe { public displayframe(arraylist<string> contents){ displaypanel panel = new displaypanel(contents, whitelist); add(panel); } private void displayall(){ displayframe frame = new displayframe(contents, whitelist); gridbaglayout gbl = new gridbaglayout(); frame.setlayout(gbl); frame.setvisible(true); ... } public class displaypanel extends jpanel { arraylist<jcheckbox> cbarraylist = new arraylist<jcheckbox>(); arraylist<string> contents; ... public displaypanel(arraylist<string> contents){ ... createlistofcheckboxes(); } private void createlistofcheckboxes() { gridbagconstraints gbc = new gridbagconstraints(); gbc.gridwidth = contents.size() + 1; gbc.gridheight = co

php - Non persistent pg connections -

i've changed pgsql.allow_persistent off in /etc/php.ini , , restarted apache. now i'm getting identical pg handles 2 consecutive pg_connect . array ( [0] => resource id #14 [1] => resource id #14 ) my question is, php still using persistent connections, , should done if answer yes. php caches connections within given script run, multiple connect calls same params return same connection. unlike persistent connections caching occurs within single script run. as found, can disable caching force new flag - pgsql_connect_force_new.

ruby on rails - Testing a simple has many association through a join table -

to wrap exercise i'm working on, i'm trying test association through join table. i'd test association artists have many collections through art pieces , collections have many artists through art pieces. below code: context 'associations' let(:artist){ artist.create(first_name: "daniel", last_name: "rubio", email: 'drubs@email.com', birthplace: 'mexico', style: 'contemporary') } let(:art_piece) { artpiece.new(date_of_creation: datetime.parse('2012-3-13'), placement_date_of_sale: datetime.parse('2014-8-13'), cost: 250, medium: 'sculpture', availability: true, artist_id: artist.id, customer_id: customer.id, collection_id: collection.id)} let(:customer) { customer.create(first_name: 'carmen', last_name: 'dent', email: 'cdent@email.com', no_of_pur

PHP change date format -

i have date monthpicker in format: 2014 april , , want change 2014-04-01 before inserting mysql. i'm trying use strtotime: $b = date("y-m-d", strtotime($_post['month'])); echo $b; result is: 1970-01-01. dont it. use datetime $date = new datetime("2014 april"); echo $date->format("y-m-d");

ios - How to create 2-dimensional array with nil elements -

in chess game use 2-dimensional array track positions of pieces @ chess board. initially thought create nsmuteablearray , indicate unoccupied squares nil . occupied slots should hold pointer piece object... however following code: nsmutablearray* _board; ... _board = [[nsmutablearray alloc] init]; (int = 0; < 8; i++) { nsmutablearray *row = [[nsmutablearray alloc] init]; (int j = 0; j < 8; j++) { [row addobject:nil]; } [_board addobject:row]; } fails runtime error: *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '*** -[__nsarraym insertobject:atindex:]: object cannot nil' so nil can't passed argument addobject ... here instead? try nsmutablearray* _board; ... _board = [[nsmutablearray alloc] init]; (int = 0; < 8; i++) { nsmutablearray *row = [[nsmutablearray alloc] init]; (int j = 0; j < 8; j++) { [row addobject:[nsnull null]]; } [_board addob

java - Why wont my custom JButton display its name? -

hi working on project , having trouble adding jbuttons. reason, wont print name. this class supposed add custom buttons import java.awt.*; import javax.swing.jpanel; public class fightpanel extends jpanel { public static final int width = 600; public static final int height = 600; public fightpanel() { setpreferredsize(new dimension(width, height)); setlayout(new borderlayout()); fightbutton test = new fightbutton("test"); add(test); } } this class custom button class import javax.swing.jbutton; public class fightbutton extends jbutton { private string name; public fightbutton(string name) { this.name = name; setname(name); } } the setname() method not control text displayed on button. used application code identify component. the settext(...) used set text displayed in button. did know have use super constructor that. you don't have easiest way want since passing text parameter class. if want change text

parsing - Splitting a String C++ -

i entering type of input command line : mynameis "jason roger" i want have mynameis , jason roger in 2 different strings. failed in printing input. when use string command; cin>>command cout<<command<<endl; i mynameis how can fix this? thanks. the >> operator reads input stream ( cin , here) until hits whitespace character. might want @ getline function instead, need split string manually.

python - Scaling the second axe on a histogram with Matplotlib -

Image
i want have second axe on histogram, pourcentage corresponding each bin, if used normed=true. tried use twins, scale not correct. x = np.random.randn(10000) plt.hist(x) ax2 = plt.twinx() plt.show() bonus point if can make work log scaled x :) plt.hist returns bins , number of data in each bucket. may use these compute area under histogram, , using may find normalized height of each bar. twinx axis can aligned accordingly: xs = np.random.randn(10000) ax1 = plt.subplot(111) cnt, bins, patches = ax1.hist(xs) # area under istogram area = np.dot(cnt, np.diff(bins)) ax2 = ax1.twinx() ax2.grid('off') # align twinx axis ax2.set_yticks(ax1.get_yticks() / area) lb, ub = ax1.get_ylim() ax2.set_ylim(lb / area, ub / area) # display y-axis in percentage matplotlib.ticker import funcformatter frmt = funcformatter(lambda x, pos: '{:>4.1f}%'.format(x*100)) ax2.yaxis.set_major_formatter(frmt)

java - Reading and Storing Multiple Files -

what trying read multiple files , store contents of files data structure. know how many files have , names of files number , names of files can change. after read in contents of files , store them need able find specific string contains across files. what having trouble have no idea easiest data structure task. thinking hashmap, , using file names key. work? there better data structure? using java edit: have been reading contents of file arraylist because each line contains separate information need able reference in future. if files not big enough can use simple map map<string, list<string>> map = new hashmap<string, list<string>>(); key(string) file name value(arraylist) contents of file (lines) if files big data structure not sufficient.

How to TDD in Ruby using Eclipse on Windows -

Image
how tdd following snippet in ruby using eclipse on windows? class passintegers def addition(i,j) k = i+j end end install test-unit executing gem install test-unit run following snippet 2 ruby test require 'test/unit' require 'passintegers' class testpassintegers < test::unit::testcase def test_pass_integers passintegers = passintegers.new expected = passintegers.addition 3,2 assert_equal expected, 5 end end possible issue if following error occurs @ eclipse console: c:/dev/tools/eclipse/configuration/org.eclipse.osgi/bundles/965/1/.cp/testing/dltk-testunit-runner.rb:252:in `block in <top (required)>': uninitialized constant test::unit::ui::silent (nameerror) open c:\dev\tools\eclipse\configuration\org.eclipse.osgi\bundles\965\1\.cp\testing\dltk-testunit-runner.rb , solve commenting #autorunner.output_level = test::unit::ui::silent and adding autorunner.runner_options[:output_level] = tes

What is the clearest way to open a file and do "rescue" when it cannot be opened in Ruby -

i dealing issue using following code begin file.open(filename, 'r') rescue print "failed open #{filename}\n" exit end is there way more perl 'open (in, $filename) || die "failed open $filename\n"' thanks. file.open("doesnotexist.txt", 'r') is enough. if file not exist, raise exception. not caught, program exits. # =>test6.rb:1:in `initialize': no such file or directory @ rb_sysopen - doesnotexist.txt (errno::enoent)

sorting - Using map in java -

i working on app reads set of int s console , creates map each unique int . counts how many times input occurs , prints out ordered tally. have gotten far , having hard time moving forward here. package examprep; import java.awt.list; import java.awt.point; import java.util.arraylist; import java.util.hashmap; import java.util.map; import java.util.scanner; import java.util.set; import javax.swing.text.html.htmldocument.iterator; public class mapthatreadsints { public static void main(string[] args) { // based on problem gave in class scanner input = new scanner(system.in); system.out.println("please enter integer"); int inputvalue = input.nextint(); hashmap<integer, integer> numbermap = new hashmap<integer, integer>(); numbermap.put(inputvalue, inputvalue); system.out.println("size of map " + numbermap.size()); } } i know have use arraylist here somewhere , loop iterate on

c++ - invalid use of non-static member C++98 -

i'm writing c++ program that, unfortunately, requires use of c++98 compiler. after writing program , trying compile error: error: invalid use of non-static data member 'graph::adj_list' this confusing me since used cppreference ( http://en.cppreference.com/w/cpp/language/data_members ) make sure compile. can me out? graph_frame.h #include <cstddef> class node{ friend class graph; private: int node_name; int edge_weight; node *next_cell = null; node *previous_cell = null; public: node(int name = 0, int new_edge = 0); ~node(); }; class graph{ private: void recursive_delete(int i, int k); node** adj_list; <----------------error public: //----argument not needed constructor because list not created //----until create_graph() called graph(); ~graph(); //----remember free buckets list void create_graph(int& graph_nodes); int check_node(int& source_node, int& dest

c++ - Correctly using an accessor in tbb -

i have list of items insert tbb's concurrent hash map. what's correct way of using accessor, way 1 or 2? // way 1 (a list of (keys,values)) { map::accessor a; myhashtable.insert(a, key); (a->second).push_back(value); a.realease(); } // way 2 map::accessor a; (a list of (keys,values)) { myhashtable.insert(a, key); (a->second).push_back(value); a.realease(); } basically either, since explicitly call accessor::release() . generally, code quality point of view, i'd limit scope of locking minimal necessary region since code extended further in unexpected way or/and exception-safety issue. the third way without explicit release is: // way 3 (a list of (keys,values)) { map::accessor a; myhashtable.insert(a, key); (a->second).push_back(value); } p.s. try avoid using of accessor in serial code when possible, e.g. use insert(value_type) form. reduce overheads of thread-safety

Input / Output Java -

my program supposed write 100 random integers on text file , read them. problem i'm printing 1 integer. know i'm close. doing wrong? import java.util.random; public class writedata { public static void main(string[] args) throws exception { //create file instance java.io.file file = new java.io.file("random100.txt"); if (file.exists()) { system.out.println("file exists"); system.exit(0); } //create file java.io.printwriter output = new java.io.printwriter(file); //write formatted output file random randomgenerator = new random(); (int idx = 1; idx <= 100; ++idx) { int randomint = randomgenerator.nextint(100); output.print(randomgenerator); //log("generated : " + randomint); //close file output.close(); } } } import java.util.scanner; public class readdata {

javascript - Angular $http.post is reporting failure, even though technically its working -

i have following controller: function registerformctrl($scope, $http) { $scope.master = {}; $scope.response = {}; $scope.update = function(reguser) { reguser.contactinfo.name = "main"; reguser.contactinfo.phone = "333-333-3333"; reguser.contactinfo.address = "333 elm st indiana pa 15701"; reguser.contactinfo.email = "someemail@johnson.com"; reguser.name = "joe johnson"; reguser.username = "joe.johnson"; reguser.password1 = "abcdef123-"; reguser.password2 = "abcdef123-"; $scope.master = angular.copy(reguser); $http.post('http://imac.local:8080/api/register', reguser) .then( function(response) { console.log("success"); console.log(response); }, function(response) { console.log("fail"); console.log(response);

html5 - Creating a smooth swipe behavior using jQueryMobile which reveals a div -

Image
what im trying reveal content while sliding right/left. im basing behavior on simple event "on swipeleft" doesn't give me intended to. $("li").on("swipeleft",function(){ alert("you swiped left!"); }); i want while doing swipe, content of li move left , while happening fixed div revealed. hope suggest me right way doing because currentnly, alert i'm showing, appears after finish swipe , not while i'm doing it. you absolutely position hidden divs @ right , left, , on swipe animate left/right margins reveal divs: demo <li><div class="leftfixed">div</div><a href="#">acura</a><div class="rightfixed">div</div></li> the css: .leftfixed { position: absolute; top: 0; bottom: 0; left: 0; width: 60px; background-color: red; color: white; text-shadow: none; z-index: 1; display: none;

haskell - Syntax for importing methods of type classes -

i noticed ghc doesn't complain if import (or export) methods of type classes directly: import prelude (signum) as opposed using "constructor" syntax: import prelude (num(signum)) because of this, assumed former syntax ok , went it. however, ran odd issue frominteger , former syntax doesn't work -- ghc accept silently, complain later frominteger never exported in first place. did happen stumble upon unspecified behavior in language? here's minimal test case: -- a.hs module (frominteger) import prelude (frominteger) -- b.hs module b import prelude () import f = frominteger

javascript - Button for layers are always in active state, legend persists for 1st layer when 2 layers are added -

i have mapbox , tilemill layer problem: check out code here: http://bl.ocks.org/marishaf/3cc9bfbeb412c1120e93 layer buttons they're in "active" mode, although still load , unload layers. legends load each layer (legends exist public land , zoning layers), if load both , try remove both layers, legend persists first layer loaded. the legend persists tooltips. example, if load layer legend first (only happens if layers loaded in order) , layer tooltips (for example point source pollution) , mouse on point tooltip called , try remove layer legend, legend persists. remove "link.classname = 'active';" before onclick function. change "if (map.haslayer(layer))" statement more similar "else" 1 ("layer" instead of "thelayer" , 1 "classname" change). snippet: link.href = '#'; // remove line here link.innerhtml = name; link.onclick = function(e) { e.preventdefault(); e

JBoss seems to hang on startup at the command line -

i trying run jboss command prompt standalone.bat file. starts startup process sits there. couldn't find answers goolgle or on here. here output command line: c:\jboss-as-7.1.1.final\jboss-as-7.1.1.final\bin>standalone calling "c:\jboss-as-7.1.1.final\jboss-as-7.1.1.final\bin\standalone.conf.bat" =============================================================================== jboss bootstrap environment jboss_home: c:\jboss-as-7.1.1.final\jboss-as-7.1.1.final java: c:\program files\java\jre8\bin\java java_opts: -xx:+tieredcompilation -dprogram.name=standalone.bat -xms64m -xmx51 2m -xx:maxpermsize=256m -dsun.rmi.dgc.client.gcinterval=3600000 -dsun.rmi.dgc.se rver.gcinterval=3600000 -djava.net.preferipv4stack=true -dorg.jboss.resolver.war ning=true -djboss.modules.system.pkgs=org.jboss.byteman -djboss.server.default.c onfig=standalone.xml =============================================================================== java hotspot(tm) 64-bit server vm warnin

android - What could be the reason for the Soap Fault (faultcode: soapenv:Client, faultstring:Bad Request) -

Image
i writing client consume soap web service in android using ksoap2. , have received soap fault exception. here excerpt logcat. <soapenv:body><soapenv:fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soapenv:client</faultcode><faultstring>bad request</faultstring></soapenv:fault></soapenv:body></soapenv:envelope> 04-06 09:04:09.693: e/searchpublications(1159): soapfault - faultcode: 'soapenv:client' faultstring: 'bad request' faultactor: 'null' detail: null this how extracted values of final strings wsdl: namespace : value of attribute namespace of xsd:import element, child element of xsd:schema , child element of types soapaction : namespace appended method's name methodname : name of method in api url : actual url of wsdl (reference: this answer , link mentioned in it. ) i understand there wrong code, can might causing , if have set values of menti

javascript - How to separate two forms in a page -

i have 2 forms in page when click on 1 button other form runs , >>>two windows of same page<<< open. how can separate function of these 2 or more forms in page? the code below. form has same code different web addresses. <form method="post"> <input id="element 1_1" class="element radio1" name="element 1" type="radio" value="http://www.yahoo.com" /> model 13<br/> <br/> <input id="element 2_1" class="element radio1" name="element 1" type="radio" value="http://www.msn.com" /> model 17<br/><br/> <input id="element 3_1" class="element radio1" name="element 1" type="radio" value="http://www.ebay.com" /> model 22 <br/><br/> <script> $(function () { $("form").submit(function (e) { e.

c# - iterate through instances of a class inside itself -

(i didn't create this, must work this) class person{ public string name { get; private set; } public static person p1 = new person("name1"); public static person a1 = new person("aname1"); public static person zx1 = new person("namezx"); public static person p2 = new person("name2"); . . public static person p20 = new person("name20"); } i need iterate through of these instances, think involves reflection i'm not sure how to. @selman22, thanks, must loop through these persons forach(var p in persons) { } however p fieldinfo object, how change person (casting isn't working) you can fields using reflection this: var persons = typeof(person) .getfields(bindingflags.public | bindingflags.static) .where(x => x.name.startswith("p")); or: var persons = typeof(person) .getfields(bindingflags.public | bindingflags.sta

php - I can't install and run ApiGen -

i'm creating php micro-framework , decided use apigen generate api. when use "apigen" command on terminal, following message: sh.exe": apigen: command not found. maybe directory tree: project/ --libraries/ ----attw/ (micro-framework , directory document) ----apigen/ what can do? how can organize directory tree? , how can execute apigen correctly? haven't found tutorials that. as version 4.0, can download apigen phar , use pretty same way use composer. for more info, checkout apigen.org

Haxe macro - Passing parameters to a macro -

i've got ne problem macro : passing parameter function... i pass string function : macro public static function gettags(?type : string) but there's compilation error (received expr , expected string). so, according documentation, did : macro public static function gettags(?type : haxe.macro.expr.exprof<string>) {} that's cool, question following : how access string value ? that's not easy use.. in fact, if trace type have : { expr => econst(cident(type)), pos => #pos(lib/wx/core/container/servicecontainer.hx:87: characters 36-40) } i think have switch on type.expr, const contains variable name, not value.. how can access value ? , there easier way value (without switch example). i think because call function not in macro, , think thing want not possible, prefer ask :) thank you as have mentioned, use variable capture in pattern matching : class test { macro public static function gettags(?type : haxe.macro.expr.exprof<

javascript - onMouseOver requires click before becoming active -

i have problem onmouseover event on div. have searched forums , tried apply of solutions proposed here similar events, have not found working yet. simple, cannot figure out myself; searching in wrong direction. has tips? function toggleheight (e, maxheight) { e = document.getelementbyid("small"); if(e.style.height != '1.2em') { e.style.height = '1.2em'; } else { e.style.height = maxheight + 'px'; } } html <a href="#!" onmouseover="toggleheight(this,180); return false" style="display:block;">menu</a> i dont know method , have done many mistake here code of want mean want change height of div , why have written a tag when have mentioned div tag before... here code. go ahead , copy code , paste in code editor... , working, tested this... <html> <style type="text/css"> #link{ background-color: lime; width:20

sql - How to perform count in access across three tables? -

i having 3 tables, sake of simplicity let's category (1...many) topic (1...many) post what trying achieve categoryid , total number of topics in category total number of posts. the best result made using following query: select category.id, count(topic.id) topiccount, count(post.id) postcount ((category) left join topic on topic.categoryid = category.id) left join post on post.topicid = topic.id group category.id unfortunately, if have 6 topics in table associated category getting '7' result. did research on , seems have use distinct keyword inside count access not support , not find appropriate way in subqueries. thank help! you 1 more record, because not counting topics, counting topic-post joined records. use following : select category.id, count(topic.id), nz(sum(numofposts),0) (category left join ( select topic.id, count(post.id) numofposts, topic.categoryid topic left join post on topic.id = post.topicid group topic.id, topic.

java - Yet Another ApplicationContext is Null -

i'm having trouble autowiring spring bean in application. i've done before in other applications success, reason i'm getting stumped. i've googled around, , have found many folks having same troubles, , warnings go along using getapplicationcontext() approach no answers helped me. understand warnings , still have case want way, maybe i'll working using aspectj , compile time weaving. here setup: applicationcontext.xml <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="h

dojo - Bower does not download git submodule (DojoX candidate plugin) -

i using dojo, dijit, dojox in project, installed with: $ bower install dojo dijit dojox bower dijit#* cached git://github.com/dojo/dijit.git#1.9.3 bower dijit#* validate 1.9.3 against git://github.com/dojo/dijit.git#* bower dojo#* cached git://github.com/dojo/dojo.git#1.9.3 bower dojo#* validate 1.9.3 against git://github.com/dojo/dojo.git#* bower dojox#* cached git://github.com/dojo/dojox.git#1.9.3 bower dojox#* validate 1.9.3 against git://github.com/dojo/dojox.git#* everything fine until discover dojox.calendar missing. candidate plugin dojox , using dojox git repository (git cloned github) requires " git submodule update --init --recursive ". my options are: can bower download git submodule? or should download module separate dojox package via normal git clone , symlink dojox/calendar it? mean have maintain link every time bower updates dojox packages, rig

java - Method for checking Mode -

i have method here, checking mode (most frequent element) in array. although there twist need account , i'm not sure how go doing this. example: if array {1,2,2,3,3,5} .. need print out 'nan' , because 2 , 3 both occur 2 times. on how add appreciated. my code: public double mode() { double maxvalue=0, maxcount=0; boolean flag=false; (int = 0; < data.length; ++i) { double count = 0; (int j = 0; j < data.length; ++j) { if (data[j]==(data[i])) ++count; } if (count > maxcount) { if(count>1)flag = true; maxcount = count; maxvalue = data[i]; } } if(flag) { return maxvalue; } else return 0.0; } i suppose current code not giving out result wanted. here's code

python - django tutorial no module named staticfilespolls error -

i had done first part of tutorial, got stuck, realized there several versions of tutorial, deleted polls , mysite directories , started again. however, when run $ python manage.py sql polls result is: c:\python27\scripts\mysite>python manage.py sql polls traceback (most recent call last): file "manage.py", line 10, in <module> execute_from_command_line(sys.argv) file "c:\python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line utility.execute() file "c:\python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute self.fetch_command(subcommand).run_from_argv(self.argv) file "c:\python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv self.execute(*args, **options.__dict__) file "c:\python27\lib\site-packages\django\core\management\base.py", line 280, in execute translation.activate('

java - What happens if you push an item into a stack but the initial capacity has already been met? -

stack initial capacity: 5 object[0] = 'h' object[1] = 'a' object[2] = 'p' object[3] = 'p' object[4] = 'y' what happens if try these executions: s.push('i'); s.push('s'); also stack implementation using array have peek method? ps. don't have computer , i'm merely on phone asking this. reading book , came question... the initial capacity starting size of stack's internal array. once initial capacity met, implementations resize underlying array.

sql - Get results only with max change? -

i need return results have highest percentage of change. table looks like item price1 price2 1 2 b 3 5 c 2 3 i want return a, this: item price1 price2 percent_change 1 2 200% i tried select item, price1, price2, max(a.mprice) my_output (select item, ((price2-price1)/price1) * 100 mprice table) but says indetifier invalid (assuming that's a.mprice ). i've tried using having check max, didn't work, still return results. i feel i'm missing obvious can't think of is. i'm guessing using max(a.mprice) wouldn't max need, i'm not sure else do. your table a not have item , mprice fetching price1 , price2 in outer query not work. but can without such subquery select item, price1, price2, ((price2-price1)/price1)*100 growth products order growth desc limit 1; first, choose 3 attributes , calculate growth, order growth descending , t