Skip to content

Instantly share code, notes, and snippets.

@twolfson
twolfson / index.md
Last active February 9, 2017 09:03
Good ideas that I will never get around to

npm link for Windows

  • grunt task that watches over node_modules directory in a repo and copies the directory on change
    • Could be also be done with nodemon or something else

SkyDB

CSS as a queue

@twolfson
twolfson / .gitignore
Created November 29, 2012 08:12
Pretty print HTML but not JS test
/node_modules
@twolfson
twolfson / index.cmd
Created December 3, 2012 21:55
Sexy Windows prompt
REM Large portion from http://www.timespace.org/2006/09/20/custom-windows-cmd-prompt/
REM TODO: Text colors
REM TODO: Git branch conditionals
set PROMPT=%USERNAME% at %COMPUTERNAME% in $P $_$$
@twolfson
twolfson / humanize.intword.js
Created December 23, 2012 23:12
Convert numbers to their short yet semantic equivalent 100 -> 100, 1200 -> 1.2k, 2589000 -> 2.5m
// Modification of https://github.com/milanvrekic/JS-humanize/blob/master/humanize.js
/*!
intword
Converts a large integer to a friendly text representation. Works best for numbers over 1 million.
100 -> 100
1200 -> 1.2k
2589000 -> 2.5m
*/
function sliceToFirstDecimal(number) {
@twolfson
twolfson / index.jade.js
Last active December 10, 2015 16:59
View concept -- because templates and views are the same.
// THIS FILE IS A JADE FILE -- THE EXTENSION IS TO FORCE LANGUAGE INTERPRETATION
// Set up of dependencies and bindings
{
// // Specify any dependencies (e.g. partials must be defined)
// 'require': ['mvc!v/nav!v/main'],
// Backbone style event bindings -- INSIDE the view/template markup
// I like this because it is so fool-proof and quite portable
'events': {
'submit .validate-form': 'submit',
'click .submitBtn': 'submit'
@twolfson
twolfson / console.js
Last active December 10, 2015 23:08
Quick console for debugging inside of IE7 VM
function Console() {
// Create a div and textarea for the console
var div = document.createElement('div'),
output = document.createElement('div'),
textarea = document.createElement('textarea'),
button = document.createElement('button'),
that = this;
// Style the div
div.style.cssText = 'position: fixed; top: 0; left: 0; background: white; border: 1px solid black; z-index: 10000;';
@twolfson
twolfson / grunt.js
Last active January 5, 2016 21:07
Download and unzip Twitter Bootstrap in one fell swoop with grunt
module.exports = function (grunt) {
// Initial configuration
grunt.initConfig({
// Download external resources
curl: {
// Twitter Bootstrap
bootstrap: {
src: 'http://twitter.github.com/bootstrap/assets/bootstrap.zip',
dest: 'tmp/bootstrap.zip'
}
@twolfson
twolfson / README.md
Created January 18, 2013 12:17
Ideal Git Workflow
@twolfson
twolfson / README.md
Created January 18, 2013 12:47
Thoughts from 07/15/12 on partials (much has changed since then)

Post

Improving partials (inspired by Jade’s mixins) [07/15] -- Inline’d partials as functions is what we really want: <%= Builder(‘partialView’, app) %> The current setup is too watered down to have any real power. Unfortunately, if we want to use Jade mixins globally, they must be defined globally as such which kills the ability for segmentation and re-use in other parts (a rose by any other name). Otherwise, it is local which is the same as our current state. So fucking simple yet so fucking powerful and easy to miss.

Comment #1

Making this happen: In every Builder invocation, include a new object property:

{
 // I have decided to rename Builder to partial for semantics
@twolfson
twolfson / index.js
Created January 20, 2013 02:11
List out every JSHint option on as JSON
// You must be on http://www.jshint.org/docs/
var nameElts = $$('.name'),
names = nameElts.map(function (elt) {
return elt.textContent || elt.innerText;
}),
nameProps = names.map(function (name) {
return ' ' + name + ': false';
}),
retStr = '{\n' + nameProps.join(',\n') + '\n}';
console.log(retStr);