Questions

How to run a single RSpec test?

I have the following file: ``` /spec/controllers/groups_controller_spec.rb ``` What command in terminal do I use to run just that spec and in what directory do I run the command? My gem file: ```...

How to see full query from SHOW PROCESSLIST?

When I issue `SHOW PROCESSLIST` query, only the first 100 characters of the running SQL query are returned in the info column. Is it possible to change MySQL config or issue a different kind of reques...

13 May at 11:44

Truncate a string to first n characters of a string and add three dots if any characters are removed

How can I get the first n characters of a string in PHP? What's the fastest way to trim a string to a specific number of characters, and append '...' if needed?

3 Mar at 03:36

Using C# to check if string contains a string in string array

I want to use C# to check if a string value contains a word in a string array. For example, ``` string stringToCheck = "text1text2text3"; string[] stringArray = { "text1", "someothertext", etc... };...

7 Oct at 03:16

What is the fastest way to send 100,000 HTTP requests in Python?

I am opening a file which has 100,000 URL's. I need to send an HTTP request to each URL and print the status code. I am using Python 2.6, and so far looked at the many confusing ways Python implement...

6 Feb at 20:29

How to initialize a two-dimensional array in Python?

I'm beginning python and I'm trying to use a two-dimensional list, that I initially fill up with the same variable in every place. I came up with this: ``` def initialize_twodlist(foo): twod_list...

7 Mar at 17:44

How to view files in binary from bash?

I would like to view the contents of a file in the current directory, but in binary from the command line. How can I achieve this?

5 Dec at 22:36

Lazy Method for Reading Big File in Python?

I have a very big file 4GB and when I try to read it my computer hangs. So I want to read it piece by piece and after processing each piece store the processed piece into another file and read next pi...

6 Feb at 09:25

What's the bad magic number error?

What's the "Bad magic number" ImportError in python, and how do I fix it? The only thing I can find online suggests this is caused by compiling a .py -> .pyc file and then trying to use it with the w...

5 Feb at 03:13

How to stop event propagation with inline onclick attribute?

Consider the following: ``` <div onclick="alert('you clicked the header')" class="header"> <span onclick="alert('you clicked inside the header');">something inside the header</span> </div> ``` Ho...

20 Jan at 15:12

When should I use GC.SuppressFinalize()?

In .NET, under which circumstances should I use `GC.SuppressFinalize()`? What advantage(s) does using this method give me?

Where does Console.WriteLine go in ASP.NET?

In a J2EE application (like one running in WebSphere), when I use `System.out.println()`, my text goes to standard out, which is mapped to a file by the WebSphere admin console. In an ASP.NET applica...

14 Apr at 12:59

Understanding esModuleInterop in tsconfig file

I was checking out someone `.tsconfig` file and there I spotted `--esModuleInterop` This is his `.tsconfig` file ``` { "compilerOptions": { "moduleResolution": "node", "target": "es6", "...

23 Jan at 19:48

How to specify line breaks in a multi-line flexbox layout?

Is there a way to make a line break in multiple line flexbox? For example to break after each 3rd item in [this CodePen](https://codepen.io/asvirskyi/pen/bdbLNz). ``` .container { background: toma...

22 Nov at 14:23

Global constants file in Swift

In my Objective-C projects I often use a global constants file to store things like notification names and keys for `NSUserDefaults`. It looks something like this: ``` @interface GlobalConstants : NS...

3 Jan at 08:0

What is "X-Content-Type-Options=nosniff"?

I am doing some penetration testing on my localhost with OWASP ZAP, and it keeps reporting this message: > The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'This check is...

Do you have to put Task.Run in a method to make it async?

I'm trying to understand async await in the simplest form. I want to create a very simple method that adds two numbers for the sake of this example, granted, it's no processing time at all, it's just...

21 Apr at 08:38

Removing highcharts.com credits link

I have just purchased [highcharts](http://www.highcharts.com/), but the credits link still appears on my graphs which are quite prominent on my site and it distorts the chart view. I assumed I would ...

4 Apr at 03:32

Is it possible to stop JavaScript execution?

Is it possible in some way to stop or terminate [JavaScript](http://en.wikipedia.org/wiki/JavaScript) in a way that it prevents any further JavaScript-based execution from occuring, without reloading ...

19 Aug at 17:24

How do you use "git --bare init" repository?

I need to create a central Git repository but I'm a little confused... I have created a bare repository (in my git server, machine 2) with: ``` $ mkdir test_repo $ git --bare init ``` Now I need t...

15 Nov at 20:3

What column type/length should I use for storing a Bcrypt hashed password in a Database?

I want to store a hashed password (using BCrypt) in a database. What would be a good type for this, and which would be the correct length? Are passwords hashed with BCrypt always of same length? Ex...

1 Aug at 06:18

What does "where T : class, new()" mean?

Can you please explain to me what `where T : class, new()` means in the following line of code? ``` void Add<T>(T item) where T : class, new(); ```

2 Oct at 18:53

How to get Top 5 records in SqLite?

I have tried this which did not work. ``` select top 5 * from [Table_Name] ```

29 Oct at 12:36

How can I disable ReSharper in Visual Studio and enable it again?

I installed [ReSharper](http://en.wikipedia.org/wiki/ReSharper), and it works in Visual Studio, but how can I disable it? Whenever I search in the ReSharper menu, I can't find a disable option.

Compare two MySQL databases

I'm currently developing an application using a MySQL database. The database-structure is still in flux and changes while development progresses (I change my local copy, leaving the one on the test-s...

15 Apr at 14:5