FAQ Database Discussion Community


Declare different type of variables using switch

c#,variables,switch-statement
I am trying to create a new variable based on a particular value received from a function. The variable can be of different classes. Here's what I am trying: switch (request) { case "ClassA": { var x = new ClassA(); break; } case "ClassB": { var x = new ClassB();...

MySQL: Remove JOIN for Matched Row if 2nd Round of Criteria Not Met

mysql,join,left-join,match
CONDENSED VERSION I'm trying to join a new list with my existing database with no unique identifier -- but I'm trying to figure out a way to do it in one query that's more specific than matching by first name/last name but less specific than by all the fields available...

Adding files to $scope in AngularJS controller

angularjs,angularjs-scope,multipartform-data,form-data
I have the following input element:  <div class="form-group">     <label>Attach BOL Document</label>        <input name="file" type="file" class="form-control" onchange="angular.element(this).scope().uploadFile(this.files)" />  </div> In my controller (outside of any function) I set a variable like this: $scope.fd = new FormData(); and I have the following function defined that fires onchange of the input element as...

Unexpected Symbol in As Formula, Can't Find

r,string,text,syntax-error,formula
I've been using as.formula for setting up a glm, and I can't figure out where the unexpected symbol is. Part of the problem is that the character vector I'm converting is so long. It's about 700 words with + inserted in between in order to turn it into a formula....

While statement inside .innerHTML

javascript,html
I have this code. document.getElementById("stage").innerHTML = "<table>" + while (c<b) { c++; } + "</table>" What I want the while statement to do is to create the rows for the table (the "" stuff). Is it possible with my approach or should I try another way? Thanks!...

Python “private” classmethod and DRY

python,dry,class-method
Occasionally, a class will have a "private" @classmethod which other methods call: class FooClassThisSometimesHasALongNameEspIfAUnittestSubclasss(...): @classmethod def foo(): ... def bar(self): ... FooClassThisSometimesHasALongNameEspIfAUnittestSubclasss.foo() ... As can be seen, the class name is repeated; it's admittedly probably not serious enough to cause a meltdown of current technology followed by a zombie apocalypse,...

Android: CollapsingToolbarLayout and SearchView, text overlapping

android,searchview,collapsingtoolbarlayout
I have little problem with overlapping CollapsingToolbarLayout title with SearchView text. When is CollapsingToolbarLayout expanded, there is no problem: But when is collapsed, the text is overlapped: How to fix it?...

Length of array in JSON object is returning undefined

