Skip to content

Instantly share code, notes, and snippets.

View mgutz's full-sized avatar

Mario Gutierrez mgutz

View GitHub Profile
Get scope of current file
```
atom.workspace.getActiveEditor().getGrammar().scopeName
```
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :login, :null => false # optional, you can use email instead, or both
t.string :email, :null => false # optional, you can use login instead, or both
t.string :crypted_password, :null => false # optional, see below
t.string :password_salt, :null => false # optional, but highly recommended
t.string :persistence_token, :null => false # required
t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>test.rb</title>
<link rel="stylesheet" href="http://github.com/jashkenas/docco/raw/0.3.0/resources/docco.css">
</head>
<body>
<div id='container'>
<div id="background"></div>
# get rid of these parens?
define('List').
oid('_id').
string('title').
string('description')
@mgutz
mgutz / gist:766621
Created January 5, 2011 17:22
sample javascript configuration
// define all common settings here
exports.common = {
storage: {
host: 'localhost',
database: 'server_dev',
user: 'qirogami_user',
password: 'password'
}
};
assert.throws(
function() {
throw new Error("Wrong value");
},
Error
);
assert = require('assert')
class MyError
constructor: (@message, @name='bar') -> #nop
try
throw new Error('baz')
throw new MyError('foo')
catch err
console.log err.message
var async = require('async');
var assert = require('assert');
engines = ['one', 'two', 'three'];
async.filter(engines, function(item, callBack){
callBack(item != 'two');
}, function(results){
assert.deepEqual(results, ['one', 'three']);
# using named functions
doSomething = (done) ->
mainWindow.menu "File", onFile
onFile = (er, file) ->
return cb(er) if er
file.openMenu onMenu
onMenu = (er, menu) ->
return er if er
@mgutz
mgutz / gist:802424
Created January 30, 2011 01:54
jquery-tmpl slow compared to string substitution
head.ready ->
# create 10,000 messages
s = ''
messages = []
for i in [0...10000]
messages.push from: 'me', text: "blah blah"