Most Popular

1500 questions
2311
votes
17 answers

What's the difference between SCSS and Sass?

From what I've been reading, Sass is a language that makes CSS more powerful with variable and math support. What's the difference with SCSS? Is it supposed to be the same language? Similar? Different?
bbonamin
  • 28,632
  • 7
  • 39
  • 49
2303
votes
39 answers

$(document).ready equivalent without jQuery

I have a script that uses $(document).ready, but it doesn't use anything else from jQuery. I'd like to lighten it up by removing the jQuery dependency. How can I implement my own $(document).ready functionality without using jQuery? I know that …
FlySwat
  • 166,742
  • 71
  • 243
  • 309
2302
votes
12 answers

Should 'using' directives be inside or outside the namespace?

I have been running StyleCop over some C# code, and it keeps reporting that my using directives should be inside the namespace. Is there a technical reason for putting the using directives inside instead of outside the namespace?
benPearce
  • 36,402
  • 14
  • 63
  • 95
2299
votes
24 answers

What are MVP and MVC and what is the difference?

When looking beyond the RAD (drag-drop and configure) way of building user interfaces that many tools encourage you are likely to come across three design patterns called Model-View-Controller, Model-View-Presenter and Model-View-ViewModel. My…
2296
votes
51 answers

Vertically align text to top within a UILabel

I have a UILabel with space for two lines of text. Sometimes, when the text is too short, this text is displayed in the vertical center of the label. How do I vertically align the text to always be at the top of the UILabel?
Stefan
  • 28,442
  • 15
  • 63
  • 76
2293
votes
43 answers

"implements Runnable" vs "extends Thread" in Java

From what time I've spent with threads in Java, I've found these two ways to write threads: With implements Runnable: public class MyRunnable implements Runnable { public void run() { //Code } } //Started with a "new Thread(new…
user65374
  • 23,589
  • 4
  • 18
  • 7
2287
votes
20 answers

Branch from a previous commit using Git

If I have n commits, how can I branch from the n-3 commit? I can see the hash of every commit.
dole doug
  • 31,300
  • 20
  • 64
  • 85
2284
votes
56 answers

JavaScript equivalent to printf/String.Format

I'm looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .NET). My basic requirement is a thousand separator format for numbers for now, but something that handles lots of…
Chris S
  • 63,624
  • 49
  • 218
  • 238
2278
votes
30 answers

Generate random number between two numbers in JavaScript

Is there a way to generate a random number in a specified range with JavaScript ? For example: a specified range from 1 to 6 were the random number could be either 1, 2, 3, 4, 5, or 6.
Mirgorod
  • 29,263
  • 18
  • 50
  • 63
2278
votes
66 answers

How to format numbers as currency strings

I would like to format a price in JavaScript. I'd like a function which takes a float as an argument and returns a string formatted like this: "$ 2,500.00" What's the best way to do this?
Daniel Magliola
  • 29,269
  • 60
  • 159
  • 239
2278
votes
21 answers

Easy way to pull latest of all git submodules

We're using git submodules to manage a couple of large projects that have dependencies on many other libraries we've developed. Each library is a separate repo brought into the dependent project as a submodule. During development, we often want to…
Brad Robinson
  • 40,427
  • 18
  • 57
  • 86
2276
votes
27 answers

Make .gitignore ignore everything except a few files

I understand that a .gitignore file cloaks specified files from Git's version control. I have a project (LaTeX) that generates lots of extra files (.auth, .dvi, .pdf, logs, etc) as it runs, but I don't want those to be tracked. I'm aware that I…
Andrew
  • 33,526
  • 12
  • 62
  • 92
2269
votes
31 answers

Iterate through object properties

var obj = { name: "Simon", age: "20", clothing: { style: "simple", hipster: false } } for(var propt in obj){ console.log(propt + ': ' + obj[propt]); } How does the variable propt represent the…
Rafay
  • 23,065
  • 4
  • 19
  • 27
2268
votes
18 answers

Showing which files have changed between two revisions

I want to merge two branches that have been separated for a while and wanted to know which files have been modified. Came across this link: http://linux.yyz.us/git-howto.html which was quite useful. The tools to compare branches I've come across…
johannix
  • 28,368
  • 14
  • 38
  • 41
2268
votes
25 answers

How to print without a newline or space

Example in C: for (int i = 0; i < 4; i++) printf("."); Output: .... In Python: >>> for i in range(4): print('.') . . . . >>> print('.', '.', '.', '.') . . . . In Python, print will add a \n or space. How can I avoid that? I'd like to know how…
Andrea Ambu
  • 36,488
  • 14
  • 52
  • 76