javascript,jquery,json
I am retrieving JSON data from a PHP file like so: $.getJSON('fresh_posts.php',function(data){ global_save_json = data.freshcomments; var countPosts = data.freshposts; var howManyPosts = countPosts.length; I need to get the length of the first main array in the object, but there is an issue. howManyPosts is returning undefined. The JSON object from...

More pythonic/elegant way to do this Python string slicing?

python,string,lambda
So I have a function that takes two string inputs - it slices them so that if of even length, the length of the front segment is the same as that of the back, and if of odd length, the middle character goes to the front segment (i.e. hello ->...

Linux local communication sockets: Why is bind() not failing as expected?

c,linux,sockets,bind
I have this server application that sets up a local communication stream socket for clients to connect to. If a second instance of the server is launched and it tries to bind to the same address (file name), bind() should fail with EADDRINUSE. But it does not. Why? Here is...

Why does video resolution change when streaming from Android via WebRTC

android,google-chrome,video,webrtc,video-processing
I'm trying to stream at 640x480 from Chrome on Android using WebRTC, and the video starts off at that, but then the resolution drops to 320x240. Here are the getUserMedia parameters that are sent: "getUserMedia": [ { "origin": "http://webrtc.example.com:3001", "pid": 30062, "rid": 15, "video": "mandatory: {minWidth:640, maxWidth:640, minHeight:480, maxHeight:480}" }...

Jquery duplicate selected checkbox

javascript,jquery,forms,checkbox
I have a search page that uses a form and checkboxes to display results. When the page reloads with the new results, I want to display something like this at the top of the page so users can easily remove one of their selections: X Blue     X Red    ...

App crashing when mGoogleApiClient.connect(); is called

android
I am trying to integrate a sign in feature for my app. But it crashes when the sign in button is pressed. The log just shows that Signin button was clicked where mGoogleApiClient.connect(); is called and then it crashes. Also none of the Log in the Override methods are printed,...

PHP: YouTube v3 API… Retrieve last 50 videos from Watch Later list and add them to a playlist

php,youtube-api
<?php require_once 'Google/autoload.php'; require_once 'Google/Client.php'; require_once 'Google/Service/YouTube.php'; $client = new Google_Client(); $client->setDeveloperKey('{YOUR-API-KEY}'); $youtube = new Google_Service_YouTube($client); $nextPageToken = ''; $htmlBody = '<ul>'; do { $playlistItemsResponse = $youtube->playlistItems->listPlaylistItems('snippet', array( 'playlistId' => '{PLAYLIST-ID-HERE}', 'maxResults' => 50, 'pageToken' => $nextPageToken)); foreach ($playlistItemsResponse['items'] as...

I can not see download image in gallery until I restart the phone

java,android
When I download an image and save it to the Android device the image does not appear in the gallery, later after the phone is restarted the images are in the gallery. Here is the code where I download the images and save them to the device: private void downloadImage()...

How do I use a dynamic form action using angular?

angularjs
I have an http get method that generates a dynamic form upload URL. When I display it on the screen it works. When I put it in the action tag of a form it does not appear. <div ng-app="mainApp" ng-controller="data-controller"> <form action="{{uploadUrl}}" method="post" enctype="multipart/form-data"> <input type="file" name="myFile"> <input type="submit" value="Submit">...

One UIAlertController function with multiple actions - is this possible?

ios,swift,segue,uialertcontroller
The following code is for a function I wrote to handle the 'Back' button and the 'Logout' button. When the user taps 'Cancel', he will stay on the current view, when he taps 'OK' he will be taken to either the previous view or the login screen, depending on which...

How can I use lodash in dojo?

dojo,lodash
Is there a module for lodash that I can import into my dojo project? I know that I can always reference it by window._, but I wanted to be more conventional (as far as dojo is concerned) and formally require it into my module. Thanks in advance....

Truncate everything after first 120 characters and refresh

javascript,jquery,backbone.js
I'm quite new to UI development. I have a textfield. (input) where the user enters a string for SMS. I want to discard all the characters which are more than 120. I have written code for this one. Problem: if the user enters more than 120 characters, how do I...

RedirectToAction when NullReferenceException of the Model is raised

asp.net-mvc,exception-handling,asp.net-mvc-5
I have the following controller method public ActionResult Details() { try { Pacient pacientdp = new Pacient(); if (pacientdp.PacientPrenume == null) { return RedirectToAction("Index", "Home"); } var id = WebSecurity.GetUserId(User.Identity.Name); MedicalDBContext pacientContext = new MedicalDBContext(); Pacient pacient = pacientContext.Pacients.FirstOrDefault(x => x.PacientID == id); return View(pacient); } catch (Exception ex) {...

Searching for the change history of partial file or path in Mercurial or TortoiseHg

mercurial,tortoisehg,file-search
Each time I need anything beyond the standard search, I find myself trying several things, searching Google and in the end terribly failing. Apparently, the Hg search syntax is pretty extensive and I would like to use its power, but I don't seem to be able to find a good...

What's the proper way to open a file in python 2.7?

python,python-2.7
I'm trying to open a txt file in IDLE but it gives me an error. I can't figure out what happens to the f in my file name or why the single '\' becomes double in the error message. >>>f=open('D:\programs\python 2.7.10\programs\foo.txt','r') Traceback (most recent call last): File "<pyshell#94>", line 1,...

belongs_to with foreign_key not working in one direction

ruby-on-rails,foreign-keys,belongs-to
class Position < ActiveRecord::Base belongs_to :product, foreign_key: :symbol end class Product < ActiveRecord::Base has_many :positions, primary_key: :symbol, foreign_key: :symbol end When I do Product.first.positions.first I am getting a Product back. But, when I do Position.first.product I am getting nothing. When I look at the SQL generated by the query, it...

Check box for Column listview Wpf

c#,wpf,listview,checkbox
How to create Check box for Column inside Listview. i was able to make checkbox for listview items. but i want to have checkbox for Column itself.like in windows: here is code in XAML <ListView HorizontalAlignment="Left" Grid.Row="1" Width="400"> <ListView.View> <GridView> <GridViewColumn Width="140" Header="Column1 With Checkbox"> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox Tag="{Binding}" IsThreeState="False"...

(dynamic) Rails model (object) parameters (values) through has_many associations

ruby-on-rails,ruby,activerecord
I have a multiple models (ie. tires and rims). Multiple models have multiple parameters (like color, size, type, etc.) I have this: Parameter: belongs_to :tires belongs_to :rims ParameterValue: belongs_to :parameter belongs_to :tires, :through => :parameter belongs_to :rims, :through => :parameter Tire: has_many :parameters Rim: has_many :parameters Here goes the problem....

How to exclude generated code from coverage statistics

testing,go
I have thrift generated code in my project? How do I stop this from affecting my coverage stats? They're dismal.

Convert String(already formatted) to an Array of NSDictionary

ios,arrays,string,nsdictionary
I have this String already formatted as a [[String:AnyObject]], however I can't retrieve the information out of it nor couldn't find a way to convert it to a dictionary. [ [name: Laura, age:33, gender: female], [name: James, age:25, gender:male] ] What can be done to convert this string into a...

Can't figure out how to instantiate generic class returned from function with condition like

java,android,generics,android-studio,java-generics
Can't figure out how to get this work: //Have a tiny CustomServiceLoader implementation public class MyServiceLoader { static private Map<Class<?>, Class<?>> CONTENTS = new HashMap<>(); static public <S, T extends S> void registerClassForInterface(Class<T> c, Class<S> i) { if (c == null) { CONTENTS.remove(i); } else { CONTENTS.put(c, i); } }...

How does PBS_NODEFILE work in pbs?

pbs,qsub,torque
For example, I have a file /home/user/nodes, which contains: node1 node2 node3 node4 ... When I try to submit a job like: qsub -v PBS_NODEFILE=/home/user/nodes -l nodes=2 Does it mean that pbs will select 2 nodes from /home/user/nodes list? I tried but it was not. It still chose the nodes...

Adding months to setMonth of javascript showing a 0

javascript,date
I'm running to an issue I'm not sure how to resolve it; so the deal is that I have a function of javascript that take the date selected from the user and depending of another selection it adds to the date 6 o 12 months, the weird thing is that...

Using sed, awk or grep to split a string with numbers [duplicate]

regex,bash,shell,awk,sed
This question already has an answer here: Learning Regular Expressions [closed] 1 answer I have this file: mmD_154Lbb_e_dxk_83233.orc 154L_bbe_Bddxk_3259.txt 14Lbe_3233.orc m2_154Lbbe_dxk_67233.op mZZ_1A4Lbbe_dxk_32823.op mmD_154Lbbe_dxk_99333.orc mmD_oS154be_dxk_12338.txt I'm trying to use sed or awk to split the numbers and I don't have solution: I need out put: 83233 2597 3233 67233 32823...

Access declared variables via `this` in non-global scopes

javascript,scope
var x = 16; console.log(this["x"]); // 16 I'm ok with this, but: (function () { var y = 16; console.log(this["y"]); // undefined }()); Why we cant access variables via this ?! I know it's possibe when we assign values, for example: (function () { x = 16; // will assigned...

Query total physical memory in Windows with Golang

windows,go
Trying to get the total physical memory using Go on Windows but not sure which package(s) to use and calls to make. I believe this can be done with syscall. Would also prefer not to interface with C to do this.

Bootstrap 5 img-responsive in one row

html,css,twitter-bootstrap
I am having a hard time getting 5 img-responsives classes in a row with bootstrap. I am new to bootstrap so I may be way off here but this is what I have right now. HTML: <div class="container" id="pics" > <div class="row"> <div class="col-lg-3 col-md-6 text-center"> <div class="service-box"> <img class="img-responsive"...

Lifecycle policy on S3 bucket

amazon-web-services,amazon-s3
I have an S3 bucket on which I've configured a Lifecycle policy which says to archive all objects in the bucket after 1 day(s) (since I want to keep the files in there temporarily but if there are no issues then it is fine to archive them and not have...

Different width divs in the same row

html,css
I'm trying to put 3 divs(with different widths respectively : 10%,70% & 20%) in the same row but the middle one always go full width of the page. Here is my code: #left-bar { width: 10%; background-color: #FF0000; } #middle-bar { width: 70%; background-color: #6600FF; } #right-bar { width: 20%;...

Java Vector wrong output

java,vector,output
My problem is, when I add for example 3 inputs in Vector and when I display the result I only found the last output. XMLTable, Table,Column = classes cols : the vector who contain the problem Code : btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { XMLTable xt= new XMLTable();...

VBS (MSGBOX)- How can I add multiple attribute numbers (such as 16)

vbscript
I want to create a VBS script that has a message box with multiple numerical attributes, for example having a message box with the 16 icon as well as the 2 value (Abort,Retry,Ignore) In other words, I would want to combine the following two scripts into one. lol=msgbox("Body message",16,"Title") with...

How to properly write a RewriteCond for https and subdomains

regex,apache,.htaccess,mod-rewrite,url-rewriting
Thus far I've gotten this far with my RewriteConditions but it's from hacking and slashing from internet examples. They seems to behave a little funny at times, like showing the directory in the url, so I assume I'm not doing it right. The desired behaviour: I have multiple subdomains all...

Unknown provider: $modalInstanceProvider <- $modalInstance in Angularjs modal

angularjs,twitter-bootstrap,modal-dialog,angular-ui-bootstrap
I am using angular bootstrap ui modal which is working fine but when I try to close it using modalInstance it gives above error.Here is my code var app = angular.module('LoginModule', ['ui.bootstrap']); app.controller('LoginModal', ['$scope', '$modal', function ($scope, $modal) { $scope.animationsEnabled = true; $scope.open = function (size) { var modalInstance =...

WCF Service hosted in a Windows Service - Wrong / Expected Namespace

c#,xml,wcf,serialization,datacontractserializer
I have a WCF Service that I've installed that keeps throwing an unexpected namespace exception upon startup. The odd part is that it works just fine if I host it via IIS or in visual studio via the WCFSvcHost. I'm unable to find any namespace declaration in the designer when...

Problems with big C# list, list is inaccessible

c#,list,thread-safety
Every time I do a List.add to one list bigger than 1000, I have a chance to get (Collection was modified; enumeration operation may not execute). If I increase the size, the problem happens more often. I have a lot of threads making a cache of info, and users getting...

Regex to highlight invalid tokens

regex,regex-negation
Hi have a field were the user can enter a string with a limited set of tokens, say {token1}, {token2}. Token is a string between curly braces, no spaces allowed. I want to have the entry of the user checked with regex to invalidate when the user enters any unknown/invalid...

Spring Security AbstractAuthenticationProcessingFilter Extension Losing Instance Variable Value

java,spring,spring-security
Once again, I'm hoping I'm doing something really dumb here. :) I have an extension of AbstractAuthenticationProcessingFilter in my Spring Security implementation, and in that extension, in the attemptAuthentication method, I access the passed-in HttpServletRequest object and pull out a header value, which I store in an instance variable. I'm...

Getting Round The SubQuery Returned More Than 1 Value Error

sql-server-2008
I am trying to get a reading of time spent in class, and my query keeps producing the error of Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression....

Make jQuery act dynamically depending on the width of the window

javascript,jquery
Hello! I've been learning jQuery for a little while now and am trying to sharpen my skills by creating a responsive website. I added a navigation bar, then a big slider, and below it is the main content of the website. Right now, jQuery (as both the menu background and...

InvalidCastException in release when casting TextFormatted to ISpannable or ISpanned

c#,android,xamarin,monodroid
This question is the same but it doesn't seem to answer the question as to why this cast fails in release mode but works in debug. The Android docs specify: Return the text the TextView is displaying. If setText() was called with an argument of BufferType.SPANNABLE or BufferType.EDITABLE, you can...

Heap memory Solr and Elasticsearch

solr,elasticsearch
I'm just reading the book Mastering Apache Solr and the writer recommends to set the minimum heap size (-Xms) to 2GB and the maximum heap size (-Xmx) to 12GB. Is 2GB necessary? I just use a 512MB server (which is low, I know) for Solr and I found it already...

Undefined variable admob in PhoneGap AdMob plugin

android,ios,node.js,cordova,jquery-mobile
It's difficult for me to explain my problem because my english is not good, hope you would understand. This is my first try to make a mobile game, all done and I want to show ads by AdMob. I have tried some PhoneGap AdMob plugins such as admob-phonegap , cordova-admob-pro...

How to remove duplicate comma separate strings using awk

bash,csv,awk
I have a csv file like this: (named test2.csv) lastname,firstname,83494989,1997-05-20,2015-05-07 15:30:43,Sentence Skills 104,Sentence Skills 104,Elementary Algebra 38,Elementary Algebra 38,Sentence Skills 104,Sentence Skills 104,Elementary Algebra 38,Elementary Algebra 38, I want to remove the duplicate entries The closest I have got is the following awk command awk '{a[$0]++} END {for (i in...

Custom Observable stream of REST results from a list of links

rx-java
I am using a library which implements its own REST requests. It takes a 'permalink' and issues a REST request to fetch Content (I provide mocks in the source code for testing). I have a list of permalinks, and would like to schedule a request for each and generate a...

How to check the end of args array?

java,arrays,scala,args
I am writing a parser program in Scala that should read input using "args" and pars it. It doesn't matter I use: while(!args.isEmpty){ if (Files.exists(Paths.get(args(j)))){ Statement=Statement.concat(inputXml) Statement=Statement.concat(" ") println(j) } else{ Statement=Statement.concat(args(j)) Statement=Statement.concat(" ") println(j) } j=j+1 } or while(args.length !=0) { if (Files.exists(Paths.get(args(j)))){ Statement=Statement.concat(inputXml) Statement=Statement.concat(" ") println(j) } else{...

Importing a Youtrack 5 database into Youtrack 6

youtrack
I currently have a stand alone instance of Youtrack 6 installed from the ZIP distribution. When I try to import the database from the Youtrack 5 instance into Youtrack 6, Youtrack 6 starts up using the host and port of Youtrack 5, which is a WAR file running on Tomcat....

Delphi and sleep function

delphi,timer,sleep
I am having some issues regarding the sleep function. I have my application which executes an external command with some options: str := 'C:\BERN52\MENU\menu.exe C:\BERN52\GPS\PAN\DAILY.INP C:\GPSUSER52\WORK\MENUAUX_DAILY.INP'; WinExec(Pansichar(str), SW_Shownormal); After that when this process is finished I should kill it and continue with another things. I did the following: Sleep(60000*StrToInt(Form1.Edit11.Text)); winexec('taskkill...

Visible bind not updating after Observable change with Knockout

javascript,sorting,knockout.js
I´m creating a sortable table using Knockout. The table binding, the sorting functionality and Filtering is Working fine. However, I´d like to show a sorting icon when a specific column is active. Since the span has bind to visible property in the header array, and this property is observable, when...

Accessing nested data in JSON

jquery,json
I have some JSON data that looks like this: { "ValueDate": { "date": "2015-06-08 00:00:00", "timezone_type": 3, "timezone": "Europe/Paris" }, "JobBucket": "OPENBOOK", "Status": "Complete", "UpdateDate": { "date": "2015-06-09 03:10:11", "timezone_type": 3, "timezone": "Europe/Paris" }, I have validated it and the formatting is correct. I am trying to display this data...

OSMDroid Limit the map in North/South

android,osmdroid
I am working with the OSMDroid API and I'm wondering if there's a way to limit the map in north and south. I mean, is this possible to prevent the map from endlessly repeating itself on the Y-Axis. I found this issue on the Github's "osmdroid" project but the code...

Reloading route after .save()

ember.js,ember-data
I want to reload a route after a .save() (in controller). Currently, ember-data is changing the status in the store but whatever I tried for reloading the route didn't work. The problem is I want to reload the current route based on conversation status. For example, if I'm currently in...

Angular Formly Nested selects

angular-formly
I'm trying to achieve a series of nested SELECT with Formly. My options look like this : $scope.productsList = [{ name : 'product1', options : [ name : 'option1Product1', name : 'option2Product1' ] }, { name : 'product2', options : [ name : 'option1Product2', name : 'option2Product2' ] } ]...

Indicate end of a group

apiblueprint
In the groups example https://raw.githubusercontent.com/apiaryio/api-blueprint/master/examples/04.%20Grouping%20Resources.md it says that the end of a groups is indicated by the start of another group. Is there a way to indicate the end of a group without having to start another group? E.g. instead of # Group Messages ## My Message [/message] ### Update...

Liquibase endDelimiter usage

oracle,plsql,liquibase
Trying to run this from Liquibase: --changeset blah runOnChange:true endDelimiter:\n/\s*\n|\n/\s*$ DELETE MYTABLE; INSERT INTO MYTABLE(A,B,C) VALUES ('A', 'B', 'C'); DECLARE row_count NUMBER; BEGIN SELECT COUNT(1) INTO row_count FROM OTHERTABLE; IF (row_count = 0) THEN DELETE MYTABLE WHERE A LIKE 'BLAH:%'; END IF; END; / But getting this error: Caused by:...

Python execute JavaScript on Website [closed]

javascript,python
I need to execute a JavaScript on a website, to perform a action. In fact, to buy something on Steam. Example: I visit http://steamcommunity.com/market/listings/238460/Rammy with my Webbrowser. At the bottom of the page there are some buttons with Javascript on it. For example they're bound to:javascript:BuyMarketListing('listing',%20'428187075130762395',%20238460,%20'2',%20'41998256') How can I execute...

Writing information from SQL Server to C#

c#,sql-server
Below I have a piece of code that should be writing out columns from my database, however when I try to execute, it gives me an exception that says it can't read a column with no values, but its wrong because it should contain dates in the columns that I...

Faking Ajax Request Form for testing

java,ajax,unit-testing,playframework,playframework-2.0
In my Playframework 2.4 project I have methods like this: public static Result resetValue(int client) { String receivedName= form().bindFromRequest().get("username"); User user = User.findByName(receivedName); if( user == null ) { return badRequest("No user logged in"); } user.setValue(0); user.saveUsertoDB(); return ok("Value set to zero"); } I want to write JUnit Tests for...

a simple select input is not working properly with angular-meteor

angularjs,select,meteor,angularjs-ng-repeat,angular-meteor
this is a weird thing: using angular-meteor library put a simple select input on the page: <div id="category"> <select ng-model="selectedItem"> <option ng-repeat="p in inputCategories" value="{{p.name}}"></option> </select> </div> select itself shows up, it has the correct number of options, but the actual option text is invisible! When inspected, it shows the...

Protractor cannot find angular came from non angular site

javascript,angularjs,protractor
In protractor I search for a LinkText Login thats worked fine. I were redirect to the login site (non angular) and type in the username and pw. Clicking the submit button i came back to the first site. Now the Login Button is a Logout button. But protractor cannot see...

Statically balanced trees in Agda

tree,agda,dependent-type
I'm teaching myself about dependent types by learning Agda. Here's a type for binary trees balanced by their size. open import Data.Nat open import Data.Nat.Properties.Simple data T (A : Set) : ℕ -> Set where empty : T A 0 leaf : A -> T A 1 bal : ∀...

How to add data to table that is existing [closed]

php,mysql,sql,where
if (file_exists(TEMP.'/'."$check_dir".'/'."$endofname$test".'.jpeg')) { echo "File : $endofname$test was made <br />"; move($new_file_destination); $img_name = 'http:localhost/single4thenight/media/com_jomclassifieds/items/backpage/'."$check_dir".'/'."$endofname$test".'_1.jpeg, '; $img_title = "UPDATE iutca_jomcl_adverts SET images='$img_name' WHERE title='$title'"; if ($conn->query($img_title) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . mysqli_error($conn); } } I need to add data...

jquery ui datepicker not working with tabs

php,jquery,jquery-ui,tabs,datepicker
When a user switches tabs in the jquery ui code they can click on a button to add data to a jqgrid. The only thing that is not working is datepicker; it will launch one time and after that when switching to a new tab it will not launch again....

Flask - how to get query string parameters into the route parameters

flask,query-string,friendly-url
Im very much new to Flask, and one of the starting requirements is that i need SEO friendly urls. I have a route, say @app.route('/sales/') @app.route(/sales/<address>) def get_sales(addr): # do some magic here # render template of sales and a simple GET form that submits an address. <form action={{ url_for('get_sales')...

Where should I put routes in express.js

node.js,express
I just started to learn node.js with express 4. I have read some books and tutorials, I also cloned some sample apps from git but I still have a very basic question, which practice should I follow to write the routing(or controller)? Some people define all the routes in app.js,...

Table update based on match/nomatch

sql,oracle,join,sql-update
I have two tables t1 and t2. t1 has this structure: yearmonth account company RCV_amount_t1 t2 has this structure: yearmonth account company billing amount billing amount CM_1 billing amount CM_2 RCV_amount_t2 I want to join t2 to t1 using yearmonth, account, and company. If they match, I want to update...

Ternary operator precedence and assignment

c++,c++11,ternary-operator
I have an unusual bug in my code, where sometimes, my code will return the wrong value. I have a ternary expression in a function which may be the culprit, and it's written like this; corpusBoard[i][j] = (piece == 'o') ? 'o' : 'x'; Which should state, if piece is...

Why can't I open/write from a serial port on Android?

android,serial-port,file-permissions,android-4.4-kitkat,tty
I have written an Android app which runs on a custom kernel on Android 4.4 Kitkat device, which uses the Android Serial Port API (https://code.google.com/p/android-serialport-api/) in order to open the serial port "/dev/ttyACM0" which is the port associated with my serial device. The port has the proper "666" permissions (crw-rw-rw),...

Constant buffer is empty when passed HLSL C++

c++,directx,shader,hlsl
So I moved from this problem: Previous problem to this one :). I made 2 constant buffers in C++ which I'm passing to my HLSL Shader but when I debug and look into the buffers they are just filled with zeros except the last 3 numbers (which are -572662307). I...

Recursively pass through Json to get all values for a specific key

javascript,json
I have a json object which looks like this: var testJ = {"ROOT":{ dir : 'app', files : [ 'index.html', { dir : 'php', files: [ 'a.php', { dir : 'extras', files : [ 'a.js', 'b.js' ] } ] } ] }}; I need to extract all the files and...

will push notifications with Production-SSL certificate work when I'm still testing my app? How can I know it will work?

ios,apple-push-notifications
My push notifications are working fine with the sandbox model. I just verified that the production ssl certificate is working both with direct SSL-connection and with AWS SNS. However, my device is still producing the same push token as it produced for the sandbox, and this token is not working...

How do I, or can I use a static resource for the StringFormat on a TextBlock?

c#,wpf,xaml,string-formatting
I have a text block that is displaying the date/time. The look of the clock may be different on some controls in the application, as far as color and maybe font, but I want the date and time to have the same format. I know I can set the StringFormat...

BAD SUBSTITUTION: String comparison using array elements in bash

bash
I'm getting started with bash programming, and am stumbling through the syntax a little. The following is part of the code to play tic-tac-toe from the command line. i=0 initialGrid=('_' '_' '_' '_' '_' '_' '_' '_' '_') if [ "${ initialGrid[ $i ] }" = "_" ]; then echo...

Selecting all messages to user from conversation in one query

php,mysql
I have a "message" system for users whose data scheme looks something like this: Table: Messages - Message_id PRI AI key Message_id Message_text From_user_id Date Conversation_ID 1 'a' 1 1 2 'b' 2 1 3 'c' 5 1 4 'f' 18 2 5 'e' 1 8 Table:Conversations Conversation_id Subject 1...

How to store the file path of an indexed document in Apache Solr 5.1.0

mysql,solr
I'm trying to store the file path of an locally stored indexed document in Apache Solr so I can then update the index with metadata that is stored in a DB in MySQL. That file path is how I'm going to relate the document to its corresponding metadata I already...

How to have more than one set of ratings on the page

javascript
I'm playing around with the simple star rater and have to sets of ratings - http://codepen.io/anon/pen/WvOevd <input type="radio" name="rating" value="1"><i></i> <input type="radio" name="rating" value="2"><i></i> <input type="radio" name="rating" value="3"><i></i> <input type="radio" name="rating" value="4"><i></i> <input type="radio" name="rating" value="5"><i></i> </span> <strong class="choice">Choose a rating</strong>...

'For Each' If Statement Loop Issues

excel,vba,excel-vba,loops
*This is for Excel's VBA This is probably just a stupid logic error on my part but I've been working on this for hours and I just can't seem to figure it out: I have a webpage with two links I need to access. These two links are changing daily,...

Create a desktop application using Gmail API

python,linux,gmail-api
I have been trying to configure my conky to show the details of unread mails in my Gmail account. I have finally come up with a python script which does this task. It uses a client_secret.json file I downloaded from the google developer console. Here's the code from datetime import...

multiple dialogs inside one dfm

c++,vcl,c++builder-xe2
I'm developing an application with a lot of small, custom dialogs. These dialogs are e.g. giving choices, displaying graphs or offer additional interfaces. Mostly they require very little markup-code and have few child elements. Currently I'm using embarcadero'c XE2 RAD Studio's C++ Builder, which works with VCL and generates for...

Endless loop query: select WHERE IN (select distinct …)

mysql
I am trying to figure out if anyone else in my woltlab forum has used the same userAgent (software specs) as "noname". There are thousands of entries, and many are multiple times in the table. So I'm using DISTINCT to list all userAgents of noname. This by itself works fine....

Braintree: Creating a new subscription after the user has canceled

braintree
I am trying to decide how to handle the situation where a user has subscribed through the month, lets says 6/1 they are subscribed through until 6/31. Midway through the month they decide to cancel their subscription (6/15), but then on 6/20, they decide to restart their subscription again. How...

Rails and FullPage.js not loading correctly

jquery,ruby-on-rails,ruby,ruby-on-rails-4,fullpage.js
I'm using ZURB foundation and FullPage.js to construct a landing page. It works great if I open up the page or refresh it manually. If I redirect using a link however, my JS seems to get all messed up, until I manually refresh the page again. In my application.js file...

Coherence config default override path

java,serialization,override,weblogic12c,oracle-coherence
I've already spent more than 2 days trying to make this work without any result. The server is WebLogic 12c with embedded Coherence server. It is important to mention that I do not run Coherence in standalone mode, instead it starts automatically alongside the application server that has access to...

Django 1.8 No Reverse Match At Error

python,django
I am getting the following error message http://prntscr.com/7f3l4d everytime I click on a link in template.html. Can someone help me out with this. urls.py project urlpatterns = [ url(r'^', include('feature.urls', namespace="feature")), url(r'^admin/', include(admin.site.urls)), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urls.py app urlpatterns = [ url(r'^$', views.rock_and_feat, name='rock_and_feat'), url(r'^(?P<pk>[0-9]+)/$', views.DetailView.as_view(), name='detail'), ] views.py...

How can I hide any DOM element

jquery,dom
I want to hide any element that is clicked. For example, if <p></p> is clicked it should hide, or if <div></div> is clicked it should hide. I tried using: $(document).ready(function(){ $("*").click(function(){ $(this).hide(); }); }); However, this hides all the elements if one element is clicked. How can I achieve what...

Prevent creating Parse PFUser with just setting username

ios,objective-c,parse.com
In my app users can create an account using Parse. This works fine but I just noticed that when I sign up with a new username it is ok to not register a password. I have subclassed the PFUser and this is my sign up: // LoginViewController.m - (IBAction)signUpButtonPressed:(UIButton *)sender...

Unity3D: Adding force based on direction an object is facing

c#,unity3d,transform
I am trying to make a "worms"-like game where the player can choose the position of an object (the player can move the object around 180 degrees) , and then the force would be added to the direction the object is facing. I tried using transform.right and transform.forward, but the...

Program for approximating pi [closed]

python,python-3.x
The question asks to write a program that approximates pi using the forumla pi = 4/1 - 4/3 + 4/5 - 4/7 + ..... I have to prompt the user for the number of terms in the series, and the calculate the approximation. This is the program I tried import...

C++: Safe reading from file with std::string (&str[0]) as a buffer? [duplicate]

c++,string,allocation
This question already has an answer here: Is writing to &str[0] buffer (of a std:string) well-defined behaviour in C++11? 1 answer I have a binary file that I'm reading from. In the file at one point, there is a known number of bytes which make up a simple ASCII...

Existing Java Project into Github

java,eclipse,github
I read around to see how to load an existing project into GitHub but I later got really confused. So in the end I did the following: Created a project which uses the GitHub Repository I have (Library-Tracker) as the location. Dragged existing Java files into src folder Committed and...

MarkLogic 8 - Rest Endpoint Returning XML even though we specify JSON

json,xml,rest,upgrade,marklogic
http://localhost/v1/documents?format=json&uri=%2Fdocs%2F1234.json It looks like this URL is giving us XML instead of JSON which is causing some issues. I believe this started happening once we upgraded to Marklogic 8. You can see we are specifying json which seems right based on this: https://docs.marklogic.com/REST/GET/v1/documents How do I get this to return...

Opencv: EM algorithm training slowly

c++,algorithm,opencv
I am trying to use opencv EM algorithm library. I tried some example about EM algorithm such like this and this first, but I got the same problem in these code. It take me lots of time in EM training step. This is my testing code for image segmentation from...

Android Handling Mediaplayer

android
I have created an application that I used about 44 short audio records. For each I have created a button. But, sometimes the sound of a specific button doesn't work. How can I fix it I will post a part of the code: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first__window);...

Show plot points with the same coordinates in the same InfoWindow()

javascript,google-maps
Im using google map api to plot a list of events. Events have the coordinates to the venue where the event is held. Most venues have more then one event. How do I show all events with the same coordinates in one info window. var locations = [ ['event number...