Skip to content

Instantly share code, notes, and snippets.

Eric Doughty-Papassideris ddlsmurf

Block or report user

Report or block ddlsmurf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ddlsmurf /
Created Feb 26, 2018
This is a very hastily cobbled together JSON prettifyer that doesn't bug me about input validity as long as unambiguous. Also it warns about a few validity issues (not all).
{ Transform } = require('stream')
EOL = "\n"
Utils =
spaces: (num) -> if num <= 0 then '' else (new Array(num + 1)).join(" ")
ljust: (str, len) -> str + Utils.spaces(len - str.length)
streamToString: (stream, cb) ->
len = 0
buffer = []
.on('end', -> cb(null, Buffer.concat(buffer, len)))
toString = Object::toString
hasOwnProperty = Object::hasOwnProperty
propertyIsEnumerable = Object::propertyIsEnumerable
toStringTags = date: '[object Date]'
Utils =
### @return `undefined|null|boolean|string|symbol|number|NaN|array|arguments|date|object|function` ###
type: (val) ->
switch type = typeof val
when 'undefined', 'string', 'boolean', 'symbol'
return type


Function declarations

There are two (mostly) equivalent ways to define a function:

function Add(a, b) { return a + b };

var Add = function(a, b) { return a + b };
View gist:3490e61ff090c36ec4ea
toString = Object::toString
hasOwnProperty = Object::hasOwnProperty
propertyIsEnumerable = Object::propertyIsEnumerable
### @return `undefined|null|boolean|string|symbol|number|NaN|array|arguments|date|object|function` ###
(val) ->
switch type = typeof val
when 'undefined', 'string', 'boolean', 'symbol'
return type
when 'number'
return (if Number.isNaN(val) || (val in [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY]) then 'NaN' else type)
ddlsmurf /
Created Apr 23, 2014
Simple sublime text 2 multiple cursor alignment command
import sublime, sublime_plugin, re
class AlignCursors(sublime_plugin.TextCommand):
def adjust_column_for_tabs(self, view, tab_size, region, rowcol):
line_text = view.substr(view.line(region))[:rowcol[1]]
return rowcol[1] + (line_text.count("\t") * (tab_size - 1))
def run(self, edit):
view = self.view
regions = view.sel()
right_most = 0
ddlsmurf / console output
Last active Dec 24, 2015
Example for C users of how classes and virtual lookup tables can work. Proper memory and error management left out.
View console output
basic debug on object of type 'base', data: 0xdeadbeef
basic debug on object of type 'pointer', data: 0xdeadbeef
int debug (type 'int') value: '123'
No method 'sayHi' in 'int'
string debug (type 'string') value: 'hi guys'
Howdidledidoo 'string'
View data.json
ddlsmurf / MSC.hs
Created Jul 31, 2012
MSCGen adaptation of dot plugin for gitit -
View MSC.hs
module MSC (plugin) where
-- This plugin allows you to include a diagram
-- in a page like this:
-- ~~~ {.msc name="diagram1"}
-- msc {
-- # MSC for some fictional process
-- hscale = "1";
-- a,b,c;
ddlsmurf / 0001-killed-jsonkit.patch
Created Feb 11, 2012
Moved JSONKit out and replaced with dynamic calls (wip at best)
View 0001-killed-jsonkit.patch
CouchCocoa.xcodeproj/project.pbxproj | 8 --------
REST/RESTBody.m | 16 +++++++---------
2 files changed, 7 insertions(+), 17 deletions(-)
diff --git a/CouchCocoa.xcodeproj/project.pbxproj b/CouchCocoa.xcodeproj/project.pbxproj
index 57f6218..7de3e35 100644
--- a/CouchCocoa.xcodeproj/project.pbxproj
+++ b/CouchCocoa.xcodeproj/project.pbxproj
ddlsmurf / output.txt
Created Jan 10, 2012
YAML succinct tutorial
View output.txt
# Example with basic types
  string: some text
  number: 12345
  array_of_bool: [on, off, true, false, yes, no]
  ruby symbol: :symbol
    - item one
    - item two
You can’t perform that action at this time.