Skip to content

Instantly share code, notes, and snippets.

@supersym
supersym / modules.md
Last active December 17, 2015 10:29
Some wisp snippets I probably shouldn't loose

Separation of functions through modules:

(import [read-from-string] "./reader")
(import [meta with-meta symbol? symbol keyword? keyword namespace
         unquote? unquote-splicing? quote? syntax-quote? name gensym pr-str] "./ast")
(import [empty? count list? list first second third rest cons conj
 reverse reduce vec last
@supersym
supersym / CoffeeConvert.sublime-build.md
Last active December 16, 2015 22:49
Sublime2 Literate CoffeeScript/JavaScript/Coffeecup support and settings.

Support for Literate CoffeeScript

Sublime2

These are separate sublime-build scripts for use in Sublime2. Ensure package AAAPackageDev and BuildSwitcher are installed. To create a new build script, use one of these two ways:

  • Keyboard: Ctrl + Shift + P (command dialog) then type the following 'new bui' + RETURN
  • Mouse: click on Tools » Build System » New Build System
@supersym
supersym / jade2coffee.md
Last active December 16, 2015 13:29
Learning. Regular expressions and such in multiple environments, software, languages like Python and CoffeeScript.

Notes

I am learning regex very much still so need to practice. I use gskinner's regex tool online and Sublime2. These are python regexp which is different from the JS/CS.

^(\s+) Indents

^(\s+)?\n Match the empty lines

@supersym
supersym / mike.md
Last active December 16, 2015 11:49
CoffeeScript collection of snippets, samples and short solutions for common problems or meant to inspire somehow

Credits

I found these examples scattered throughout the web and included the original links where I found them. The authors or persons who published them on these sites are referenced over there so follow the links for them or message me if you want your name explicit here.

Quick-list syntax and jargon

  • or= Or equals-operator as used e.g. hash or= {}
  • ?= Existential-operator as used e.g. hash ?= {}
  • for..of Object/hash-comprehension e.g. log val for key,val of store
  • for..in Array-comprehension e.g. log item for item in [1,2,3,4,5]

"td": "TextDown" "gh": "GitHub" "wp": "WordPress" "gd": "Google Drive" "ghg": "GitHub Gists" "gc": "Google Chrome Browser" "nix": "Unices" "win": "Windows" "mswin": "Microsoft Windows" "cli": "Command Line Interface"

@supersym
supersym / chrome.md
Last active December 11, 2015 06:18

Useful extensions and apps for in Chrome

For maintainers

  • Github Issues is a full featured desktop class front end to GitHub's issues tracker GitHub Issues is a front end to GitHub's issues tracker written in Cappuccino focused on providing a true desktop application like experience to manage multiple repositories.

This full featured issue tracker gives you a very clean and efficient desktop like workflow for managing your projects' issues.

  • Track as many repositories as you'd like
@supersym
supersym / Diagrams.md
Last active December 11, 2015 05:49 — forked from jeluard/Diagrams.md

Factory Method Pattern

P: You don’t know what kind of object you will need until runtime. S: Use the Factory Method pattern and choose the object to be generated dynamically.

Say that you need to load a file into an editor but you don’t know its format until the user chooses the file. A class using the Factory Method pattern can serve up different parsers depending on the file’s extension.

class HTMLParser
    constructor: ->

Why shouldn't I 'for ... in' to iterate an array?

Thanks to vava for answering this

First of all, never use a for in loop to enumerate over an array. Never. Use good old for(var i = 0; i<arr.length; i++).

The reason behind this is the following: each object in JavaScript has a special field called prototype. Everything you add to that field is going to be accessible on every object of that type. Suppose you want all arrays to have a cool new function called filter_0 that will filter zeroes out.

Array.prototype.filter_0 = function() {

var res = [];

printf <ARGUMENTS...>

Format and print data. Write the formatted arguments to the standard output under the control of the format.

The built-in printf (print formatted) command prints a message to the screen. You will use this command a lot in shell scripts.

Use-case example 1

Include a format code for each item you want to print. Each format code is replaced with the appropriate value when printed. Any characters in the format string that are not part of a formatting instruction are treated as printable characters.