FAQ Database Discussion Community


How to require .class parameter to be a certain class in Java?

java,class,generics,type-safety
For example, I want to do something like: public void foo(Class c){ doSomething(); } But I want the Class c parameter to be a class that has implemented a specific interface. Is there a way to enforce this at compile time?...

Laravel API + Yeoman Angular Generator

php,angularjs,api,laravel,yeoman-generator
I have a problem I can't figure out. I wrote the back-end admin section with Laravel and Blade and added API routes for the front-end (The Angular App). I am using the yeoman angular generator, then I build the front-end project and move all the folders in "dist" into Laravel's...

C# LVM_DELETEITEM from listview

c#,winapi,hook
So, I'm programming in C#, and I am trying to get a item id from the SysListView32, then send a LVM_DELETEITEM message to remove the item from the list view. My code: using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using Microsoft.Win32.SafeHandles; using System.Runtime.InteropServices; using System.Text; using System.ComponentModel;...

Mock up projects for portfolio [closed]

javascript,html,css
I'm currently searching for entry level web development employment and I created a website where I included my mock up projects so that potential employers can see it. However, I want to know if this is allowed? For example, I recreated a website with my own twist and it has...

In JavaScript and knockout.js, why can't I return a variable? Why must I return the variable as if it's a method?

javascript,variables,methods,knockout.js,return
Consider this snippet of code: function AppViewModel() { this.firstName = ko.observable(""); this.lastName = ko.observable(""); this.fullName = ko.computed(function() { return this.firstName() + " " + this.lastName() }, this); } ko.applyBindings(new AppViewModel()); For a while I couldn't figure out why the fullName variable wasn't working properly. But then I noticed that I...

PHP string operation - strip .jpg extension [duplicate]

php,joomla
This question already has an answer here: How to remove extension from string (only real extension!) 12 answers I have the following php: <?php $image_directory = JPATH_SITE . '/images/site/'; $images = JFolder::files($image_directory); foreach($images as $image) { echo '<li><img src="/images/site/'.$image.'"> <p class="slidecaption">'.$image.'</p></li>'; } ?> So $images ends up being 1980.jpg...

Django save history of get request

django,forms,post,get
im developing a django app in which people enter their ID and they get either their active customer or not. that has already been solved, what i want is to save everytime a person trys to enter their ID this is the view: def ingreso_cliente(request): query_string = '' found_entries =...

How can iterate throught a dictionary in a list in python

