Skip to content

Instantly share code, notes, and snippets.

View gr2m's full-sized avatar
🧚
automatin'

Gregor Martynus gr2m

🧚
automatin'
View GitHub Profile
@gr2m
gr2m / html_slicing_overlay.css
Created September 6, 2011 21:40
best HTML slicing helper ever: show the reference design as non-blocking overlay. Webkit-Browser only.
/* =============================================================================
show the reference design as non-blocking overlay.
NOTE: Webkit-Browser only. Reference image needs to be flipped as
»box-reflect: right« & transform: scaleX(-1) do not play together.
========================================================================== */
body:after {
content: '';
display: block;
@gr2m
gr2m / drop_databases.js
Created October 29, 2011 16:24
couchDB: delete multiple DBs at once using jquery.couch.js
// this works perfectly within Futon
regex_str = prompt('Databases that match the following pattern will be deleted ("*" for all)')
$.couch.allDbs({success:function(dbs){
dbs.forEach( function(db) {
if (RegExp(regex_str).test(db)) {
$.couch.db(db).drop()
}
})
}});
@gr2m
gr2m / chrome_15_mac.js
Created November 18, 2011 12:56
JavaScript stack traces by different browsers (using stacktracejs.org as fallback)
[
"TypeError: number is not a function",
" at Number.CALL_NON_FUNCTION (native)",
" at Object.generateBacktrace (http://couch.minutes.local:4000/vendor/hoptoad.js:101:11)",
" at Object.generateXML (http://couch.minutes.local:4000/vendor/hoptoad.js:59:29)",
" at Object.notify (http://couch.minutes.local:4000/vendor/hoptoad.js:9:34)",
" at Meeting.attach_behaviors (http://couch.minutes.local:4000/javascripts/controllers/meetings/show.js:135:17)",
" at Meeting.render (http://couch.minutes.local:4000/javascripts/controllers/application.js:57:12)",
" at Meeting.initialize (http://couch.minutes.local:4000/javascripts/controllers/meetings/show.js:128:19)",
" at Meeting.<anonymous> (http://couch.minutes.local:4000/vendor/backbone.js:901:21)",
@gr2m
gr2m / backbone_events_debounce.coffee
Created November 25, 2011 15:07
Extend `Backbone.Events` with a `debounce` method.
# works exactly like `.bind()`, with the difference that it gets executed with a delay.
# Each time the event gets triggered again, the delay gets reset.
#
# based on: http://benalman.com/projects/jquery-throttle-debounce-plugin/
#
# example:
#
# car = new Backbone.Model
# bind_triggered = debounce_triggered = 0
#
@gr2m
gr2m / package.json
Created February 1, 2012 09:28 — forked from tissak/package.json
Handlebars support in Spine
{
"name": "app",
"version": "0.0.1",
"dependencies": {
"serveup": "~0.0.2",
"hem": "~0.1.6",
"es5-shimify": "~0.0.1",
"json2ify": "~0.0.1",
"jqueryify": "~0.0.1",
"spine": "~1.0.5",
@gr2m
gr2m / gist:2046802
Created March 15, 2012 20:47
remove redis keys based on their expiration time
# remove all keys that will expire in less than 1 hour
redis-cli keys "*" | while read LINE ; do TTL=`redis-cli ttl $LINE`; if [ $TTL -le 3600 ]; then echo "Del $LINE"; RES=`redis-cli del $LINE`; fi; done;
@gr2m
gr2m / imagine.js
Created March 18, 2012 13:29
Imagine ...
// imagine ...
app.email.send({
to : 'joey@example.com',
subject : 'Email Attachments',
body : {
text: 'Find the screenshot attached',
html: "This is how we do it:\n"
+ "{{ attachments['screenshot.png'] }}"
},
@gr2m
gr2m / jasmine.promise-matchers.coffee
Created March 25, 2012 06:21
Jasmine Promise Matchers
jasmine.Matchers.prototype.toBePromise = ->
this.actual.done && !this.actual.resolve
jasmine.Matchers.prototype.toBeRejected = -> this.actual.isRejected()
jasmine.Matchers.prototype.toBeResolved = -> this.actual.isResolved()
jasmine.Matchers.prototype.toBeResolvedWith = ->
expectedArgs = jasmine.util.argsToArray(arguments);
unless this.actual.done
throw new Error('Expected a promise, but got ' + jasmine.pp(this.actual) + '.');
@gr2m
gr2m / run_jasmine_tests.cmd
Created April 20, 2012 15:46
Run jasmine.js tests from your console
# 1. install www.phantomjs.org
# 2. set 'spec/specRunner.coffee' to where you put the phantom_specRunner.coffee file
# 3. set 'spec/specRunner.html' to where the jasmine html test page is located
$ phantomjs spec/specRunner.coffee spec/specRunner.html
@gr2m
gr2m / wikipedia_log_types_and_actions.txt
Created June 10, 2012 17:35
Wikipedia log actions grouped by types
abusefilter
modify
Modify an abusefilter entry. Made by Abusefilter extension.
block
block
unblock
reblock