Skip to content

Instantly share code, notes, and snippets.

@geraldalewis
geraldalewis / add_and_remove_header.coffee
Created January 2, 2011 12:47
code to add and remove HTTP request header; removed from RequestParams.
HTTPHeader addHeader: ( HTTPHeader header ) ->
_headers ||= {}
#supports multiple headers of the same name
if headers[ header.name ] then header.value = headers[ header.name ].value + ";" + header.value
headers[ header.name ] = header
header
#! make it so that if the user uses a header object with multiple values (";"), it acts accordingly
else if prev and not prev.spaced
if value is '(' and prev[0] in CALLABLE
prev[0] = 'FUNC_EXIST' if prev[0] is '?'
tag = 'CALL_START'
else if value is '[' and prev[0] in INDEXABLE
tag = 'INDEX_START'
switch prev[0]
when '?' then prev[0] = 'INDEX_SOAK' # <---- #971
when '::' then prev[0] = 'INDEX_PROTO'
@geraldalewis
geraldalewis / 1216 ?= compilation.md
Created May 10, 2011 23:42
CoffeeScript issue #1216 ?= compilation Notes

##Notes##

Update The Existential Operator in docs

###Ticket Bug###

There's a bug in the ticket -- if(a != null) a = b; should be if(a == null) a = b;

Of the two options:

@geraldalewis
geraldalewis / CoffeeScript 1216 and 1348.md
Created May 11, 2011 13:21
Production notes for issue #1216 and pull #1348

#Issue #1216 with pull #1348#

##Issue## As @satyr pointed out, the #1216 patch (pull #1348) broke some ?=:

a = 1; console.log a ?= 2

would output

var a;

@geraldalewis
geraldalewis / debug_mode_for_coffee_script.md
Created May 15, 2011 23:10
Debug mode for running .coffee scripts #558, #987

Debug mode for running .coffee scripts #558, #987

Adds a --debug option for .coffee scripts that outputs more helpful error messages (mapping compiled .js lines of code to the input .coffee file's lines).

This branch should be considered experimental at the moment -- it serves as a proof-of-concept and to expose additional issues with adding debugging support to CoffeeScript

Current output:

TypeError: string is not a function

@geraldalewis hello.
adsf'
asdf
@geraldalewis
geraldalewis / 1002_patches.diff
Created July 25, 2011 16:32
1002_identical_params..1002_identical_params_revised
diff --git a/src/nodes.coffee b/src/nodes.coffee
index 1697c44..cc382d7 100644
--- a/src/nodes.coffee
+++ b/src/nodes.coffee
@@ -1076,19 +1076,23 @@ exports.Code = class Code extends Base
o.scope = new Scope o.scope, @body, this
o.scope.shared = del o, 'sharedScope'
o.indent += TAB
- o.uniqs = {}
delete o.bare
@geraldalewis
geraldalewis / gist:1142542
Created August 12, 2011 17:42
Full diff of src/ for patch #1590 for issue #1234
diff --git a/src/grammar.coffee b/src/grammar.coffee
index e57ab39..035e168 100644
--- a/src/grammar.coffee
+++ b/src/grammar.coffee
@@ -217,7 +217,7 @@ grammar =
# Variables and properties that can be assigned to.
SimpleAssignable: [
o 'Identifier', -> new Value $1
- o 'Value Accessor', -> $1.push $2
+ o 'Value Accessor', -> $1.add $2
@geraldalewis
geraldalewis / gist:1608379
Created January 13, 2012 19:55
default arguments order
# non-default params = true arity;
# args <= arity: apply args to non-defaults first, in order
# args > arity: apply args in order
f = (a=0,b,c=2) ->
f() # a = 0 b = undefined c = 2
f(1) # a = 0 b = 1 c = 2
f(1,2) # a = 1 b = 2 c = 2