Questions

append multiple values for one key in a dictionary

I am new to python and I have a list of years and values for each year. What I want to do is check if the year already exists in a dictionary and if it does, append the value to that list of values fo...

1 Oct at 16:28

npm check and update package if needed

We need to integrate Karma test runner into TeamCity and for that I'd like to give sys-engineers small script (powershell or whatever) that would: 1. pick up desired version number from some config ...

2 Jan at 15:56

SQL server query to get the list of columns in a table along with Data types, NOT NULL, and PRIMARY KEY constraints

I need to write a query on SQL server to get the list of columns in a particular table, its associated data types (with length) and if they are not null. And I have managed to do this much. But now ...

How do I profile a Python script?

[Project Euler](http://en.wikipedia.org/wiki/Project_Euler) and other coding contests often have a maximum time to run or people boast of how fast their particular solution runs. With Python, sometime...

How do I find the location of Python module sources?

How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux? I'm trying to look for the source of the `datetime` module in particular...

24 Feb at 22:14

How do I change the background color with JavaScript?

Anyone know a simple method to swap the background color of a webpage using JavaScript?

16 Jan at 18:44

addEventListener vs onclick

What's the difference between `addEventListener` and `onclick`? ``` var h = document.getElementById("a"); h.onclick = dothing1; h.addEventListener("click", dothing2); ``` The code above resides toget...

16 Jul at 07:15

How do I pass data to Angular routed components?

In one of my Angular 2 routes's templates () I have a button ``` <div class="button" click="routeWithData()">Pass data and route</div> ``` My is to achieve: > Button click -> route to another c...

5 Dec at 14:24

What is the equivalent of 'describe table' in SQL Server?

I have a SQL Server database and I want to know what columns and types it has. I'd prefer to do this through a query rather than using a GUI like Enterprise Manager. Is there a way to do this?

8 Nov at 15:1

How do I pass JavaScript variables to PHP?

I want to pass JavaScript variables to PHP using a hidden input in a form. But I can't get the value of `$_POST['hidden1']` into `$salarieid`. Is there something wrong? Here is the code: ``` <scrip...

2 Aug at 01:2

Is there a way to perform "if" in python's lambda?

In , I want to do: ``` f = lambda x: if x==2 print x else raise Exception() f(2) #should print "2" f(3) #should throw an exception ``` This clearly isn't the syntax. Is it possible to perform an `if`...

3 Sep at 09:33

Stop form refreshing page on submit

How would I go about preventing the page from refreshing when pressing the send button without any data in the fields? The validation is setup working fine, all fields go red but then the page is imme...

7 Feb at 15:53

Git push error pre-receive hook declined

I have run gitlabhq rails server on virtual machine, following 1-6 steps from this tutorial [https://github.com/gitlabhq/gitlab-recipes/blob/master/install/centos/README.md](https://github.com/gitlabh...

18 Feb at 12:37

Trusting all certificates using HttpClient over HTTPS

Recently posted a question regarding the `HttpClient` over Https ([found here](https://stackoverflow.com/questions/2603691/android-httpclient-and-https)). I've made some headway, but I've run into ne...

Gradient borders

I'm trying to apply a gradient to a border, I thought it was as simple as doing this: ``` border-color: -moz-linear-gradient(top, #555555, #111111); ``` But this does not work. Does anyone know wh...

20 Dec at 20:24

How do you sort a dictionary by value?

I often have to sort a dictionary (consisting of keys & values) by value. For example, I have a hash of words and respective frequencies that I want to order by frequency. There is a `SortedList` whic...

20 Feb at 04:27

Best way to do multi-row insert in Oracle?

I'm looking for a good way to perform multi-row inserts into an Oracle 9 database. The following works in MySQL but doesn't seem to be supported in Oracle. ``` INSERT INTO TMP_DIM_EXCH_RT (EXCH_WH_...

7 Dec at 00:43

How to convert Strings to and from UTF8 byte arrays in Java

In Java, I have a String and I want to encode it as a byte array (in UTF8, or some other encoding). Alternately, I have a byte array (in some known encoding) and I want to convert it into a Java Strin...

How to read embedded resource text file

How do I read an embedded resource (text file) using `StreamReader` and return it as a string? My current script uses a Windows form and textbox that allows the user to find and replace text in a tex...

9 Feb at 20:48

How do you roll back (reset) a Git repository to a particular commit?

I cloned a Git repository and then tried to roll it back to a particular commit early on in the development process. Everything that was added to the repository after that point is unimportant to me s...

29 Jun at 00:6

Get selected value/text from Select on change

``` <select onchange="test()" id="select_id"> <option value="0">-Select-</option> <option value="1">Communication</option> </select> ``` I need to get the value of the selected option in jav...

1 Nov at 18:10

How to read text file from classpath in Java?

I am trying to read a text file which is set in CLASSPATH system variable. Not a user variable. I am trying to get input stream to the file as below: Place the directory of file (`D:\myDir`) in CLASSP...

18 Dec at 15:21

Iterating each character in a string using Python

How can I over a string in Python (get each character from the string, one at a time, each time through a loop)?

29 Aug at 14:23

Where should I put <script> tags in HTML markup?

When embedding JavaScript in an HTML document, where is the proper place to put the `<script>` tags and included JavaScript? I seem to recall that you are not supposed to place these in the `<head>` s...

16 Dec at 14:19

Using pip behind a proxy with CNTLM

I am trying to use pip behind a proxy at work. One of the answers from [this post](https://stackoverflow.com/questions/9698557/how-to-use-pip-on-windows-behind-an-authenticating-proxy) suggested usin...

18 Jun at 09:16