FAQ Database Discussion Community


How to signal EOF to node.js stdin from console?

javascript,node.js
I have a simple node.js app to echo stdin. When I run it interactively on the Windows console, I expected control-Z to be recognised as an EOF signal. But it isn't. So how do I get a node app to treat control-Z as EOF? // testEcho.js process.stdin.setEncoding('utf-8'); console.log("input is a...

RegEx Pattern - Time Format

javascript,pattern-matching
I've a problem with a RegEx pattern and it's maddening me ;-) Can anybody help me, please? My RegEx Pattern: /(\d+)?:?(\d+):(\d+)/ Time-Strings: 2:03, 24:35, 2:43:36 Output: Array [ "2:03", undefined, "2", "03" ] // correct Array [ "24:35", "2", "4", "35" ] // should be: [ "24:35", undefined, "24", "35"...

How to open pdf file which is located at server side by specifying its server side path in android using mupdf

android,mupdf
I am using mupdf library to render pdf file within my android application. When I am specifying local path for pdf, it open successfully within my app, where as when I write following code to render server side pdf file, it gives error message in dialog box as can not...

Kendo dropdown with ng-options instead of DataSource

javascript,angularjs,kendo-ui,html-select,angular-directive
I've got a dropdown list defined using angular like this: <select class="form-control" ng-model="controller.selectedUser.superiorId" ng-options="superior.userId as superior.lastName + ' ' + superior.firstName for superior in controller.superiors | orderBy:['lastName', 'firstName']"></select> This works fine, however I want to show a little image next to the entries and so I'm trying to convert this...

NodeJS - controller method not calling

javascript,node.js
I created a NodeJS application with port 7777. server.js 'use strict'; var express = require('express'), router = require('./router'); var app = express(); var port = 7777; app.use(router()); app.listen(port); console.log('Doctor appointment at ' + port); I am calling router from server and executng application as node server.js router.js 'use strict'; var...

Set flag in Jinja2 loop, access outside of loop [duplicate]

