Skip to content

Instantly share code, notes, and snippets.

View sindresorhus's full-sized avatar

Sindre Sorhus sindresorhus

View GitHub Profile
@sindresorhus
sindresorhus / git-dirty-checks.md
Created October 16, 2012 11:20
Benchmark results of the fastest way to check if a git branch is dirty

Tested against the WebKit git repo by entering the repo with 1 file dirty.


git diff --quiet --ignore-submodules HEAD # Will tell if there are any uncomitted changes, staged or not.
0.6 sec

git diff-index --quiet HEAD # Only tracked
2 sec

@sindresorhus
sindresorhus / more-mute-regex.md
Created October 18, 2012 08:14 — forked from jimmynotjim/more-mute-regex.md
Tweetbot can use regular expressions to mute tweets in your timeline and mentions.

##Simply annoying Tweets

Annoyingly extended words (4+ of the same letter in a phrase): OOOOHHHHMMMMYYYYGGGGOOOODDDD

([a-z])/1{4}

Tweet w/ just a single hashtag: #omgthissucks

^ *#[^ ]+$
@sindresorhus
sindresorhus / compass-task.md
Created October 18, 2012 15:46
grunt-contrib-compass task - feedback wanted

Compass task options - feedback wanted

Need some feedback on how to handle the Compass options.

The problem is that Compass doesn't expose all it's options through the CLI. CLI parameters aren't even documented. This has been a problem for us in Yeoman, since we need an option only available through their config.rb config file.

The idea is to drop the CLI parameters and dynamically create a temp file that we feed into compass from the options specified in the gruntfile.

Currently compass options looks like this:

@sindresorhus
sindresorhus / grunt-contrib task proposal.md
Created October 24, 2012 19:49
grunt-contrib task proposal

grunt-contrib task proposal

We intend extract the tasks included in Yeoman to make the project more modular and be a good internet citizen. We've already done so with the Compass task.

I've added some tasks that might be fitted for grunt-contrib.

grunt-contrib-img

Optimizing images is something most projects need. I think it's important grunt-contrib has a simple and opinionated task for this.

@sindresorhus
sindresorhus / yeoman-future-proposal.md
Created October 27, 2012 16:02
Yeoman.future proposal rev2

Yeoman.future proposal rev2

tl;dr

  • Yeoman will continue to offer a single catch-all command for our workflow (including building with Grunt and package management with Bower)

  • We will make it very explicit about the tools we use and ensure it's easy for developers to find documentation/support for them (e.g from homepage)

  • We will also do our best to implement Yeoman as an even thinner wrapper around these tools, so moving to using Grunt alone is next to no effort

@sindresorhus
sindresorhus / codestyle.md
Last active September 26, 2023 07:45
My preferred code style.

Code Style

  • Tab indentation
  • Single-quotes
  • Semicolon
  • Strict mode
  • No trailing whitespace
  • Multiple variable statements
  • Space after keywords and between arguments and operators
  • Return early
@sindresorhus
sindresorhus / github-email.sh
Created January 11, 2013 17:46
Magically retrieves a GitHub users email even though it's not publicly shown
#!/bin/bash
# Created by Sindre Sorhus
# Magically retrieves a GitHub users email even though it's not publicly shown
[ "$1" = "" ] && echo "usage: $0 <GitHub username> [<repo>]" && exit 1
[ "$2" = "" ] && repo=`curl "https://api.github.com/users/$1/repos?type=owner&sort=updated" -s | sed -En 's|"name": "(.+)",|\1|p' | tr -d ' ' | head -n 1` || repo=$2
curl "https://api.github.com/repos/$1/$repo/commits" -s | sed -En 's|"(email\|name)": "(.+)",?|\2|p' | tr -s ' ' | paste - - | sort -u -k 1,1
@sindresorhus
sindresorhus / ios-clear-btn.css
Created January 22, 2013 13:54
Recreation of the native iOS textfield clear button in a data uri. *Should be identical, but is not the original*
.clear-btn {
width: 19px;
height: 19px;
background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACYAAAAmCAMAAACf4xmcAAAAMFBMVEWysrKysrKysrKysrKysrKysrKysrKysrKysrKysrL////39/fh4eG9vb23t7eysrKQDTJbAAAACnRSTlMBKlNxqbO70e7739UFWQAAAMFJREFUeNqNlMsOxSAIREs1AbVe/v9v78JMSn0kMytJTzqIwPWRpKxWimlOcp2U1IM07SHzSbaCor6RTta3+VZ2f6jiB5WboSIncNzKkB+yP0gHlRD/cJjCURdYPrX1F+qtPrCNP+u1Dg5UrYhSzKyBA9VCdhJtwOEICTzjx0jBNfvCLZRnpBa5SCE584WLFEpSfMOBggqJkabkFciCkOUlH4t7erKRuLYkm5wbGXIAuXHmlgO3asjFxa9BfqmSK/oPfl489V95hyMAAAAASUVORK5CYII=');
background-size: 100%;
cursor: pointer;
}

Strict Mode: The Summary!

Identifiers (variables, functions) cannot be named any of these: "implements", "interface", "let", "package", "private", "protected", "public", "static", and "yield"

OctalLiterals are not allowed.

@sindresorhus
sindresorhus / att.js
Created February 3, 2013 23:53
Better (IMHO) example version of the att.js api.
var att = new Att('Access token');
att.on('ready', function () {
att.activeCall = att.phone.dial('1-800-444-4444');
});
att.phone.on('incoming-call', function (call) {
att.activeCall = call;
call.answer();
});