Skip to content

Instantly share code, notes, and snippets.

View guilsa's full-sized avatar
👋
@ Looking for projects

Guilherme Sa guilsa

👋
@ Looking for projects
View GitHub Profile
@guilsa
guilsa / week0.md
Last active August 29, 2015 14:14 — forked from bdougie/week0.md
@guilsa
guilsa / js-console-log.txt
Created March 27, 2015 16:08
console.log key binding for Sublime
[
{ "keys": ["super+shift+l"],
"command": "insert_snippet",
"args": {
"contents": "console.log(${1:}$SELECTION);${0}"
}
}
]
@guilsa
guilsa / entity-boundary-interactor-projects.md
Last active October 22, 2015 00:26
Resources on Entity, Boundary and Interactor (EBI) an architectural design pattern isolation from frameworks
@guilsa
guilsa / es6-on-terminal.md
Last active April 7, 2016 19:06
Setting up ES6 on terminal to test stuff

Add .gitignore

echo '*.env
*.DS_Store

*npm-debug.log

# compiled output
dist
@guilsa
guilsa / infinitely_nested_flatten_es6.js
Created August 20, 2016 21:59
Flatten infinitely nested array
const a = [[1,2,[3]],4]
Array.prototype.flatten = (array) => {
const newArray = []
const flattenHelper = (array) => {
array.map(i => {
Array.isArray(i) ? flattenHelper(i) : newArray.push(i)
})
}
flattenHelper(a)
@guilsa
guilsa / substring_from_string.js
Created August 23, 2016 21:44
Get a substring from a string in JavaScript
// to be used with 'expect' library <script src="https://npmcdn.com/expect@1.13.0/umd/expect.min.js"></script>
// credits: https://egghead.io/lessons/javascript-4-common-ways-to-get-a-substring-from-a-string-in-javaascript
console.clear()
var input = 'The quick brown fox jumps over the lazy dog'
var expected = 'The fox jumps over dog'
// split ... array stuff ... join
@guilsa
guilsa / json_parse.js
Created August 23, 2016 22:04
JSON.parse API Example
// requires the 'expected' library <script src="https://npmcdn.com/expect@1.15.2/umd/expect.min.js"></script>
var input = '[{"id":1,"title":"Gone with the Wind","publishDate":"1936-06-10T00:00:00.000Z","related":[80,3]},{"id":2,"title":"Freelancer","publishDate":"2015-08-11T00:00:00.000Z","related":[45,89]},{"id":3,"title":"A Christmas Carol","publishDate":"1843-12-19T00:00:00.000Z","related":[20,33]},{"id":4,"title":"The Cat in the Hat","publishDate":"1957-03-12T00:00:00.000Z","related":[50,10]}]'
testBasicAPI()
testReviverArgument()
console.log('Tests passed')
// function declarations
@guilsa
guilsa / navigate_json.js
Created August 23, 2016 22:23
Using Array Reduce() To Navigate An Object Graph In JavaScript
// head over to https://vimeo.com/179308538 for a video how to
@guilsa
guilsa / 0_readme.md
Last active February 14, 2024 10:24
Steps for implementing Bower, RequireJS and Knockout

##Purpose

To learn basic configuration of RequireJS and require.config.

##Why RequireJS

RequireJS is useful for building modularized enterprise JavaScript applications.

  • we no longer have to control file loading, RequireJS does it elegantly for us
  • creation of modules (even though ES6 provides module loading, RequireJS came prior and is very stable)
@guilsa
guilsa / untitled
Created October 16, 2016 06:49
Opening a CSV file
import csv
infile = open('sample.data','r') #the r means open for reading, use w when writing
reader = csv.reader(infile)
for line in reader:
print line
infile.close()