python,jinja2
This question already has an answer here: Jinja2: Change the value of a variable inside a loop 2 answers I would like to set a flag inside a Jinja2 template for loop and later display something or not depending on the flag like so: {% set foobar = False...

Why is not recommended to modify session configuration for authorization headers in Alamofire?

swift,alamofire
From: https://github.com/Alamofire/Alamofire Modifying Session Configuration ... example code ... This is not recommended for Authorization or Content-Type headers. Instead, use URLRequestConvertible and ParameterEncoding, respectively. Ok, I will not use it, but why it is not recommended for handling Authorization headers?...

Python 3 - A Specific Operation on a List

python,python-3.x
I have a list of length n having positive numbers like: list = [a,b,c,d,g,h,w,x,y,z] where a,b,c... are all numbers. I want to check if the list has any any two consecutive pairs of numbers which satisfy the below criteria: [w,x] and [y,z] such that w = z +/- 1 and...

TCL: Make code cleaner from nested if-statements

if-statement,tcl
This is a procedure of one of the items of the status bar on i3 window manager on linux. Is run every second. Basically deals with frequency governors. If temperature reaches a certain number then switch to powersave mode, or if a certain application is running, e.g. steam, or the...

Add comma separated input to table column

sql-server
I have a table that have three column in it Agent_Listing_Company>- ListingId, AgentId, CompanyId I want to insert comma separated input in it. My input is like ListingId = '5', AgentId = '6,7,8', CompanyId = '9,10,11' I am using this query for insertion but its not working INSERT INTO dbo.Agent_Listing_Company...

Merging CSV Files with missing columns in Pandas

python,csv,pandas
I'm a new to pandas and python, so I hope this will make sense. I have parsed multiple tables from a website to multiple CSV files, and unfortunately if the value was not available for the parsed data, it was omitted from the table. Hence, I now have CSV files...

Why the division of two integers return 0.00? [duplicate]

c,floating-point,int,printf,format-specifiers
This question already has an answer here: printf(“%f”, aa) when aa is of type int [duplicate] 2 answers Every time I run this program I get different and weird results. Why is that? #include <stdio.h> int main(void) { int a = 5, b = 2; printf("%.2f", a/b); return 0;...

How to echo an str_replace only if array exists in results

php,foreach,echo,str-replace
I'm very amateur when it comes to PHP, so hopefully this makes sense. I have the following foreach loop that fetches all of the "credits" that are linked to a music artist using that artist's id (mixer, producer, arranger, composer, etc). I want to be able to replace the different...

How to animate enter and leave of MeteorJS {{#if}} block?

animation,meteor,spacebars
The title really says it all. Given a template: {{#if selection}} <div class="something"> <p>To Animate</p> </div> {{/if}} how do I control enter and exit animations of .something? Thanks....

jQuery string-variable as id-selector return empty object

javascript,jquery
There is something I'm not seeing here.. I have a string-variable with elements id: var sf_new_id = "#sf_widget_choice-32:14.86:1:1" I get that string from another element like this('sf_selectedmethod' is another element): var anotherid = sf_selectedmethod.attr('id'); Then I removed the last char and add some info to that id, namely the last...

Running .VBS from Batch File

windows,batch-file,cmd
I have been writing some batch files to some specific job in my role as Desktop Support. I have been scripting a Profile Backup script for a couple of months now, changing as the role requires and as new issues crop up. I am trying to run the following VBS...

Basic HTTP server w/ Node JS

node.js,http,server
I'm in a bit of a predicament. I'm new to coding in general, and this is my assigned program for my JavaScript class this week. We are supposed to create a web server that serves files from a file system, that also implements Node modules. It must be able to...

How to make cell clickable also the buttons on cell will be clickable in swift

ios,swift,tableview
I have used tableview in storyboard. in this tableview I have added cell. each row cell contains labels and some buttons. Now: I want to make row as clickable as well buttons on cell that will be clickable. I have tried using storyboard but it is not working....

Why Dojo grid.refresh is making another server call?

javascript,dojo,dojox.grid
We are using dojo JsonRest. Whenever we need to refresh the grid with new data, dojo is firing two server calls. Below is the code. var MyJsonRest = declare(JsonRest, { get: function(id, options) { return this.inherited( arguments, [id, lang.mixin(this.headers, options)]); } }); myDataStore = MyJsonRest({ target: someurl, headers: { 'moduleUName':...

Replace character in string with multiple characters Shell Script

bash,shell,raspberry-pi,raspberry-pi2
I want to replace "." in this result: "172.16.0.25" with " dot ". Here is my code: #!/bin/bash connection=`netstat -tn | grep :1337 | awk '{print $5}' | cut -d: -f1` #this returns "172.16.0.25" replace=" dot " final=${connection/./$replace} echo "$final" Which returns: test.sh: 4: test.sh: Bad substitution I tried using...

Avro : java.lang.RuntimeException: Unsupported type in record

apache-pig,runtimeexception,avro
Input: test.csv 100 101 102 Pig Script : REGISTER required jars are registered; A = LOAD 'test.csv' USING org.apache.pig.piggybank.storage.CSVExcelStorage() AS (code:chararray); STORE A INTO 'test' USING org.apache.pig.piggybank.storage.avro.AvroStorage ('schema', '{"namespace":"com.pig.test.avro","type":"record","name":"Avro_Test","doc":"Avro Test Schema", "fields":[ {"name":"code","type":["string","null"],"default":null} ]}' ); Getting a runtime error while STORE. Any inputs on resolving the same. Error Log :...

Migrating a Qt QGL based project to use OpenGL 4.3

c++,qt,opengl,opengl-es
Ever since I first started my current Qt project around 6 months ago, it has been using what I believe is version 1.3 of OpenGL. However as of recently, I've been itching to actually start improving the way I render things, and it appears that I'm missing many functions that...

Passing two query string parameter using Rails 3

ruby,ruby-on-rails-3.2
I want to pass two id in link_to tag so that by using two id I can fetch data from DB.but in my case it is showing one id is coming with URL in address bar therefore i am getting the following error. Error: ActiveRecord::RecordNotFound in PaymentsController#download_pdf Couldn't find PaymentVendor...

why does the following code crash. (dynamic memory)?

c++,memory,dynamic
My program counts the occurrence of each digit from 0 to 9 in a string. It seems to me that i have done everything correctly, but a problem still persists. int main(){ string word = "23456745"; int* ReturnArray = count(word); for(int i =0; i < 10; i++){ cout << i...

How to define function on click, after element append in dynamically or (setTimeInterval) [duplicate]

javascript,jquery
This question already has an answer here: Event binding on dynamically created elements? 8 answers I have made on click function for dynamic elements but its not working, Is there a way around it? $( "p" ).on( "myCustomEvent", function( event, myName ) { $( this ).text( myName + ",...

To declare or not local variables in JavaScript

javascript
Which is better way of writing foo()? foo1() or foo2()? Better in terms of: Performance Memory consumption Variable/Object entropy Assuming other factors are taken care of. ex: the variable is not used at multiple places within the function, etc. function f1() { return 10; } function f2() { return 20;...

Best way to remove the last blank space from words read using sstream?

c++,stringstream
So, my code is supposed to scramble words of a sentence without altering the order they appear on the input. The code works fine, but at the end of the output there's a blank space which leads to a presentation error. #include <iostream> #include <string> #include <sstream> using namespace std;...

How to add custom UIView(xib) in custom UITableviewCell with the help of AutoLayout?

ios,objective-c,uitableview,uiview,autolayout
I have one View Controller in which I have one UITableView. I have used custom UITableviewCell with xib in that UITableView. Now I have one UIView with xib and I want to add that UIView's object in custom UITableViewCell with the help of AutoLayout. I added that UIView successfully in...

how to match hash values in two different hashes

ruby,hash
I am trying to count the number of matching appid in two separate hashes, but my solution feels clunky. Can someone suggest a 'ruby' way of doing this? #hash from an array: {"appid"=>240, "playtime_forever"=>103} {"appid"=>2670, "playtime_forever"=>1099} #This is Steam data for those interested def games_in_common(friend_hash,other_hash) arr1=Array.new arr2=Array.new other_hash.keys.each{|k| arr1<<other_hash[k] }...

How to call instance methods inside a block?

ios,objective-c-blocks
I want to call instance methods inside a block. Here is the method that I am working with, [self.someVariable addBoundaryTimeObserverForTimes:timeArray queue:NULL usingBlock:^{ [self myInstanceMethod]; }]; But I am not able to reference self from inside this block. What should I do? EDIT: I am sorry that I posted this question...

How i can get list from some class properties with java 8 stream

java,collections,java-8,java-stream
Good day. I have a list of Person. I need get a list from property of Person. For example i have a Person class: class Person{ private String name; private String birthDate; public String getName(){ return name; } public String getBirthDate(){ return birthDate; } Person(String name){ this.name = name; }...

how to handle a long wait time for data, when ios 8+ app has been backgrounded by user

ios,swift
I've spent a lot of time looking at the options but am still not 100% clear, so wanted to reach out for some guidance. Scenario is this: User submits an HTTPS request to our backend server for some data via an iOS app Depending on the data, the first (only)...

How to call function in controller in angularjs?

angularjs,angularjs-scope,angularjs-controller,angularjs-ui-router
If in url parameter id is available then i want to call function. .controller('repeatCtrl', function($scope,$state,$stateParams) { if($stateParams.id != ""){ //Here i want to call itemDetails function $scope.itemDetails(id); }; $scope.itemDetails = function(id) { // function body here!! alert(id); }; }) ...

Image sizing for web application [closed]

php,html,css,image
I use php and framework named "laravel 5.0". There is a great package for gd library, and I can resize or add some grey filter. Now I'm about to create the web app and use a few types of sizes of images such as the image for thumnbnaill, the image...

Printing values using Iterator on 2d vector

c++,vector,stl,iterator
Here is my code: std::vector< std::vector<std::shared_ptr<int>> > om(2, std::vector<std::shared_ptr<int>>(2)); om[0][0] = std::shared_ptr<int>(std::make_shared<int>(1)); om[0][1] = std::shared_ptr<int>(std::make_shared<int>(2)); om[1][0] = std::shared_ptr<int>(std::make_shared<int>(3)); //init values om[1][1] = std::shared_ptr<int>(std::make_shared<int>(4)); std::vector<std::shared_ptr<int>>::iterator pd; //inner iterator...

Reading multiple space-delimited text files from a folder in R

r,import
I have 100 space-delimited text files in a folder. Each text file has a paragraph of text in it. I wish to extract the data in a data frame with column 1 as File ID and Column 2 as the corresponding text paragraph. This is what I have tried so...

Multiple JFrame or JDialog

java,swing,jframe,jdialog
I'm developing an application with Swing and there is a situation that I couldn't decide to what to do. I need multiple pages but; Should I use multiple JFrame or JDialog or something else? What are the advantages of them? Is there specific way to choose? ...

Calculate bytes of the unicode character in python

python,unicode,byte
I'm writing a Python script to read Unicode characters from a file and insert them into a database. I can only insert 30 bytes of each string. How do I calculate the size of the string in bytes before I insert into the database?

How can I access the sample code for several Activities in Android Studio?

android,google-maps,android-studio
I remember somehow being able to access the sample code that I think came with the standard Android Studio download. I can't access that now however, because I don't remember the location. I am referring to the files named "BasicMapDemoActivity", "ProgrammaticDemoActivity", "OptionsDemoActivity", etc. Any idea where I could find these?...

Mongoose find and findOne middleware not working

node.js,mongoose,find,middleware
If have the following schema and middleware hooks, but the find and findOne hooks are never being called. The save and update hooks work as expected. According to the Mongoose Middleware documentation, this should be available. // define the schema for our recs model var recSchema = mongoose.Schema({ dis: String,...

Where to place a method which checks if two edges are parallel in a graph?

java,oop,graph,uml,software-engineering
I'm divided as to where to place a method which checks whether two edges are parallel in a graph. In the UML class diagram seen below, I have placed my suggestions in notes. The figure depicts that a Graph consits of Edges and Vertices. Two edges are parallel if they...

When passing a function as a pointer, how do I specify the parameters?

c++
I've found a ton of info on function pointers, but one thing is really confusing. How am I supposed to specify the parameters of the function that's being passed? An example from what I've been trying to do... void BatchDelete(string head, string filename, void (*f)(string, string)); void DeleteOneNode(string head, string...

How to upsert document in MongoDB Java driver 3

java,mongodb,scala,mongodb-java,casbah
what is the idiomatic way to upsert a document using version 3 of the mongodb java driver (specifically v3.0.1)? We have a collection for sessions and when a new session gets created or modified, we want to upsert it in one operation - rather than having to query if a...

Extract text from php using Jsoup result an empty textView

android,jsoup
I am parsing this page : http://www.catedralaltapatagonia.com/invierno/partediario.php?default_tab=0 I need the weather report and the last update date and time (I read the source code,and the info is there under div#meteo_contenedor_avalanchas) but when i run the project i receive an empty textview. This is my code: public class Metreologia extends Activity...

Why “babel-node” spins 2 processes?

node.js,babeljs
I have the following script in my package.json: "scripts": { "start": "babel-node app" } When I run npm start and then ps aux | grep node, I see 2 processes running: mishamoroshko 18102 58.9 4.2 3173444 174656 s001 S+ 2:37pm 0:03.18 node /Users/mishamoroshko/my-project/node_modules/babel/bin/_babel-node app mishamoroshko 18101 0.0 0.4 3045884 15488...

Trouble displaying Cell Date in swift, No errors

uitableview,swift,cell
ok so basically setting a basic messaging app using parse, have my message controller here finished but the cell data just isn't displaying. Im not getting any errors so not much to go on. Can anyone with a fresh pair of eyes spot the error code is as follows :-...

Angular JS filters working unexpectedly?

javascript,angularjs,search
I'm trying to filter a list of json data (https://api.myjson.com/bins/5a2aw) using an Angularjs filter. When I just use filter exact matching does not take place and for 1 shows results with id = 1,10,11,12. Using true with filter though works very weirdly, a single result whose id is 7 appears...

does not conform to protocol Swift Parent Class - Objective C Protocol

objective-c,swift,protocols
I am trying to call my Protocol Class in Swift, but its giving me Error "Type SwiftViewController does not conform to protocol ABCDelegate. Could you please tell me what I am missing , as I find other posts , but nothing is explained properly , also let me know if...

AppBarLayout is not responding to scroll in the fragment

android,android-design-library,androiddesignsupport
I am using the new Android Support Design library. I have followed the demo on the Android Developer Blogspot except I use a fragment for RecyclerView instead of putting both in the same xml. Here's my activity_main.xml <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/drawer_layout" >...

Dandelion DataTables deferRender not working

jsp,spring-mvc,jquery-datatables,dandelion
I am using ajax source to display data on the table. Above my table i have criterias to filter what i want to display in my table. What i want to achieve is to disable initial data load, so when page is loaded I'll get empty table, then after I'll...

find element with max value from std::map [duplicate]

c++,std,stdmap
This question already has an answer here: C++ Help finding the max value in a map 6 answers I'm trying to get the element with max value from std::map, int main() { map<int, int> m; m[1] = 100; m[2] = -1; auto x = std::max_element(m.begin(), m.end(), m.value_comp()); cout <<...

validating mutiple drop downs list with the same name field in CakePHP 2.x

cakephp,drop-down-menu
I'm new to cakephp 2x. I have multiple drop down in my form. All the drop downs are using same list data, from one table called -> Students. Now what I want is ,when the user select first student in first drop down ,then that student should be minus from...

Spring bean loading order

java,spring,spring-mvc
I've two bean definitions in my application-context.xml (BeanClassA, BeanClassB). If BeanClassA has an @Autowired annotation to BeanClassB, Should the BeanClassB be declared BEFORE BeanClassA in the bean definitions in application-context.xml? More generically is there an inherent order in which the beans would be loaded..

Null result for date object fetched from DB giving sysDate/current date on mapping to Java object

java,database,oracle,date,orm
I fetched data from the oracle database through java code using a query similar to the below: select min(specDate) from table The result is supposed to be of type Date. Since there was no specDate populated for any of the rows in the table, the result was null. I used...

What is the difference between @YES/@NO and YES/NO?

objective-c,boolean,objective-c-literals
In Objective-c what is the difference between @YES/@NO and YES/NO? What types are used for each?

Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821'

asp.net,wcf,log4net
I have added Log4Net in my project using NuGet Package Manager and it is showing Version 2.3 installed on my system. Here is my config entry: <configSections> <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> </configSections> and then reference to...

What are the different ways to know which all classes and methods present in a DLL?

c#,dll
I was in interview and interviewer asked me the below question. How to know what classes and methods are present in DLL ? I was confused and said, "we can use tool or refactor that." Can someone explain the different ways to find everything from DLL (from code as well...

How to get source of a sampled bin in Coverage in QuestaSIM

system-verilog,function-coverage,questasim
I'm using QuestaSIM and have a merged coverage report from regression. From my merged coverage report, how can I trace a sampled bin back to its simulation (test name & seed value)?...

Why is TfidfVectorizer in scikit-learn showing this behavior?

python-2.7,scikit-learn,tf-idf
While creating TfidfVectorizer object if I pass explicitly even the default value for token_pattern arguement it throws error when I do fit_transform. Following is the error: ValueError: empty vocabulary; perhaps the documents only contain stop words I am doing this because eventually I want to pass a different value for...

CSS Polaroid style image/caption scaling issues

html,css
I have fixed proportion images and I would like to wrap them in a polaroid style graphic with a caption using CSS. The total image should take up approximately 60% of the vertical height of the screen and the width should scale accordingly. Markup <span> <img src="https://placekitten.com/g/320/320"> <div>Kitler, 1978</div> </span>...

Table Generation issue in R

r,for-loop,matrix
I was trying to run this simple code in R and that's what I got: table <- matrix(NA, nrow=10, ncol=1) for (i in seq(0.01, 0.10, by=0.01)) { table[i*100, ] <- i } table # [,1] # [1,] 0.01 # [2,] 0.02 # [3,] 0.03 # [4,] 0.04 # [5,] 0.05...

Hibernate @OneToMany tries to insert null

java,hibernate,jpa,orm,hibernate-mapping
I have the following simple example. When it runs, I see the QuoteRequest object being generated with auto-generated id. Next, I see the Accidents object being generated, but quote_request_id that's being inserted is null, so I get an error: Column 'quote_request_id' cannot be null @Entity @Table(name = "Quotes") public class...

How to disable browser features and shortcut keys to conduct fullscreen online Exam?

javascript,php,jquery,twitter-bootstrap,codeigniter
I am new to OES (Online Exam System). I want to conduct an Online Examination with Secure environment that user will not be able to cheat please help do this. I am using PHP with Codeigniter framework for back end and bootstrap, JS and JQuery for user side or front...

Bigquery select distinct values

google-bigquery
How to select distinct values in Google Bigquery? Query: SELECT DISTINCT cc_info FROM user WHERE date = ? Thanks!...

How to add a resource file in visual studio

visual-studio-2012,resx
I want to add a resource file to my project in Visual Studio. But I am not able to find from where I can create the resource file. Can anyone help me out in this

How use PyQt without GUI?

python,pyqt,pyqt4
I want create python server application using PyQt4 without GUI ( signal/slots, threads, process and other core patterns ). How i can create this?

Find a Duplicate in an array Ruby

arrays,ruby
I am trying to find the duplicate values in an array of strings between 1 to 1000000. However, with the code I have, I get the output as all the entries that are doubled. So for instance, if I have [1,2,3,4,3,4], it gives me the output of 3 4 3...

How to use uuid:randomUUID() in policy builder @Novell

java,uuid,novell,novell-idm,netiq
I want to use predefined method of java using java.util.UUID:randomUUID() for 046b6c7f-0b8a-43b9-b35d-6489e6daee91 in place of CN, but when i use this code in my policy, then it gives me com\.novell\.xsl\.extensions\[email protected] in place of CN. So how can i solve this issue? Here is my Policy : <do-set-local-variable name="id1"> <arg-string> <token-xpath...

What's the best way to remove event listener on an element?

javascript,jquery
The jQuery .off() API can only remove the event that was added by using its own on(or bind in jQuery) method, many third-party plugins may add events using pure javascript and because of browser compatibility issues, is there any single line of code that can do this stuff more easily?

Use same Fragment class in ViewPager

android,android-fragments,android-viewpager
I have a ViewPager and I want to use the same Fragment type for all it's Views but I have a problem. Only the first View is actually updated. If I swipe to left/right I get an empty Fragment and if I swipe back I can see that the Fragment...

What's the difference between file_get_contents a variable and a string?

php,simple-html-dom
I have source code : A. $this->eArticle["product_link"] = 'http://afamily.vn/doi-song/lop-hoc-toa-tau-day-nham-mat-ve-obama-khien-tre-thich-me-20150530074455878.chn'; print file_get_contents($this->eArticle["product_link"]); AND B. print file_get_contents('http://afamily.vn/doi-song/lop-hoc-toa-tau-day-nham-mat-ve-obama-khien-tre-thich-me-20150530074455878.chn'); In A, result return NULL ( screen haven't text ) In B, result display website...

How to dynamically add listener to button on customAdapter in android

android,onclicklistener,custom-adapter
I want to increment/decrement the count and update it to the database when click on button. the problem is button is on adapter, how should i apply an listener to individual button and update the count for particular user on UI as well as in Database. What I have achieved:...

How to group fields to get one change value handler

java,gwt
I have a Presenter like this: public class ItemPresenter { public interface Display { TextBox getFilterItemName(); TextBox getFilterItemAmount(); } public ItemPresenter() { addChangeValueHandlers(); private void addChangeValueHandlers() { this.display.getFilterItemName().addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { display.reload(getItemList(display.getFilterBaseVersionName() .getText())); } }); this.display.getFilterItemAmount().addChangeHandler(new ChangeHandler() { @Override public void...

Run time exception in the code [duplicate]

android
This question already has an answer here: Cannot add header view to list — setAdapter has already been called 7 answers I have this code to create a parallax scrolling effect,i could not found any errors in this code but when i run the app it crashes and it...

MySQL SUM time(3) with milliseconds

php,mysql
I have mysql column time(3) and it's storing good value of time.. but then I want to sum two times it converts to bad time format; I have two records: id | time ---|----------- 1 | 00:00:15.490 2 | 00:02:14.900 So in real I shoud get: 00:02:30.390 but I get...

Is there even any need to use the django rest framework [closed]

django,django-rest-framework
I wanted to build a backend which resembled a RESTful architecture, and I came across something called the Django REST Framework, which talked about serialization, response (JSONResponse()) and user authentication to build a Web API. However, all these functions are already available in Django 1.8 (serialization, JSONResponse(), user authentication), so...

Convert numpy int array to boolean array

python,arrays,numpy
I have an array that maps the cells in a game of life. So far I have an int for every single cell. To minimize the amount of reads I want to compress the array to whole 8 cells per 1 integer. The problem arises when I want to create...

Critical section in service, multithreaded service

multithreading,delphi,service
I developed a service application which is collecting JPEG data from some equipment. Number of remote devices varies from 1 up to 20. After service start it creates a number of threads=current number of remote devices. Every thread is writing into global array of records. Record: type TDevice=record devName:string; ms:TMemoryStream;...

R - Contingency table once against multiple table

r,table,contingency
I have a table like the following: V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 fve fve fve fve fve fve fve fve mdm mdm mdm fve fve fve fve fve fve fve fve fve fve fve fve fve fve fve fve fve fve fve mdm fve fve...

what to return or to do in a winapi window procedure in order to intercept an error and produce an error log entry

c,winapi
We have a c program. One policy in the development of this program is: "Every function/method that can fail should have a return value and should return the appropriate value in case of an error. No exception like behaviour." So, in the case of an error, our program produces a...

Scala - sort tuples by first element reverse, second element regular

scala,sorting,order
I have tuples of the form (Boolean, Int, String). I want to define Ordering which sorts the tuples in the following order: Boolean - reverse order Int - reverse order String - regular order Example: For the tuples: Array((false, 8, "zz"), (false,3, "bb"), (true, 5, "cc"),(false, 3,"dd")) The ordering should...

SQLiteDatabase.rawQuery(java.lang.String, java.lang.String[])' on a null object reference

java,android,sqlite,sqlite3,android-sqlite
When accessing the database a NullPointerException is thrown. Here is the code that creates the db: public class DatabaseHelper extends SQLiteOpenHelper { public static final String KEY_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS {0} ({1})"; public static final String KEY_DROP_TABLE = "DROP TABLE IF EXISTS {0}"; private Context context; Activity...

Pause-Resume Audio on button click

java,android
Hi Guys i create a audio play button that plays audio i named as "a" here found in the raw folder ...everything is working well the audio is being played when pressing the Play button,but i need to pause the audio on another button,also i need to add resume ....i...

Hot to set the title of a Windows console while npm is running?

node.js,windows,batch-file,npm
I have started to develop a web application project on my Windows machine, for which I use npm, bower and the nodejs HTTP server. For easier start of the HTTP server, I created the batch file: @echo off title HTTP Server npm start npm start starts the http-server. For that...

Convert a web project to EJB Project with CDI and JPA

maven,java-ee,jpa,ejb
I have a web project that was developed using JSP , Servlets and JDBC. When built it generates a web archive. Now my task is to remove the JDBC , introduce JPA, EJB and CDI which is done for some pages. After this I want to split the same project...

Dynamically created Button in Android does not look like one created using XML and also does not respond to click

android
I am trying to create a button dynamically in one of the activity. But the look and feel of the newly created button (looks flat and does not have any visual effect after clicking on it) is no at all similar to one which is being created using activity XML...

How to multiply alternate values using R?

r
I have a list of dates and corresponding values. I want to segregate only dates with the month September or any alternate date, and multiply the corresponding value by 10. Please guide me on this. Date Index values Jan 2011 2134 Feb 2011 2258 Mar 2011 2032 Aug 2011 2012...

Simple Insert Variable PHP into MySQL

php,mysql,variables,insert
I have a simple bit of code that I can't get working. <?php $mysqli_connection = new MySQLi('localhost', 'root', 'secret', 'edgeserver'); if ($mysqli_connection->connect_error) { echo "Not connected, error: " . $mysqli_connection->connect_error; $username = 'Eddie'; $username = mysql_real_escape_string($username); $email = '[email protected]'; $email = mysql_real_escape_string($email); $sql = "INSERT INTO `users` (`username`, `email`) VALUES...

How to compare two files in python and get the values in Boolean?

python
I am new in python I am working on python file operations,In Which I have a two input files 1.Security_Headers_list.txt 9508,content-security-policy 9496,content-security-policy 9240,content-security-policy 904,content-security-policy,x-content-type-options,strict-transport-security,x-frame-options 8013,content-security-policy 5263,content-security-policy,x-frame-options 4378,content-security-policy 3854,content-security-policy 3331,content-security-policy 2.Master.txt strict-transport-security content-security-policy...

Using awk and grep command in for loop

shell,awk,grep,ksh
Consider below code snippet: #! /bin/ksh for i in `grep "ProcessOrderWebService-N" Orders.Log | grep "::stringFromNetwork = 600001" | awk -F',' '{print $1}'`; do echo $i; done; 2015-05-26 10:20:10 2015-05-26 10:20:49 2015-05-26 10:21:45 From the command prompt, when I run the command: grep "ProcessOrderWebService-N" Orders.Log | grep "::stringFromNetwork = 600001" |...

How to change database_url on heroku?

postgresql,heroku
I am trying to share a database between two apps on Heroku according to Share database between 2 apps in Heroku but setting up database_url on the second app gives an error: $ heroku config:add DATABASE_URL=postgres://... Setting config vars and restarting pacific-headland-1960... failed ! Cannot destroy last attachment to billing...

How to query submenu with menu in Codeigniter?

php,codeigniter
This is my welcome controller code: public function index() { $data = array(); $data['title'] = '। All User ।'; $data['logo_image'] = $this->sv_model->select_logo_image(); $data['all_footer'] = $this->sv_model->select_all_published_footer(); $data['all_welcome'] = $this->sv_model->select_all_published_welcome(); $data['all_notification'] = $this->sv_model->select_all_published_notification(); $data['all_chairman_gallery_image'] = $this->sv_model->select_all_chairman_gallery_image();...

How to store as a comma separated list of values stored in a string, in SQL server

sql-server,c#-4.0
I have a string called joined which contains a range of values as a comma separated list. For example when I print joined the output is as follows. 59.05,59.00,58.96,58.95,58.95,58.95,58.95,58.96,60.30,61.32 What I want to know is, how can I store this sting variable in SQL Server. I want to store it...

java.net.BindException: Cannot assign requested address

java,tomcat7,ubuntu-12.04,snmp
I want to use low port in my application (SNMP Trap Receiver on Spring web + Tomcat7). As I told in this thread Binding Low Port to Java Program on Ubuntu Server, before, I got error Permission denied. Then I change tomcat7 user group be root. But after that, I...

Error in binding: No implementation was bound - Guice

java,guice
I’m trying to use Guice to solve dependency. I’ve read through tutorials and examples, but I still can’t figure out why I keep getting this error: No implementation for com.edit.owl.persistence.PersistentStore<com.edit.common.domain.Foo> annotated with @com.google.inject.name.Named(value=FooPersistence) was bound. while locating com.edit.owl.persistence.PersistentStore<com.edit.common.domain.Foo> annotated with @com.google.inject.name.Named(value=FooPersistence) for parameter 0 at...

Accessing objects through their interfaces

c#,interface
What does it really mean? I am reading design pattern book. It says objects are accessed solely through their interfaces, and i am not able to get my head around it, can some body give me some example (Will really appreciate if its in C#) What does we really achieve...

Display and render only a specific object in wireframe in Unity3D

unity3d,unityscript
I want to know how to view and render a specific game object (mesh) in wireframe, not the whole scene. I can change the scene to wireframe using GL.wireframe but the problem I want to view and render only a certain object (not the whole scene) in wireframe. Any advice...

Serializer needs to include more info in a GET while accepting primitives in a POST

django,django-rest-framework
Right now I have the following serializer: class ShiftSerializer(serializers.ModelSerializer): confirmed_location = LocationSerializer(required=False) class Meta: model = Shift When I create a new Shift object I can pass along a basic object like this... {date_requested: "2015-06-11", employee: 4, shift_requested: 2} ...and the object gets created without issue. In an effort to...

How to implement Facebook Realtime Update Subscription with callback URL [closed]

java,facebook,web-services,restfb
How to implement Facebook Realtime API

Meteor Collection: find element in array

mongodb,meteor
I have no experience with NoSQL. So, I think, if I just try to ask about the code, my question can be incorrect. Instead, let me explain my problem. Suppose I have e-store. I have catalogs Catalogs = new Mongo.Collection('catalogs); and products in that catalogs Products = new Mongo.Collection('products'); Then,...