Skip to content

Instantly share code, notes, and snippets.

View sindresorhus's full-sized avatar
🌴
On vacation

Sindre Sorhus sindresorhus

🌴
On vacation
View GitHub Profile
@sindresorhus
sindresorhus / oss-contributions.md
Created April 3, 2013 21:05
Some ideas for people looking to contribute to Open Source

Yeoman

  • Documentation
    • Improve
    • Grammar
  • Tutorials
  • Answering questions on StackOverflow and the mailinglist
  • Triaging bugs
  • Fixing issues in the tracker
  • Meta bug of tasks that needs to be done: yeoman/yeoman#997
@sindresorhus
sindresorhus / console-time-wrap.js
Last active December 17, 2015 08:19
Wrap method calls in console.time
var falafel = require('falafel');
var src = 'test();';
var output = falafel(src, function (node) {
if (node.type === 'CallExpression') {
var parent = node.parent;
var funcName = node.callee.name;
parent.update('console.time(\'' + funcName + '()\');' + parent.source() + 'console.timeEnd(\'' + funcName + '()\');');
}
@sindresorhus
sindresorhus / grunt-plugin-guideline-braindump.md
Created December 28, 2013 14:00
Braindump of Grunt plugin guidelines
  • plugins should only do one thing and do them well. Your task shouldn't concat files that's why we have grunt-contrib-concat. Your task shouldn't minify CSS, that's what eg. grunt-csso is for.
  • don't bloat with uneeded options. pick sane defaults.
  • should be fully tested (this should be enforced! we really don't want people using untested plugins).
  • search the plugin list before creating one. what you want to create is probably already created and all you're doing is making it harder for users to find one.
  • don't use the prototyped colors properties like, ''.green. This will be deprecated in the future. Use a sane coloring lib like chalk instead.
  • readme:
    • should have a good intro
    • travis badge
    • have examples
  • describe all options with types and defaults
@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

//<editor-fold desc="Node Requires, gulp, etc">
var gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
csso = require('gulp-csso'),
debug = require('gulp-debug'),
footer = require('gulp-footer'),
gutil = require('gulp-util'),
gzip = require('gulp-gzip'),
@sindresorhus
sindresorhus / mysql-backup.bat
Created August 19, 2013 08:27
A bat script for doing MySQL backups I found lying around.
@echo off
:: requires US locale system setting
set dbUser=root
set dbPassword=<your-password>
set backupDir="C:\Documents and Settings\username\Desktop\backup\mysql"
set mysqldump="C:\Program Files\MySQL\MySQL Workbench 5.2 CE\mysqldump.exe"
set mysqlDataDir="C:\Documents and Settings\All Users\Application Data\MySQL\MySQL Server 5.1\data"
set zip="C:\Program Files\7-Zip\7z.exe"
@sindresorhus
sindresorhus / jquery.random.js
Created September 24, 2010 18:32
jQuery plugin - Returns a random element
$.fn.random = function() {
var rand = Math.floor( Math.random() * this.length + 1 );
return this[rand];
};
@sindresorhus
sindresorhus / jquery.hoverclasslive.js
Created August 13, 2010 09:28
jQuery plugin - Add hover in IE6 on live elements
$.fn.hoverClassLive = function(str) {
var klass = str || 'hover';
return this.live('hover', function() {
$(this).toggleClass(klass);
});
};
@sindresorhus
sindresorhus / jshint-options.md
Created July 31, 2012 14:43
JSHint options

My recommended JSHint options

JavaScript:

{
	node: true,
	browser: true,
	es5: true,
	esnext: true,

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.