Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env node
var capitalize = require("../main.js");
var value = process.argv[2];
console.log(capitalize.capitalize(value));
#!/usr/bin/env node
var capitalize = require("../main.js");
var value = process.argv[2];
console.log(capitalize.decapitalize(value));
{
"author": "robert kuzelj <robert@capitalize.org>",
"name": "capitalize",
"description": "capitalizes and decapitalizes a string",
"version": "0.3.0",
"homepage": "www.capitalize.org",
"repository":
{
"url": ""
},
{
...
"version": "0.3.0",
...
"bin" :
{
"cap" : "./bin/cap.js",
"ccap": "./bin/ccap.js",
"dcap": "./bin/dcap.js"
}
{
...
"version": "0.4.0",
...
"bin" :
{
"cap" : "./bin/cap.js",
"ccap": "./bin/ccap.js",
"dcap": "./bin/dcap.js",
"coffee": "./bin/dcap.js"
get = "get"
set = (value) -> value
class Grid
@new: (x, y, val = 0)->
item = new Grid x, y, val
(x, y) ->
(value) ->
if value == get
return item.grid[x][y]
class Grid
@new: (x, y = 1, dval = 0)->
item = new Grid x, y, dval
(x, y) ->
(value) ->
v = value()
if v is undefined
return item.grid[x][y]
else
item.grid[x][y] = v
@robkuz
robkuz / overengineering.coffee
Created March 5, 2012 16:22
Over engineering
# very simple, very clear. If need to be changed, changes in two places
func: (data)=>
if data.x % @TILE_SIZE == 0
@x = Math.floor(data.x / @TILE_SIZE)
if data.y % @TILE_SIZE == 0
@y = Math.floor(data.y / @TILE_SIZE)
# easier to change BUT intention not so clear anymore
# and also longer and took longer to write
func: (data)=>
@robkuz
robkuz / curried.coffee
Created April 9, 2012 06:20
curried functions
foo = (param1)->
(param2)->
param1 + param2
foo(1)(2)
@robkuz
robkuz / foobaz.coffee
Created May 18, 2012 10:30
easy adhoc package and dependency system using Coffeescripts destructuring assignment
class A
class B
# packages and their artifacts must be defined as object literals
window.foobaz = {
A
B
}