Posts

Showing posts from February, 2015

jquery - Select specific radio buttons in all groups with no selected checkboxes -

i need to: get radio groups no option selected from groups inputs "data-correctanswer" is there better way of doing 1 have? (it's working) jsfiddle (need select a , h only ) html: <form class="multiform truefalse"> <ul> <li> <input data-correctanswer="correct" name="question1" type="radio"><span>a</span> </li> <li> <input name="question1" type="radio"><span>b</span> </li> </ul> <ul> <li> <input name="question2" type="radio" checked="checked"><span>c</span> </li> <li> <input data-correctanswer="correct" name="question2" type="radio"><span>d</span> </li> </ul>

java - Using a Dynamic path for a csv file -

i have program saves on file. current code set file save on specific path, when run program different computer program doesn't work , need change path everytime. public createcustomer() { initcomponents(); arraylist<string> considlist = new arraylist<string>(); string csvfiletoread = "e:\\ryan_assignment_sit2\\consid\\consid.csv"; // reads csv file. bufferedreader br = null; // creates buffer reader. string line = ""; string splitby = ","; // reader delimiter try { br = new bufferedreader(new filereader(csvfiletoread)); // buffer reader file name read. scanner reader = new scanner(system.in); while ((line = br.readline()) != null) { //while there line read. reader = new scanner(line); reader.usedelimiter(splitby); while (reader.hasnext()) { // while there next value (token). considlist.add(reader.next()); }

python - numpy nonzero() returns indexes sorted by row index? -

as in matlab, nonzeros return indexes ordered columns( http://www.mathworks.com/help/matlab/ref/nonzeros.html ). in numpy, seems returned indexes ordered rows (for 2d matrix). not articulated in doc ( http://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html ). safe assume that? an example: test = np.array([[0,2], [3,0]]) test[test.nonzero()] gives array([2, 3]) instead of array([3, 2]) there following comment on c source code of pyarray_nonzero , c function handles calls nonzero : /*numpy_api * nonzero * * todo: in numpy 2.0, should make iteration order parameter. */ npy_no_export pyobject * pyarray_nonzero(pyarrayobject *self) the iteration order is hardcoded c-order , i.e. last index varies fastest, i.e. sorted rows, columns, 2d case. given comment, safe assume that, if ever changes, providing new functionality defaults current behavior.

g++ - Is operator void*() conversion still part of C++ library? -

consider program: #include <iostream> int main() { delete std::cout; } afaik conversion function operator void* () const has been removed c++11. so, program should fail in compilation on c++11 compiler. ya, true both g++ 4.8.1 & 4.9.2 gives diagnosis (in form of warning deleting void* undefined & that's thing). shouldn't program fail in compilation because removal of conversion function due stream object implicitly converted void* in c++98 & c++03?. bug? seems bit surprising still not have implemented change. i've tried program in g++ 4.9.2(that supports c++14) gives warning not compiler error. ideone compiler gives me error expected. (see live demo here ) it has nothing compiler, library issue. libstdc++ has lots of incompatibilities c++11, of one. making breaking changes in 5 , though iirc. in short, it's neither bug nor compiler issue.

What is the equivalent of the following Python list comprehension in Fortran? -

i trying write following list comprehension(written in python) in fortran. lit = [[x,y] x in [p,q,r] y in [h,k,l] if [x,y]!=[a,b]] where a, b, p ,q ,r, h, k, l integers how can achieve if want fill columns first in 2d fortran array? the python code returns list. equivalent to for x in [p,q,r]: y in [h,k,l]: if [x,y]!=[a,b]: list.append([x,y]) i made 2 sublists in fortran. sublist_x , sublist_y each list contains p,q,r , h,k,l respectively. integer :: list(0:7), sublist_x(0:2),sublist_y(0:2), count count =-1 i=0,7 if (i%3 ==0) count = count +1 endif list(0,i)=sublist_x(i%3) list(1,i)=sublist_y(count%3) enddo i think complex way of doing things... if understand correctly want cartesian product of 2 little lists, excluding element [a,b] ? if misunderstand, stop reading now. here's little program want ... program test implicit none integer, dimension(:), allocatable :: listx, listy, bad_element i

How to iterate over this Json data in rails? -

i'm trying iterate on json data want items out of "data tried doing @response =httparty.get(("http://ddragon.leagueoflegends.com/cdn/5.15.1/data/en_us/item.json")) puts @response["data"].each |item| puts item end also want able iterate them without having know ids prior example first item "1001" don't want have enter manually but says can't find '[]' nil:nilclass before mentions json below doesn't finish because took sample there lot more items , if paste , on 1000 lines. "type":"item", "version":"5.15.1", "basic":{}, "data":{ "1001":{ "name":"boots of speed", "group":"bootsnormal", "description":"<grouplimit>limited 1.</grouplimit><br><br> <unique>unique pa

c++ - Using += operator with float values -

i'm trying implement operator function solve next error : error: assignment of member 'animal::weight' in read-only object weight +=amount*(0.02f); my animal.cpp function looks like: void animal::feed(float amount) const { if (type == "sheep"){ amount=amount*(0.02f); weight+=amount; }else if (type == "cow"){ weight +=amount*(0.05f); }else if (type == "pig"){ weight +=amount*(0.1f); } return weight; } animal.h (short version): class animal { public: animal(std::string atype, const char *ansex, float aweight, qdatetime birthday); float getweight() const {return weight;}; void setweight(float value) {weight = value;}; float feed(float amount) const; void feedanimal(float amount); private: float weight; }; float operator+=(const float &weight,const float &amount); then implemented += operator. float operat

Android: Listen for notification update -

is there way listen if notification updated. example if receive message in messenger notification listener notice that, once receive second message - notification listener ignores that. i have tried cancelling notifications, did not work my notification listener: public class reader extends notificationlistenerservice{ @override public void onnotificationposted(statusbarnotification sbn) { string pack = sbn.getpackagename(); int id = sbn.getid(); string ticker = sbn.getnotification().tickertext.tostring(); bundle extras = sbn.getnotification().extras; final string title = extras.getstring("android.title"); string tag = sbn.gettag(); int ides = extras.getint("android.id"); final string ss = extras.getstring("android.text").tostring(); final string text = ss.tolowercase(); if (pack.equals(

java - How to execute tasks in ExecutorService sequentially? -

i have 3 threads joined, i.e. second thread executes after first dies. this code have: public class main { public static void main(string args[]) throws exception { final thread thrda = new thread(() -> system.out.println("message 1")); final thread thrdb = new thread(() -> system.out.println("message 2")); final thread thrdc = new thread(() -> system.out.println("message 3")); thrda.start(); thrda.join(); thrdb.start(); thrdb.join(); thrdc.start(); thrdc.join(); } } how implement functionality using executorservice instead of 3 thread objects? if want/need execute group of jobs 1 after in single thread different main app thread, use executors#newsinglethreadexecutor . executorservice es = executors.newsinglethreadexecutor(); es.submit(() -> system.out.println("message 1")); es.submit(() -> system.out.println("message 2"

ios - Parse - Swift : Concatenate Queries -

i'm creating ios app swift , parse.com. unfortunately, i've problem when build query. what want : have class sport's players (with goals , passes). retrieve player goals , player passes. have 2 columns in parse class : goals , passes. so, me, use query_goals.limit = 1 query_goals.orderbydescending("goals") query_passes.limit = 1 query_passes.orderbydescending("passes") and need concat 2 queries didn't find in swift ios documentation... does have idea please ? :) edit : want print best scorer , passer in collectionview cells : override func queryforcollection() -> pfquery { let query = pfquery(classname: "liste_joueurs") query.limit = 1 query.orderbydescending("goals") let query_passes = pfquery(classname: "liste_joueurs") query_passes.limit = 1 query.orderbydescending("passes") let final_query = query + query_passes //swift concat illustrate purpose ret

python - From where comes the parent argument (PySide)? -

in example, comes parent argument, provides it? class mainwindow(qtgui.qmainwindow): def __init__(self): super(mainwindow, self).__init__() self.do_something() #sanity check self.cw = childwidget(self) self.setcentralwidget(self.cw) self.show() def do_something(self): print 'doing something!' class childwidget(qtgui.qwidget): def __init__(self, parent): super(childwidget, self).__init__(parent) self.button1 = qtgui.qpushbutton() self.button1.clicked.connect(self.do_something_else) self.button2 = qtgui.qpushbutton() self.button2.clicked.connect(self.parent().do_something) self.layout = qtgui.qvboxlayout() self.layout.addwidget(self.button1) self.layout.addwidget(self.button2) self.setlayout(self.layout) self.show() def do_something_else(self): print 'doing else!' parent , children specific qt (c++)

many to many - Rails 4 - association not working correctly -

i created 2 models using rails generator this: $ bin/rails g model manager name:string and $ bin/rails g model blog/post title:string manager:references with that, have 2 models files: # app/models/manager.rb class manager < activerecord::base has_many :blog_posts end and # app/models/blog/post.rb class blog::post < activerecord::base belongs_to :manager end going rails console can create manager , post this: $ manager1 = manager.new $ manager1.name = "john doe" $ manager1.save $ post1 = blog::post.new $ post1.title = "hello world" $ post1.manager = manager1 $ post1.save and on console, if do: $ post1.manager.name that works perfectly. returning manager's name. if do: $ manager1.blog_posts i expected list of manager's posts. getting error: nameerror: uninitialized constant manager::blogpost the same happing when try many-to-relationship between "blog:category (ap

wordpress - How to redirect site to 403 if a certain url get variable exists or contains an unwanted value using htaccess -

in site statistics, i'm staring strange urls these: mysite.com/?p=casino-online-spielen mysite.com/category/page/2/?p=casino-online-spielen i've tried rewrites has messed wordpress rewrites or didn't work. not in htaccess or apache. <ifmodule mod_alias.c> redirectmatch 403 ?p=(casino|pharmacy) </ifmodule> what need htaccess rule sends user 403 error if word casino found, or better yet if ?p= found in url, not supposed happen. fear destroy archive pagination. on other hand, should allows ?s= variables , whatever in it. essentially follow @starkeen suggestion , use mod_rewrite eg. <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{query_string} p=(casino|pharmacy) rewriterule .* - [f,l] </ifmodule> note: f = forbidden = 403 l = last = doooooo it.

javascript - Show HTML Source Code via PHP or Java -

i'm trying should pretty simple. i have php form takes field entries , places them in html style table on output page. page has 0 styling since css , after output table, view source code in chrome , copy , paste email templates send out ranking tables in emails. now, have else doing same process using safari , not chrome. same can achieved rather trying explain process them, incorporate better solution. on same page display table (with view source code), there way display html source itself? eliminating need manually view source after page has been rendered? the exact code i'm using is: <?php echo" <!-- nightly ranking 7:00 pm --> "; echo " <table class=\"nightly_ranking\"> <tbody> <tr> <th class=\"table_center\" colspan=\"3\">".$_post['field_venue']." ".$_post['field_date']." 7:00 pm game</th> </tr> <tr> <td class=\"table_cen

javascript - Trying to use a Chrome Extension to fetch certain pieces of text from a webpage -

this first attempt @ building chrome extension , i'm trying learn how building extension tracks television series watch. extension supposed to, among other things, fetch metadata series , display on html page. whenever try fetch title of series using tag or class, etc. (determined using chrome's inspect element function) end "undefined". have tried using .innertext same happens. here javascript using: $(document).ready(function(){ document.getelementbyid("subscribe").addeventlistener("click",myfunction); function myfunction() { chrome.tabs.query({active: true, currentwindow: true}, function(tabs) { chrome.tabs.sendmessage(tabs[0].id, {subscribe: "yes"}, function(response) { var bkg = chrome.extension.getbackgroundpage(); bkg.console.log(response.confirm); bkg.console.log(response.atitle); \\i wrote check data fetched, gives undefined document.getelementbyid("antitle&q

javascript - jQuery File Upload: RailsCast for nested attributes and rails 4, file doesn't show, unless refreshed -

i'm following jquery file upload video railscast can't images show without refreshing page. my photo being uploaded through form: <%= simple_form_for @upload, html: { multipart: true, id: 'add_new_project_photos' } |f| %> <%= f.simple_fields_for :project_images, projectimage.new, child_index: projectimage.new.object_id |ff| %> <%= ff.file_field :photo, multiple: true, name: "project[project_images_attributes][][photo]" %> <% end %> <% end %> i created create.js.erb file. <% if @project.project_images.new_record? %> alert("failed upload painting: <%= j @painting.errors.full_messages.join', ').html_safe %>"); <% else %> $("#added_photos").append("<%= j render(@project) %>"); <% end %> my controller class projectscontroller < applicationcontroller #... other methods def create @project = project.new(trip_params) @uploa

linux - Perl - How to send local mail? -

i integrate following terminal command perl script. terminal command: mutt -s "user monitoring" -a "/home/mipa/documents/system_monitoring/protocol_name.csv" -- mipa@localhost.localdomain the command sends local mail containing file attachment user on same system. i have small problem command though. seem require more user interaction command listed here. command requires user follow menu confirm values , hit "y" key send. my question here two-folded. there similar mail command not require user interaction , works following single command predefined flags? , how integrate command perl script able choose file name, , receiving user followed issuing command? any guidance regarding possible solution highly appreciated. there few ways send command line emails in linux: how send file email attachment using linux command line? why -- in command? maybe confusing mutt . https://unix.stackexchange.com/questions/108916/automatically-

mysql - PHP/SQL array access error -

i'm trying make new column results sql query in php: $somearray= array(array('match'=>'123'), array('match'=>'456'), array('match'=>'789')); //arbitrary number of elements foreach($somearray $key=>$item){ $somearraysdouble[]=$item; } $somequery="select count(*) somecount sometable"; $probe1=array(); $probe2="0"; $probe3="0"; $probe4="0"; $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "mydb";//mydb uses mysql $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } foreach($somearray $key=>$item) { $somequery.=" somecolumn "%$item['match']%"; $blahblah=$conn->query($somequery); if ($blahblah->num_rows > 0) { while($row = $result->fetch

c++ - Visual Studio 2010 win32 compiled application does not work on windows xp -

i'm working on project should run on windows platforms. written in c++, using windows api. when compile in visual studio 6 on windows xp, can run on windows xp. when run in visual studio 2010 , run on windows xp did not work. did install vcredist2010_x86 , vcredist2010sp1_x86 , .net versions 3.5 , 4.0 on windows xp sp3. still doesn't work. added following preprocessor symbols project: #define _win32_winnt 0x0501 #define winver 0x0501 #define ntddi_version 0x0501 but still doesn't work. vs 2010 platform toolset v100 . question : need compile application using visual studio 2010, can executed on windows xp? i'm using vs2010_sp1 on window_7_sp1_x64 , 'release' mode. added #define previous include section. , i've tested ntddi_version 0x05010300 problem still alived! error, showed win_xp is: "program.exe has encountered ploblem , needs close." @ all, think, program needs dll or install on windows xp run correctly!

CS50, vigenere.c lack of argv -

i tried check50, , got message command down below. #include<cs50.h> #include<stdio.h> #include<ctype.h> #include<string.h> #include<stdlib.h> #include<math.h> int main(int argc, string argv[]) { string = argv[1]; int s = strlen(a); if(s == 0) { printf("no keyword entered\n"); return 1; } for(int k = 0; k < s; k++) { if(!isalpha(a[k])) { printf("keyword not alphabetical\n"); return 1; } } string t = getstring(); int = 0; int x = 0; int v = 65; for(int n = strlen(t); < n; ++) { if(isalpha(t[i])) { if(isupper(t[i])) { if(isupper(t[i])) { if(islower(a[x])) { v = v + 32; } int p = a[x]; p = p -v; int 1 =t[i]; 1 = 1 - 65; int b = (1+ p[s%x]%26;

java - Play Framework 2.4.x - Subprojects with database -

heys guys, i hope can me subprojects in play framework 2.4.x. i'm developing play project (i call root) subproject. both have ebean models , want save these models in different databases. tried many possibilies i'm not able work out. defining database , ebean configuration in [root]/conf/application.conf , other 1 in [root]/modules/sub/conf/application.conf (with different database names). error "creationexception: unable create injector, see following errors: 1) error injecting constructor, java.lang.illegalstateexception: bean class models.rootmodel not enhanced?" defining 1 database , ebean configuration in root's configuration , 1 in subproject's configuration same database name. error "persistenceexception: subproject.models.submodel not entity bean registered server?" defining both databases , ebean configuration in root project , define database subproject in configuration, same error in 1. no configuration in subproject, error: &q

c# - Relations efficiency mongodb relational-storage patterns, when to embed? -

just moved traditional sql server mongodb , trying figure out relational storage pattern should using, or when use embed documents? i point out not discussion if should use relational sql database or nosql database, several reasons nosql suits needs of project more sql databases. reason asking lot of advice people receive points in direction of using mongodb how on traditional sql server, , wondering if advice should follow or if lot of people stuck in mind-set of how traditional sql servers function. application writing uses lot of one-to-many , many-to-many relations (however each entity may have limited amount of child entities), , more lookups have 1 entity , want find relational counterpart, in traditional sql world 2 or tree different tables, in mongodb embedded documents can 1 or 2 collections. (i not saying not possible achieve on traditional sql servers) since working mongodb rather sql server, i'll show example of account system use. way "master account&q

unix - Command to retrieve all informations from a website -

is there unix command retrieve informations possible website? i mean info like: ip, ip geo location, (sub-)domains, alternative domain names, name server, , other informations i'm thinking about. i know whois , there else? gives more informations? thanks i don't know command can of @ once simple pipeline should work too. ping www.website.com ip curl ipinfo.io/ip-adress geo-location nslookup -query=soa www.website.com original dns alternatively can use command dig find subdomains via dns: dig domain.com output in authority section dns servers used dig @dns.server domain.com afxr retrieve subdomains of domain.com

.net - How to Convert LINQ Comprehension Query Syntax to Method Syntax using Lambda -

Image
is there tool, process or solution convert following linq query syntax method syntax lambdas (dot notation)? expect solution convert following query syntax method syntax such this. var filteredemployees = employee in allemployees employee.departmentid < 4 && employee.employeeid < 10 orderby employee.departmentid descending, employee.lastname descending select employee; to following var filteredemployees2 = allemployees.where(employee => ((employee.departmentid < 4) && (employee.employeeid < 10))) .orderbydescending(employee => employee.departmentid) .thenbydescending(employee => employee.lastname); i'm use learn method syntax better. linqpad tool need. "stole" following screenshot website better illustrate how works. if write query using linq syntax can click on button highlighted in red see equivalent lambda syntax:

ios - Swift can't retrieve images from parse.com -

Image
i using 6.4 of xcode , working fine when updated xcode 7 seems query isn't working photos. i'm getting username on table view images not showing error when testing on simulator iphone 5: app transport security has blocked cleartext http (http://) resource load since insecure. temporary exceptions can configured via app's info.plist file. and when test on iphone 6 got error : fatal error: unexpectedly found nil while unwrapping optional value (lldb) and showing me red thread on line : query.wherekey("user", equalto: pfuser.currentuser()!.username!) apple forcing dev use ats(https), can disable in info.plist adding this <key>nsapptransportsecurity</key> <dict> <key>nsallowsarbitraryloads</key><true/> </dict> should visit apple docs more details ats , please watch wwdc video session your second issue explain below fpuser.currentuser can return nil

python - _csv.reader' object is not subscriptable -

i have problem csv module in python. this code i've written parse csv def parse(data): data_delim = data.split("\n") data_list = csv.reader(data_delim) return data_list the problem encountering following: print(data_list[enum.check_name(skill)][1]) throws error _csv.reader' object not subscriptable i have ghetto solution below, i'd rather use similar code above, have solution this? i = 0 in data_list: if == enum.check_name(skill): print(a[1]) += 1 as error message says, csv readers don't support indexing. value returned csv.reader not list; it's iterator on rows. if want, make list of rows data_list = list(csv.reader(data_delim)) . can index list other.

python - Vagrant and bottlepy error on port -

i have vagrant file... # -*- mode: ruby -*- # vi: set ft=ruby : # config github settings github_username = "fideloper" github_repo = "vaprobash" github_branch = "1.4.0" github_url = "https://raw.githubusercontent.com/# {github_username}/#{github_repo}/#{github_branch}" # server configuration hostname = "m101p" server_ip = "192.168.0.127" server_cpus = "1" # cores server_memory = "384" # mb server_swap = "768" # options: false | int (mb) - guideline: between 1 or 2 times server_memory server_timezone = "utc" public_folder = "/vagrant" vagrant.configure("2") |config| # set server ubuntu 14.04 config.vm.box = "ubuntu/trusty64" config.vm.define "m101p" |vapro| end # create hostname, don't forget put `hosts` file # point server's defa

elasticsearch - Visualizing multiple searches in Kibana -

so have single index in elasticsearch want visualize kibana. want visualize field temperature want separate based on value in sensor_name . there way craft search query let me or not possible? set y-axis use temperature field, perhaps min/max/avg, etc. you'll typically set x-axis date histogram, show change in values on time. now, group these values sensor_name , you'll want aggregation, available in kibana4 under x-axis definition. select 'terms' , sensor_name field. should it!

Error when using import randint in python -

file "ex43.py", line 2, in random import randint importerror: cannot import name randint any suggestions randint error? tried reinstalling python, no luck. check random.py or random.pyc file(which override python random ) in current folder ex43.py resides.if there, delete or rename files.also check import by >>>import random >>>print(random.__file__) check importing packages

scala - Akka actor ask pattern does not work as expected -

actor b contains reference actor called senderr . actor ask s actor b, waits response , prints it. not receive response. why? must print number 4 @ console doesn't. class a(b: actorref) extends actor { private implicit val timeout = timeout(20 seconds) b ! 1 def receive = { case 2 => (b ? 3).map(println) } } class b extends actor { var senderr : actorref = null def receive = { case 1 => senderr = sender() sender ! 2 case 3 => senderr ! 4 } } object main extends app { val system = actorsystem("test") val b = system.actorof(props[b]) val = system.actorof(props(classof[a], b)) } ask creates temporary micro-actor single purpose of receiving 1 response of type any when b receives 3 sends 4 senderr refers a . a not have match 4 . in order (b ? 3).map(println) receive 4 , b has send sender() , @ time refers temporary actor set ask : case 3 => sender ! 4 alternatively, have case 4 i

php - getting id from POST request -

i'm watching tutorial i'm watching tutorials cms oop - php on control page : public function update() { if(isset($_post['updatearticle'])) { $id = (int)$_post['id']; //article data array //varaibles $title = $_post['title']; //title $content= $_post['content']; //content $cat = (int)$_post['cat']; //validation //data array $data = array( 'title' => $title, 'content' => $content, 'cid' => $cat ); //insert if($this->articlesmodel->update($id,$data)) { system::get('tpl')->assign('message','article updated'); system::get('tpl')->draw('success'); } else { system::get('tpl')->assign('message','error updating ar

php - htaccess "redirect loop" -

my site not loading properly. reason when put htaccess code mentioned below, site home page loads without style or image. , when delete .htaccess server site loads shows .html on url. here error get: err_too_many_redirects i can't seem figure out. i'm not htaccess guy :( would appreciate kind of help here htaccess code: addtype text/html .shtml .shtm .htm .html addhandler server-parsed .shtml .shtm .htm .html options indexes followsymlinks includes -line commented- uncomment version of php have on server -line commented- 1 of following can uncommented -line commented-addhandler application/x-httpd-php5 .shtml addhandler application/x-httpd-php52 .shtml -line commented-addhandler application/x-httpd-php54 .shtml -line commented-addhandler application/x-httpd-php56 .shtml -line commented-addhandler application/x-httpd-php4 .shtml rewriteoptions inherit rewriteengine on options +indexes -line commented- going ssl rewritecond %{server_port} 80 rewriterule ^(.

Javascript refresh triggered or intentional? -

if user clicks refresh or f5 or refreshes tab left click/reload intentional action! can hacker inject script maybe in image src (but not specific;) or anywhere else on page, forces reload/redirect? if so, there in onbeforeunload event tell me triggered code? wow window.onunload=function(e){console.dir(e);} location.reload(); event navigated https://www.google.com/webhp?hl=en proof kaii correct! wonder why browser venders don't make object of event - @ least check if refresh user intention??? can hacker inject script maybe in image src (but not specific;) or anywhere else on page, forces reload/redirect? yes, i.e.: <script>window.location = window.location;</script> if so, there in onbeforeunload event tell me triggered code? no. event object observable during onbeforeunload() not contain trace of information cause of unloading.

oop - Javascript child objects -

this question has answer here: how can split javascript application multiple files? 5 answers my javascript app getting big , want split on multiple files. have wrapped var myapp = function() { /*functions , variables here*/ } and want this, each child object in different file: var myapp = new function() { } myapp.childobject1 = new function() { this.func= function() { console.log('hello'); } } myapp.childobject2 = new function() { this.func= function() { console.log('world'); } } myapp.childobject1.func(); myapp.childobject2.func(); it works, i'm wondering if correct way it. thank answers. found article http://www.adequatelygood.com/javascript-module-pattern-in-depth.html helpful. that should work fine. find pattern , go it. http://toddmotto.com/mastering-the-module-pattern/ one of firs

php - How do I make an internal redirect in Silex / Symfony? -

i have users getting auto-generated when login via social media. don't email want make when land on /whatever/page/after/login see screen that's "just enter email continue on!" i took @ http://silex.sensiolabs.org/doc/cookbook/sub_requests.html , i'm either misreading or thinking i'd need within silex\controllerproviderinterface . want behavior request. meanwhile if make providers extend one, i'm not sure of right way cut out of parent's connect without botching everything. i tried re-initializing similar answer here unable overwrite pathinfo in symfony 2 request . here code i'm working with: $app ->before(function (request $request) use ($app) { $token = $app['security']->gettoken(); $app['user'] = null; if ($token && !$app['security.trust_resolver']->isanonymous($token)) { $app['user'] = $token->getuser(); if (!$app['user']->isve

mysql - LEFT JOINs with multiple tables -

i have following tables: table users - primary key (user_id) +---------+----------+-----------+ | user_id | username | realname | +---------+----------+-----------+ | 1 | peterpan | peter pan | | 2 | bobfred | bod fred | | 3 | sallybe | sally | | 6 | petersep | peter sep | +---------+----------+-----------+ table users_groups - primary key (user_id, group_id) +---------+----------+ | user_id | group_id | +---------+----------+ | 1 | 1 | | 1 | 2 | | 2 | 1 | | 2 | 2 | | 3 | 6 | | 3 | 9 | | 6 | 6 | | 6 | 9 | +---------+----------+ table game - primary key (id) +----+-------+ | id | game | +----+-------+ | 1 | game1 | | 2 | game2 | | 6 | game6 | | 9 | game9 | +----+-------+ table groups - primary key(group_id) +----------+--------------+---------------+ | group_id | group_name | group_desc | +----------+--------------+---------------+ | 1

java - AngularJS and SparkJava. Never enter into .success() method and can't see server's response -

i'm starting out angularjs , client-server programming overall. have angularjs client , java server (made sparkjava framework). this snippet of controller's code: var urlshortener = angular.module('urlshortener', []); urlshortener.controller('shortenctrl', function($scope, $http){ $scope.longurl = ""; $scope.shortening = function(longurl){ $http.get("http://localhost:4567/shortening", {params:{longurl: longurl}}) .success(function(response){ alert("success"); }) .error(function(response){ alert("error"); }) } } ); ...and maven project's server code import static spark.spark.*; public class server { public static void main(string[] args) { get("/shortening", (request, response) -> { string longurl = request.queryparams("longurl"

qt - Passing a QObject to an Script function with QJSEngine? -

i'm trying call function in external script while passing qobject parameter. my qobject defined this: #ifndef insertvalues_h #define insertvalues_h #include <qobject> struct insertvaluedef { qstring name; qstring xmlcode; qstring value; bool key; bool insert; }; typedef insertvaluedef tinsertvaluedef; class insertvalues : public qobject { q_object public: explicit insertvalues(qobject *parent = 0); ~insertvalues(); void insertvalue(tinsertvaluedef value); int count(); void setitemname(int index, qstring name); void setitemxmlcode(int index, qstring xmlcode); void setitemvalue(int index, qstring value); void setitemiskey(int index, bool iskey); void setitemtoinsert(int index, bool toinsert); qstring itemname(int index); qstring itemxmlcode(int index); qstring itemvalue(int index); bool itemiskey(int index); bool itemtoinsert(int index); bool valueisnumber(int index); int getindexbycolum