What does “use strict” do in JavaScript, and what is the reasoning behind it?

What does “use strict” do in JavaScript, and what is the reasoning behind it?

Recently, I ran some of my JavaScript code through Crockford's JSLint, and it gave the following error: Problem at line 1 character 1: Missing "use strict" statement.Doing some searching, I realized that some people add "use strict"; into

Does Javascript pass by reference?

Does Javascript pass by reference?

Does Javascript pass by references or pass by values? Here is an example from Javascript: The Good Parts. I am very confused about my parameter for the rectangle function. It is actually undefined, and redefined inside the function. There a

What is dependency injection?

What is dependency injection?

There have been several questions already posted with specific questions about dependency injection, such as when to use it and what frameworks are there for it. However,What is dependency injection and when/why should or shouldn't it be us

What is the explicit promise construction antipattern and how do I avoid it?

What is the explicit promise construction antipattern and how do I avoid it?

I was writing code that does something that looks like:Using the Promise constructor:function getStuffDone(param) { return new Promise(function(resolve, reject) { myPromiseFn(param+1) .then(function(val) { resolve(val);

Laravel 5.3 Creating Models Returns “Field doesn't have a default value”

Laravel 5.3 Creating Models Returns “Field doesn't have a default value”

I'm using Laravel and Eloquent for two years and today I've decided to install a fresh Laravel 5.3 and try something with it.I used an old database schema of mine and created my models, defined fillable columns. This is what my Page model l

What is the reason behind std::chrono::duration's lack of immediate tick count manipulation?

What is the reason behind std::chrono::duration's lack of immediate tick count manipulation?

Suppose we have#include #include #include namespace Ratios { typedef std::ratio Days; }typedef std::chrono::system_clock Clock;typedef Clock::time_point TimePoint;And our main looks likeint main(int argc, char *argv[]){ // argc check lef

Best way to choose a random file from a directory

Best way to choose a random file from a directory

What is the best way to choose a random file from a directory in Python?Edit: Here is what I am doing:import osimport randomimport dircachedir = 'some/directory'filename = random.choice(dircache.listdir(dir))path = os.path.join(dir, filenam

How to extend Java annotation?

How to extend Java annotation?

In my project I use pre-defined annotation @With:@With(Secure.class)public class Test { //....The source code of @With:@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)public @interface With { Class[] value() default {};}I wa

Cannot assign method group to an implicitly-typed local variable

Cannot assign method group to an implicitly-typed local variable

I have this error "Cannot assign method group to an implicitly-typed local variable"in this codeprivate async void Button_Click_2(object sender, RoutedEventArgs e){ var frenchvoice = InstalledVoices.All.Where(voice => voice.Language.Eq

ack-grep: chars escaping

ack-grep: chars escaping

My goal is to find all "" occurrences with ack. How can I do that?ack "Doesn't work. Please tell me how can I fix escaping here? 1:Since ack uses Perl regular expressions, your problem stems from the fact that in Perl RegEx language, ? i

What's the Best Way to Add One Item to an IEnumerable?

What's the Best Way to Add One Item to an IEnumerable?

Here's how I would add one item to an IEnumerable object://Some IEnumerable objectIEnumerable arr = new string[] { "ABC", "DEF", "GHI" };//Add one itemarr = arr.Concat(new string[] { "JKL" });This is awkward. I don't see a method called so

Force break on any exception thrown in program

Force break on any exception thrown in program

When coding in C# I like not to handle exceptions because it makes it easier to figure out where and why things went wrong. However, I can't give anyone a program that doesn't handle exceptions.Can I somehow force Visual Studio to break on

Placeholder CSS not being applied in IE 11

Placeholder CSS not being applied in IE 11

I am getting some problem in applying placeholder css.I am trying to apply css (i.e. color:#898F9C;) on input-box placeholder using pseudo-class selector :-ms-input-placeholder, but it's not working in IE.Demo After some hit and try, I get

Is php 5.4 safe without Suhosin?

Is php 5.4 safe without Suhosin?

I'm currently working on developing a PHP CMF which will eventually be commercially available and I want to use traits. The problem however is that traits are a PHP 5.4 feature and apparently the popular Suhosin security patch isn't compati

Why doesn't `std::initializer_list` provide a subscript operator?

Why doesn't `std::initializer_list` provide a subscript operator?

Suppose that you are writing a function that accepts an std::initializer_list called list, and that the function requires random access to list's elements. It would be convenient to write list[i] instead of list.begin()[i]. So why doesn't s

Calling other function in the same controller?

Calling other function in the same controller?

I'm using Laravel. Here is a class I'm working on:The line:return sendRequest($uri);Renders the error:Call to undefined function sendRequest()I'm assuming it's because I'm referencing the function in the wrong manner, but I can't find any e

Image processing / super light OCR

Image processing / super light OCR

I have 55 000 image files (in both JPG and TIFF format) which are pictures from a book.The structure of each page is this: some text --- (horizontal line) --- a number some text --- (horizontal line) --- another number so

Creating reusable html for navigation bar on multiple pages

Creating reusable html for navigation bar on multiple pages

I thought it would be convenient to have reusable code, especially for the navigation bar because it will be the same across all of my pages. This way I won't have to go through each page and manually edit each one individually when a chan

mysql: efficient way for postfix-search (like '%text' aka. prefix wildcard)?

mysql: efficient way for postfix-search (like '%text' aka. prefix wildcard)?

Is there any build-in functionality in MySQL to do the above without scanning the entire table?Only solution I found is to store a mirrored version of the column I want to compare and do a like 'txet%'.I also don't see a way of getting arou

How should my business logic interact with my data layer?

How should my business logic interact with my data layer?

So I'm working on making a draft of my program.This is my plan:GUI---Business Logic---DataYou should be able to replace either GUI or the Data layer without issues.Every layer watches itself. So GUI will call methods from Business logic and

iPhone Localization - Get the phone's language code?

iPhone Localization - Get the phone's language code?

I'm localizing my iPhone app for multiple languages, and in addition to changing some of the strings I need to change some backgrounds. Is it possible to query the iPhone and get the user's language code?Thanks! 1:Take a look at NSLocal

How to create Kotlin DSL - DSL syntax Kotlin

How to create Kotlin DSL - DSL syntax Kotlin

As with anko you can write callback functions like this: alert { title = "" message = "" yesButton { toast("Yes") } noButton { toast("No") }}How can I create a nested functions like that? I tried creating it

Etymology of linux commands [closed]

Etymology of linux commands [closed]

Just for fun ... I tend to keep myself alert by looking for serendipitous puzzles throughout the day. One of the things I love about linux is the never-ending amount of cleverness it embodies, from its elegant simplicity all the way to the

Virtual Extension Methods in upcoming Java 8 release

Virtual Extension Methods in upcoming Java 8 release

When I see code snippets like interface A { void a(); void b() default { System.out.println("b"); }; void c() final { System.out.println("c"); }; }I have one question. Haven't we already got enough sh*t in Java? Why one mig

Set uiCulture automatically based on browser accept language

Set uiCulture automatically based on browser accept language

How I can set the culture of the ui automatically based on the users'browser?All I found about this is Globalize.culture("pt-BR"); But it sets pt-BR as default and I dont want set this by default! I want only set this if the user is pt-BR!H