python,python-2.7
This is an output from traversing through different folders in a directory: r= [{'s.data': [22, 10, 21, 2, 3, 3, 4, 4, 4], 'd.data': [1, 5, 3,67,8,4, 9, 0, 2], 'q.data': [2, 3, 4, 5, 6, 3, 4, 2, 32], 't.data': [32, 21, 9, 2, 13, 5, 4, 9, 7],...

Bootstrap Modal not popping up

javascript,jquery,css,twitter-bootstrap
I'm really new to bootstrap and I am trying to add a popup using Modals. I added the code and the scripts, but when you click on the button its not popping up. I can tell something is coming up because the background fades a little but a popup is...

Simple C++ swap function

c++,arrays,pointers
Why is it that if I have a function like this, to swap two numbers, it doesn't work[swap], (I know I can do this by declaring pointers in the prototype, and then pass the address of the respective variables in main()), but works for array, without having to pass pointers...

Is possible define a pointer to a function which has “not” variable argument list e.g “bools”?

c++,arrays,pointers
I know that I can make in C++ pointer to a function with variable argument list: bool (*fun)(bool,...); but I'm looking for construction could make a pointer to any of below function: bool f(bool); bool f(bool, bool); bool f(bool, bool, bool); bool f(bool, bool, bool, bool); bool f(bool, bool, bool,...

Load directive after AJAX call

angularjs,angularjs-directive,angularjs-resource
I have build a directive for pagination that takes two arguments; the current page and the total number of pages. <pagination page="page" number-of-pages="numberOfPages"></pagination> The issue is that I will only know the value of numberOfPages after an AJAX call (through ng-resource). But my directive is already rendered before that the...

Update a variable every second in Python?

python,tkinter
I'm writing a VERY simple incremental game in Python (final product will almost certainly be less than 5000 lines), and I've come to a problem. So far, all the currency is added solely by clicking, but the next upgrade I'm adding is going to add a certain number to the...

Is it possible to run classic asp and webpages (webmatrix c#) on the same site?

c#,razor,asp-classic,webmatrix
I have a very old homepage made from classic asp that works like a charm, but we need to upload images easy and save them on the server. Previously we did this with a asp.net webforms page on the same server, which worked like a charm. But it's getting really...

Double instance variables in java

java
Why do double instance variables in java have a lower case d attached to them? Do they need to have this? Example: double area = 0d; double avgDailyTemp = 26d; etc......

Limit number of places in php [duplicate]

php
This question already has an answer here: PHP: show a number to 2 decimal places 11 answers i am wondering how to limit some numbers etc: This number: 90.909090909091 just to: 90.90 I am using math here, $var1share = $adamage / ($adamage + $ddamage) * 100; So, i want...

Why does Chrome debugger think closed local variable is undefined?

javascript,google-chrome,google-chrome-devtools
With this code: function baz() { var x = "foo"; function bar() { debugger; }; bar(); } baz(); I get this unexpected result: When I change the code: function baz() { var x = "foo"; function bar() { x; debugger; }; bar(); } I get the expected result: Also, if...

Node.js + Express + socket.io - socket.io not serving properly

javascript,node.js,sockets,express,socket.io
I know this is a very discussed topic, yet I still can't seem to make it work exploring every solution on the internet. My app.js code looks like this: var express = require('express'); var io = require('socket.io'); var app = express(); app.use(express.static(__dirname + '/public')); // view engine setup app.set('views', path.join(__dirname,...

What to pass to Method that Checks if Key is Pressed?

c#,winforms,keypress
Okay so I created a method called KeyCheck(), that should check if a key is pressed (specifically the enter key) and if it is it will press button1. Unfortunately when I call the method I am unsure what to pass along to it. I want it to know when the...

Strings- taking out a letter at the start of each string in a list

python,string,list,loops,call
I am new to coding and am doing a computer science class. I have enjoyed it so far. the following Question has stumped me: An acronym is a string of capital letters formed by taking the first letters from a phrase. For example, SADD is an acronym for “students against...

How to refresh the task in a retained TaskFragment

android,android-fragments,android-asynctask,android-task
I have used a Fragment to perform the background update of the app avoiding interruption if the activity is destroyed or paused. Following this sample the update task start in if (mTaskFragment == null) { mTaskFragment = new TaskFragment(); fm.beginTransaction().add(mTaskFragment, TAG_TASK_FRAGMENT).commit(); } and works fine. My problem is that I...

Assignment operator linked list c++

c++,linked-list,overloading,assignment-operator
I am attempting to code an assignment operator for a linked list class in c++. The errors I'm getting say that "head" is undeclared, but I'm not sure where I'm supposed to declare it. It's being used in other functions without a problem. Another error says my use of "this"...

Date function isn't working as expected

javascript,html
I'm trying to insert the current year into a copyright statement and it's not working - likely because of something really basic. Any help? Thanks. :) ps If there are any other stylistic issues, I welcome all comments. $(document).ready(function () { // Veterinary Calculator Code // define variables for body...

PHP SEARCH and then INSERT

php,mysql,arrays,search,insert
I'm a relative novice when it comes to PHP and after doing some searching I can't seem to find an answer to my question. What I have is pretty basic, two tables 'person' and 'case'. I'm able to insert and search for a person (albeit it took me sometime to...

Symbol#to_proc with custom methods

ruby
I like how in Ruby you can pass methods as blocks like so using Symbol#to_proc: [1.0, 2.0, 3.0].map(&:to_i) #=> [1, 2, 3] I can also define my own lambda, times_two, and pass it as a block as well: times_two = ->(x) {x * 2} [1, 2, 3].map(&times_two) #=> [2, 4,...

C Memory management with int pointer (array)?

c,pointers,memory,malloc,free
Simple question, but the other similar questions on here are don't deal with this specific case, or so i could find. int * moves; moves = malloc(540); //540 is the most i will ever need, usually less someFunctionThatFillsSomeOfThoseSlots // also returns how many slots were used int * final =...

Cant get the view to show up on the TeamStudio Unplugged app

xpages,teamstudio-unplugged
I have tried putting the view into a custom control and then putting the custom control in the UnpMain.xsp, and I have tried putting it directly into the UnpMain.xsp, neither of these works. I can get other components to show, such as text fields, check-boxes, labels, and so on but...

Performing a sort using k1,1 only

linux,sorting,text,ascii
Assume you have an unsorted file with the following content: identifier,count=Number identifier, extra information identifier, extra information ... I want to sort this file so that for each id, write the line with the count first and then the lines with extra info. I can only use the sort unix...

perl: trouble testing numeric user input against array elements

arrays,perl,input,user
I'm a Perl beginner and I'm making a simple fortune teller program for a class. I wanted to start by having the user choose between four numbers, like on a paper fortune teller (cootie catcher, as it were). I created an array, @number_choices = ( 1, 2, 3, 4 );...

How to open a new activity without keeping opened the last one?

android
I'm doing a videogame. I wanted the application to have 3 screens. The presentation screen, the play screen, and the end screen. I know that an activity can be started with an intent, but my problem is that in doing so, the last activity would be stacked, allowing the user...

trying to disassemble

assembly,reverse-engineering,x86-64,att
The assignment is to interpret some assembly code to find a phrase that will run without calling "explode bomb". I'm using gdb to disassemble the current phase. I'm stuck and any advice on whether I'm moving in the right direction would be very appreciated. 0x0000000000400fb5 <+0>: sub $0x18,%rsp 0x0000000000400fb9 <+4>:...

clone() method in ArrayList, why Arrays.copyOf()?

java,arraylist,clone
I try to get my head straight about cloning in Java with my own ArrayList. For what I see this code @Override public Object clone() { try { MyArrayList<E> v = (MyArrayList<E>) super.clone(); v.elementData = Arrays.copyOf(elementData, size); return v; } catch (CloneNotSupportedException e) { throw new InternalError(); } } Gives...

mysql get result of most frequent value of every post

php,mysql,wordpress
I found some similar questions with good answers but i couldnt figure out how to apply this to my specific case. I have a site where users can rate there favorite post from 1-6. Every number is a different category. Now i need to know the most frequently votes for...

Twitter OAuth Swift OS X

cocoa,swift
I'm trying to integrate Twitter OAuth into my OS X app with Swift. I am getting a request token from the Twitter API and then using the app's protocol as the callbackURL appname://oauth. I have seen a tutorial for iOS that uses something like this and then passes the request...

Error when installing rpy2 module in Python with easy_install

python,r,rpy2
I've been trying to install the rpy2 module so I can use R functions inside my Python script, but I'm getting an error after following the advice from these pages: 1) Tried to guess R's HOME but no R command in the PATH. OsX 10.6 2) http://rpy.sourceforge.net/rpy2/doc-dev/html/overview.html What I've done...

jquery toggle only first target

jquery,html,css,wordpress
I created a toggle for an image display an about me section below it. I used targets to trigger the appropriate section. The code works fine on http://codepen.io/CookieFresh89/pen/OPOvXK. However when I put this on my Wordpress website, all of the images target the first id="div1". HTML <img class="showSingle" target="1" src="http://sogomarketingagency.com/wp-content/uploads/about-me-holder.jpg">...

Is ToTitleCase supposed to capitalize letters after the apostrophe?

vb.net,asp.net-mvc-5,extension-methods
I have searched but not found an answer. I have this as an extension method: <Extension()> _ Public Function ChangeCase(ByVal source As String) As String Return New System.Globalization.CultureInfo("en-US").TextInfo.ToTitleCase(source) End Function But it is capitalizing the letter after the apostrophe. Is it supposed to do that? For example I'll becomes I'Ll....

How can I automatically derive Typeable instance for DataKinds derived types?

haskell,types,deriving,data-kinds
I had some types like this: data Currency = USD | EUR deriving (Show, Typeable) data Money :: Currency -> * where Money :: Int -> Money c deriving (Show, Typeable) And I wanted to use typeOf with them in this function: findRate :: Money a -> Rates -> Maybe...

cannot get this adb shell am start line to work

android,adb
I am trying to launch this app on my emulator.. Here is my adb shell am start line C:\Users\harvey\AndroidStudioProjects\Sunshinea1>adb shell am start -n com.example.harvey.Sunshinea1app/com.example.harvey.Sunshinea1app.MainActivity WARNING: linker: libdvm.so has text relocations. This is wasting memory and is a security risk. Please fix. Starting: Intent { cmp=com.example.harvey.Sunshinea1app/.MainActivity } Error type 3 Error:...

How to create a class which will periodically update its variables based on the file content

python,python-2.7,flask
I am experimenting with writing a small REST API with Flask. Since I do not want to introduce a database at the moment, I plan to store all information required by clients in memory. Right now a cron job collects data from the web, analyses it and writes the results...

I'm making an API in PHP, but it cannot combine two variables [closed]

php,api,email,sms,phone
I am attempting to make an API for an SMS messager in PHP. Everything works and checks out except one thing. It gets the &carrier and the &number but PHP cannot appear to combine them. Any suggestions? I've attempted debugging it. The URL is: https://www.swiftresolver.com/sms/[email protected]&from=faded&message=hi&subject=hi&amount=3&carrier=ATT My whole code: <br> <br>...

Does php internal server read .htaccess configuration?

php,.htaccess,mod-rewrite,url-rewriting
I have a .htaccess with some rewrite rules: RewriteRule ^([a-zA-Z]+)\.page$ index.php?module=$1 [L] When I launch php server with php -S 127.0.0.1:80 in current dir, http://127.0.0.1/home.page page is not found on my server. So I can understand that php internal server does not read RewriteRule's at least. Is it true or...

2 values for a single input box and storing the 2nd value in php

javascript,php,jquery,html,mysql
I am using two values for 1 input box, when user selects multiple boxes the values will be submitted to submit_checkbox.php. I want to save the 2nd value i.e value after "|" sign in the php form. How can I do it ? My code is as follows :- <form...

why does java complain about a class that is not used?

java
I compiled successfully my program but got a undefined class error when trying to run it. The weird thing is I don't use the cern/colt/matrix/DoubleMatrix1D class in myprogram (I verified this with "grep"). Can someone please point me in the right direction? Thanks $ javac -cp $(find ../resources/ -name "*.jar"|tr...

Regarding C# Syntax with : and proceeding arguments in class declaration. Online converters failing to convert

c#,.net,vb.net
I'm running through a tutorial on WCF. Unfortunately, most all tutorials regarding WCF are in C# and I'm not too familiar with C# syntax; most all of my experience is in VB. I've gotten through it so far, but I ran into a bit of a snag. I think that...

How do I load an HTML file over HTTP into a string for use in JavaScript?

javascript,jquery,html
I would like to access an HTML file (makemeastring.html) from JavaScript as a String. jQuery's .load does not seem to work.

Ansible custom nested looping

loops,nested,ansible
I have to process output from CloudFormation Outputs that is: Ansible code that produces this output: - debug: var: stack.stack_outputs Output: ok: [localhost] => { "stack.stack_outputs": { "Roles": "webserver balancer dbserver", "dbserver": "54.0.1.1 54.0.1.2", "balancer": "54.0.2.3", "webserver": "54.0.2.5 54.0.2.7 54.0.3.1" }} With that, I want to create 3 (dynamic number!)...

Hibernate Use of @OneToMany or @ManyToMany targeting an unmapped class where the collection is pointing to a super class that doesn't have a table

java,hibernate,jpa,inheritance
I am having this error: sesion.org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: entities.Elaborado.componentes[entities.Producto] This is the super class: package entities; import javax.persistence.*; @MappedSuperclass @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) public abstract class Producto { @Id protected Integer numero; protected String descripcion; public Integer getNumero() { return numero; } public void setNumero(Integer numero)...

Query for Objects with Pointer Array in Parse

objective-c,swift,parse.com
I have an array of [PFObjects] called restaurantsArray. Within Parse, there is a Class: FoodPhotos with pointers to RestaurantName (the objects in restaurantsArray) How can I query for all objects within FoodPhotos that contain the pointer to an object in restaurantsArray. Class "FoodPhotos": Basically I want to grab all...

Creating an HTML editor component with ReactJS

reactjs
New to React, please point out if I've headed down the wrong track: I'm trying to build an HTML editor component, which so far looks like this: var CopyEditor = React.createClass({ render: function(){ var pageBody = "<p>My HTML string ..."; return ( <form id="editForm" method="POST"> <textarea id="editor" name="body" value=pageBody />...

Qt Ui access without source file

qt
Can I use the Qt design Form without class as kind of QMessageBox in the other source file? I have a class with source file, and a ui file without source file. In Ui namespace, I can only add header files, and not ui elements. I need to add many...

regex not being called repeatedly for multiple matches (isn't global)

javascript,regex
I have this regex /@[a-zA-Z0-9_]+$/g to do a global look up of all user names that are mentioned. Here is some sample code. var userRegex = /@[a-zA-Z0-9_]+$/g; var text = "This is some sample text @Stuff @Stuff2 @Stuff3"; text.replace(userRegex, function(match, text, urlId) { console.log(match); }); So basically that console.log only...

BAD ACCESS after block within a block is called (iOS)

ios,firebase,objective-c-blocks,exc-bad-access
I have a block where I am checking a user's status property from firebase. If the status property is 'free' I want to return from the block, otherwise I want to search for another user and check their status and do so until a 'free' user has been found: void(...

JTextArea with same parameters but not same size

java,jpanel,jtextarea
public UserInterface(){ super(new BorderLayout()); fc = new JFileChooser(); setComponents(); } public void setComponents(){ //top section openButton = new JButton("Charger fichier"); openButton.addActionListener(this); JPanel buttonPanel = new JPanel(); buttonPanel.add(openButton); //left section //class panel JPanel classe = new JPanel(); classes = new JTextArea(25,15); classes.setMargin(new Insets(5,5,5,5)); classes.setEditable(false); JScrollPane classeScrollPane = new JScrollPane(classes); classe.setBorder(new TitledBorder("Classes"));...

Android Equivalent to NSURLProtocol in iOS [duplicate]

android,ios
This question already has an answer here: What is Android's equivalent for NSURLProtocol from the iOS SDK? 1 answer I am using NSURLHttpProtocol in iOS to intercept the network calls and get information in regards to which url is processed, when request initiated or complete and so on. I...

My Inno Setup script creates two Desktop Icons

inno-setup
I am using the following lines to create icons: Name: "{group}\<PRODUCTNAME>"; Filename: "{app}\<PRODUCTEXENAME>" Name: "{group}\<PRODUCTNAME> (Log Mode)"; Filename: "{app}\<PRODUCTEXENAME>"; Parameters: "/log" Name: "{group}\{cm:ProgramOnTheWeb,<PRODUCTNAME>}"; Filename: "{app}\<PRODUCTNAME>.url" Name: "{group}\{cm:UninstallProgram,<PRODUCTNAME>}"; Filename: "{uninstallexe}" Name: "{userdesktop}\<PRODUCTNAME>"; Filename: "{app}\<PRODUCTEXENAME>"; Name:...

counting non-empty lines and sum of lengths of those lines in python

function,python-3.x,tuples,lambda
Am trying to create a function that takes a filename and it returns a 2-tuple with the number of the non-empty lines in that program, and the sum of the lengths of all those lines. Here is my current program: def code_metric(file): with open(file, 'r') as f: lines = len(list(filter(lambda...

Inquiry related to AlarmManager and WakeLocks

android,alarmmanager,wakelock,android-wake-lock,repeatingalarm
I am developing a native android app that run a backup operation every 30 mins. I am using AlarmManager for this purpose and it works fine. Here is the code I am using to start the alarm: public static void startSync(Context context) { alarmIntent = new Intent(context, AlarmReceiver.class); pendingIntent =...

std::cout statements evaluation order [duplicate]

c++,stack
This question already has an answer here: cout << order of call to functions it prints? 2 answers What is wrong with the pop() function why doesn't it work correctly? class stack{ int *p, *Cursor; int size ; public: stack(int sz) {Cursor = p = new int[size=sz+1];} //consider the...

How to manage the get-query parameters?

asp.net,asp.net-mvc
I have such view: @model MvcA.Models.SellsLiveSearch @using (Html.BeginForm("Search","Search",FormMethod.Get)) { @Html.ValidationSummary(true) <fieldset> <legend> parametrs</legend> <select id="HowManyRoom" name="HowManyRoom"><option></option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5>">4</option> </select> <select...

ONE SQL query to count records on different conditions

mysql
How can I count the total number of records, the number of unique of users and number of records on which the is status 2 from the table participants in one query? I know how to accomplish this using 3 separate queries: SELECT COUNT() FROM participants SELECT COUNT() FROM participants...

How many Mondays in a Month Visual Basic

visual-studio-2010,date
I'm trying to determine how many mondays there is between two dates. These dates will be inserted by a datetimepicker I know there are similar threads to this but they're all in PHP or VBScript. Any ideas?...

List limited items and search from full items in angularjs

angularjs
I am displaying a list of 5 items from 50 items.User able to search from entire list(from 50items) but not from only 5 items.How can I implement this on angluarJs. I am following this method because I want to reduce ajax requrest. angularJs code is, <div class="txt"> <a href="{{mall.link}}" ng-repeat="mall...

How to use a dynamically generated value in a template in AngularJS

angularjs,forms,templates,data-binding
I have a custom form application written in AngularJS and now I need to use the data from the form in a template. But nothing I've tried seems to work. I am creating a custom directive like this... .directive('dynamicModel', ['$compile', function ($compile) { return { 'link': function(scope, element, attrs) {...

How to forbid the inclusion of non-numbers?

c++,input
I have this program: #include <iostream> #include <string> using namespace std; int main() { int i=0; float reader, tot = 0; while(i!=10) { cout << "Insert a number: " << endl; cin >> reader; if(cin) { tot += reader; i++; } else { cout << "Error. Please retry." << endl;...

Finding paired events with reshape

r,reshape,reshape2
I have a list of users and items that have been bought by them at certain times, and I want to generate a list of those pairs from the raw data. While I can and probably will write a small python script to do it, I have the nagging feeling...

PHP passing a variable from HTML to another PHP file

php,html,mysql
Ok, so im making and admin page which requires to deletes entries from databases, and i cant figure out how to pass the id variable of the post to another php file. echo '<form method="post" action="delete_member_post.php" style="text-align:center;" id="delete_post">'; echo '<p style="text-align:center; font-size:20px;"> <font font-size:20px face="Rockwell" color="#680000"> Select post to delete:</font>';...

Android Fragment Translate Animation Not Working

android,android-fragments,android-animation
I'm trying to do a simple translate animation for two fragments. One comes in from the right while the other goes out to the left. My min SDK is 14. What happens is the transition takes place, but without the actual animation. After the time specified in the animation xml,...

redirect is causing HTTP Error 414 - The request URL is too long

jquery,ajax,coldfusion,coldfusion-11
I am using JQuery Ajax to post a form to a cfc. When an error occurs, such as a duplicate post being made, then the cfc checks this and does a simple redirect. Its like this: <cfif rsDuplicate.RecordCount GT 0> <cflocation url="/items/new" addtoken="no"> </cfif> When this error occurs, the redirect...

Copying transparent (32bit alpha) bitmap from TImageList in ComboBox DrawItem event

delphi,c++builder,alpha-transparency,c++builder-2010
I am customizing OnDrawItem event to draw icons next to item names. Here is my code so far for the event OnDrawItem: void __fastcall Form1::ComboBox1DrawItem(TWinControl *Control, int Index, TRect &Rect, TOwnerDrawState State) { TComboBox* CB = static_cast<TComboBox*>(Control); CB->Canvas->FillRect(Rect); boost::scoped_ptr<Graphics::TBitmap> bitmap(new Graphics::TBitmap()); bitmap->PixelFormat = pf32bit; bitmap->AlphaFormat = afPremultiplied; ImageList1->GetBitmap(Index, bitmap.get()); bitmap->AlphaFormat...

Mailchimp Custom Form CSS

html,css,wordpress,wordpress-plugin,mailchimp
I have created a MailChimp form for the footer of my website, I have modified the CSS with a bit of help to get it looking how it does now. I've become stuck now I attached two images the first one is how I want the form to look and...

sending array by ajax call in angular js

ajax,angularjs
I use the following code to send some information to my servlet to process data: $http({ method: "GET", url: "http://localhost:8080/purchase/AddInfo", data: { addArray : "sample" } }) .success(function (data, status, headers, config) { typesHash.push( {id:data.id,name : data.name, price : data.price,unit:2.5 }); }) .error(function (data, status, headers, config) { }); and...

Calculating difference in survival functions at time t in Stata

stata
I am estimating a Cox model in Stata using stcox. I estimate the model at stcox treat x1 x2 x3 I can then use the stcurve command to plot the survival function for treatment and control groups, with the x1, x2 and x3 variables set at their means by doing...

Android Studio onCreate setContentView

android,setcontentview
I started a blank project and modified the onCreate by adding the below but the button is not being created because I can not see it in the design view. What am I doing wrong, I expected to see the button with its text as indicated. Button b = new...

Array to string conversion PHP ERROR [closed]

php,sql,arrays
In my database SQL, I have messages flowing between user a and b. I want to echo out all the messages they have had. But I am getting the error "array to string conversion" at the moment. I tried to use implode but that didn't work too well. How can...

Updated With JsFiddle: Getting NaN on when I take the average function of an array

javascript,arrays
My array is declared like this var stocks = new Array(); I'm getting a list of numbers from google trends and turning it into an array. This is console.log('The stocks are ', stocks); The stocks are [47, 65, 81, 100, 86, 76, 57, 54, 80, 81, 92, 82, 81, 59,...

Is GenTraversableOnce[B] parent type of Array[File]?

scala,inheritance
Def of flatMap : def flatMap[B](f: (A) ⇒ GenTraversableOnce[B]): Array[B] To create a List of files within a dir : def recursiveListFiles(f: File): Array[File] = { val these = f.listFiles these ++ these.filter(_.isDirectory).flatMap(f => recursiveListFiles(f)) } flatMap accepts a function parameter which also accepts a parameter and returns type GenTraversableOnce[B]...

Properties files to control form inputs based on roles

jsf,jsf-2,resourcebundle,user-roles
The requirements of the application that I'm building demands that user roles are to be dynamic, they will be stored in the database, and they will also be mapped to functionalities (forms) of the application, also stored in the database. Restricting a role from accessing a specific page won't be...

Execute Applescript File from Python Script?

python-2.7,applescript,textmate2
I would really appreciate if someone could help me with this. I would like to make a function to execute an AppleScript file from within a Python script. The script I have so far is basically just a clock that calls the function to execute the file, and a button...

Does golang have a local date concept?

go
Does golang's time package (or any other library) support the concept of a local date? By local date, I'm referring to the concept supported by joda time, which is a date without a time or timezone.

Would drawing an image to a canvas be described as hotlinking if the image was from another site?

javascript,image,canvas,hotlinking
If you created an image object like so: var imageObj = new Image(); imageObj.src = urlOfImageOnAnotherWebsite; And then drew it to a canvas on my website like so: var canvas = document.getElementById('cnv'); var context = canvas.getContext('2d'); imageObj.onload = function() { context.drawImage(imageObj, 0, 0); drawText(statusquote,date); }; Would this be hotlinking the...

postgresql cidr find child blocks

postgresql,ip,cidr
I'm looking for a way to get direct children networks from cidr blocks stored in postgresql using the builtin cidr type. Example database CREATE TABLE nets ( id serial primary key, net cidr ); INSERT INTO nets (net) VALUES ('10.1.0.0/16'), ('10.1.0.0/20'), ('10.1.1.0/24'), ('10.1.1.8/29'), ('10.1.1.32/28'), ('10.2.15.0/24'), ('10.2.15.64/27') The desired query should...

Change the background color of an input element on focus

javascript,jquery,css
I would like to change the background colour of the text input (.item-input) when I press a tab key or via mouse - for some reason focus is not firing? For example: <tr class="item"> <td> <input class="item-input" type="text" /> </td> <td> <input class="option" type="text" /> </td> </tr> If .item-input is...

Reduce NSManagedObjectContect save time

ios,objective-c,database,core-data,nsmanagedobjectcontext
I am trying to make my algorithm faster as I am seeing long loading times. My app loads thousands of objects from an external database and then saves it on the device. I ran time profiler with my ipod touch and I saw that 17 seconds/26% of my loading time...

Trying to create an array of x and y values after reading file in Python

python,arrays,matplotlib
Initially I was simply using MatPlotLib to graph the points after I read them like this: with open("data1.txt") as f: samples = f.read() samples = samples.split('\n') x = [row.split(' ')[0] for row in samples] y = [row.split(' ')[1] for row in samples] fig = plt.figure() ax1 = fig.add_subplot(111) ax1.plot(x,y, 'ro')...

public class MyClass : IDisposable?

c#,.net
Q1) Should I make all my classes like this so that I can use using (...)? Ie, it this good practice? public void Dispose() { // in its simplest form } Q2) Other than code for specific objects I used that need closing, is there anything I should add to...

Java TCPSocket breaks after Client closes connection

java,tcp
I am very new to programming, especially to socket programming. I tried to figure out how communication works in real (not in all my books), but ran immediately into my first problem with the downloaded SimpleEchoServer example. Communicationflow works but when the Clientsocket closes his connection without sending a specific...

Using Grunt to preprocess and replace environment variables

angularjs,gruntjs
I have an angular app setup that's using grunt, but I'd like to be able to use grunt as a preprocessor to replace variables and I haven't been able to find anything that matches my needs. For instance, if I change the name of my main app module to "someAppName"...

What does the“wait_window” method do?

python,python-3.x,dialog,tkinter
It seems that the object that calls this method waits for the window passed as parameter to be destroyed before continue with its own loop... From the doc strings of the Misc class, we can observe: def wait_window(self, window=None): """Wait until a WIDGET is destroyed. If no parameter is given...

List of any `DataKind` in GADT

haskell,gadt,data-kinds
Disclaimer GADTs & DataKinds are unexplored territory for me, so some of the limitations and capabilities of them are unknown to me. The Question So I'm writing an AST for a JavaScript code emitter, and I've identified one edge case between expressions and that is that they can either be...

Software interrupts on AVR

posix,interrupt,system-calls,avr,syscall
I understand that x86 machine code can make POSIX system calls using software interrupts (by entering a 32-bit value corresponding to a kernel function into the EAX register of the processor and then executing INT 0x80). I'm looking into designing a small Unix-like operating system for the AVR architecture for...

Removing bin executable folder from GitHub

git,github
I accidentally pushed the bin folder of my Java program to GitHub, and now I wish to remove all those .class files. How can I do that?...

How to refresh only part of page using GAE

javascript,python,google-app-engine,web
I searched about this concept, but don't really understand how it works exactly. My backend is using webapp2 and GAE, and I want to refresh a page that pulls from my database. There's other content on the page, and I only need to refresh the table contents specifically. I currently...

Long running jQuery method - how to refresh dom? [duplicate]

javascript,jquery,performance
This question already has an answer here: refresh DOM after append element 4 answers UPDATE I think I have to be a little more precise. I have this long running code that adds content to my DIVs. This is an example of the code: m = jQuery('#test').clone(); //do some...

run external javascript within php file [closed]

javascript,php
I'm trying to run a function within a external JavaScript code but it doesn't seem to work/launch, I know for sure that exists is greater than 0 but i'm not sure if my implementation of javascript is even correct. Here's part of the code that's relevant $exists = mysqli_num_rows(mysqli_query($con,"SELECT *...

Get Text outside of tags as well

python,html,python-3.x,beautifulsoup,html-parsing
I'm trying to get some text out of a god-awful website. This is the part where I'm stumped: <tr><td valign="top"> <br> <b>AGFA&nbsp;ACCUSET,&nbsp;<i>1994</i></b>&nbsp;<font color=grey>(46965)</font><br> <br> <b>Equipements : </b><br>AGFA 9800<br> WITH RIP VIPER N°2<br> FILM PROCESSOR GLUNZ AND JENSEN ML35 n°26498<br> (LAIZE 450/600mm)<br> Spectraset 2200<br> <b>Availability :...

How to test DAO methods using Mockito?

java,unit-testing,junit,mockito,dao
I've started to discovered Mockito library and there is a question for which I didn't find the proper answer. If I have for example such method in my UserDAO class that saves user in database: public class UserDAO{ ... public void create(User user) { Connection connection = null; PreparedStatement pstmt...

WKWebView: trying to query javascript synchronously from the main thread

ios,ios8,grand-central-dispatch,semaphore,wkwebview
Is there any way to query the javascript synchronously from the main thread? Javascript is queried from the native code using an asynchronous function with a callback parameter to handle the response: func evaluateJavaScript(_ javaScriptString: String, completionHandler completionHandler: ((AnyObject!, NSError!) -> Void)?) Asynchronous behavior can usually be turned synchronous by...

How can I redirect a request to a subdomain to another subdomain on Route 53?

redirect,jekyll,github-pages,amazon-route53
I have a GitHub Pages Jekyll blog at blog.Antrikshy.com. I have been meaning to move it to code.Antrikshy.com for a while now. I made the new address a CNAME for antrikshy.github.io on Amazon and wired everything correctly to make it work. Now my blog.Antrikshy.com URL is broken. How can I...

BIOS interrupt _int86

c,interrupt,bios
I'm trying out some old code frome the book "Black art of 3d game programming". I know it is outdated but I started reading it and it's kind of fun and interesting. I downloaded the OpenWatcom C Compiler and made a new DOS Project in order to get this old...