Skip to content

Instantly share code, notes, and snippets.

@Rob-ot
Rob-ot / prefixedCalc.js
Created August 20, 2012 01:23
Detect which prefixed css calc to use via javascript
// public domain, use it for whatever
// returns "calc", "-moz-calc", etc
// (no -ms because they already support it non-prefixed)
function prefixedCalc () {
var prefixes = ["","-webkit-","-moz-","-o-"], el
for (var i = 0; i < prefixes.length; i++) {
el = document.createElement('div')
el.style.cssText = "width:" + prefixes[i] + "calc(9px)"
if (el.style.length) return prefixes[i] + "calc"
@Rob-ot
Rob-ot / fast_switch.py
Created September 12, 2012 16:19
Sublime plugin for fast file switching
# Quickly switch between files with the same name but a different extension
# add a shortcut to your user keymap file
# { "keys": ["super+alt+enter"], "command": "fast_switch" }
import sublime, sublime_plugin, os.path
def findfolder (file, folders):
for folder in folders:
if file.find(folder) == 0:
return folder
@Rob-ot
Rob-ot / unused.coffee
Created November 30, 2012 02:19
require js unused require finder
#!/usr/bin/env coffee
# A quick and dirty script to find non-required files when using requirejs
# r.js outputs the required file names so we just parse that and diff it with the files on disk
# npm install -g coffee-script
# npm install file path underscore
# then
# run this like this: ./unused.coffee grunt --no-color requirejs:prod
@Rob-ot
Rob-ot / jquery.offsets.coffee
Last active October 13, 2015 09:48
jquery.offsets.coffee
# jquery.offsets.coffee
# Rob Middleton - MIT License
define (require) ->
$ = require 'jquery'
cssObjectAdd = (object, left, top) ->
object.left += left
@Rob-ot
Rob-ot / gist:4464726
Created January 6, 2013 01:45
Override part of nib (http://visionmedia.github.com/nib/) that sets outline:0 in the reset.
// override the default reset-box-model because it sets outline: 0 which is naughty
reset-box-model() {
margin: 0
padding: 0
border: 0
}
global-reset()
reset-html5()
@Rob-ot
Rob-ot / commonerror.md
Last active December 14, 2015 00:29
An idea for standard errors in Node.js

The idea is that we could have standard error types that are not tied to anything.

These errors can be used thought the app including external libraries.

Specific errors types can be handled easily to achieve different behavior.

HTTP middleware would be included to easily translate error types into relevent HTTP status codes.

Some error type ideas: InvalidParameter(s) = HTTP 400

@Rob-ot
Rob-ot / gist:5011770
Created February 22, 2013 08:33
Why are you scared of change?
Here are some of the reasons I am scared of change. Maybe you can relate:
1. I am scared of change because I am too lazy to try something new.
2. I am scared of change because I am afraid I am being taken advantage of.
3. I am scared of change because I may waste resources trying something new that is not very good.
4. I don't want to change and I don't want to share why because I am afraid I may be talked into changing.
@Rob-ot
Rob-ot / gist:5127588
Last active December 14, 2015 18:09
Internet Achievements

I have been noticing an emergence on the Internet lately. There are certain things on my various internet profiles like reddit and youtube that show that "I was there" when some internet event happen. For example I am still subscribed to this youtube channel https://www.youtube.com/user/cadiesingularity which was part of Googles 2009 April fools joke, this gem shows that I participated in the "2009 internet April fools day". Another is this tweet I retweeted a long time ago, https://twitter.com/Wolfire/status/13804312082 a small piece of history when the first Humble Indie Bundle hit $1 million, I was there for that. Another example is the comments on reddit I made about SOPA, that is now part of history. These "Internet Achievements" are fun to look at and remember back when those things happen, and are fun to show off too. It would be cool to explore this concept in with a website that records these events.

@Rob-ot
Rob-ot / example
Last active December 17, 2015 11:59
repl.coffee!?
rob@rob-desktop:~/Projects/repl$ coffee repl.coffee
rob@rob-desktop:~/Projects/repl$ ls()
node_modules,package.json,repl.coffee
rob@rob-desktop:~/Projects/repl$ cd "node_modules"
/home/rob/Projects/repl/node_modules
rob@rob-desktop:~/Projects/repl/node_modules$ ls()
.bin,coffee-script
rob@rob-desktop:~/Projects/repl/node_modules$ cd ".."
/home/rob/Projects/repl
rob@rob-desktop:~/Projects/repl$ ls()
Hypothesis: Success is a curse for failure
Someone who succeeds the first time doesn't understand exactly why. They know everything they did combined was good but they don't understand why.
Someone who fails many times will eventually completely understand what works and what doesn't and every little piece that works and doesn't.
Someone that just keeps doing the same thing because it worked for them in the past is doomed to fail because they stop learning from mistakes.
In order to succeed we must fail.