This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var xhr = new XMLHttpRequest(); | |
xhr.open('GET', 'http://corstest.pbojinov.c9.io/?feed=rss2'); | |
xhr.onreadystatechange = function () { | |
if (this.status == 200 && this.readyState == 4) { | |
console.log('response: ' + this.responseText); | |
} | |
}; | |
xhr.send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/) * http://cssreset.com */html, body, div, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del, dfn, em, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,b, u, i, center,dl, dt, dd, ol, ul, li,fieldset, form, label, legend,table, caption, tbody, tfoot, thead, tr, th, td,article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary,time, mark, audio, video { margin: 0; padding: 0; border: 0; font-size: 100%; font: inherit; vertical-align: baseline;}/* HTML5 display-role reset for older browsers */article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block;}body { line-height: 1;}ol, ul { list-style: none;}blockquote, q { quotes: none;}blockquote:before, blockquote:after,q:before, q:after { content: ''; content: none;}table { border-collapse: co |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#aliases | |
alias ..="cd .." | |
alias home="cd /Users/petar" | |
alias profile="cd /Users/petar; subl .bash_profile" | |
#internal ip | |
alias ip="ifconfig" | |
alias ip0="ipconfig getifaddr en0" #usually wifi | |
#external ip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hyphen = "-".charCodeAt(0); //45 | |
var dash = "–".charCodeAt(0); //8211 | |
console.log(hyphen, dash); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: | |
JavaScript.load("/javascripts/something.js"); | |
// With callback (that’s the good thing): | |
JavaScript.load("http://www.someawesomedomain.com/api.js", function() { | |
API.use(); // or whatever api.js provides ... | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myRevealingModule = function () { | |
var privateCounter = 0; | |
function privateFunction() { | |
privateCounter++; | |
} | |
function publicFunction() { | |
publicIncrement(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Replace single instance, case sensitive | |
*/ | |
var sentence = "Hello my name is petar petar" | |
var findTilda = /petar/; | |
sentence = sentence.replace(findTilda, '&'); | |
alert(sentence); //Hello my name is & petar | |
/** | |
* Replace all instances, case sensitive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Concat | |
*/ | |
var mergeTo = [4,5,6], | |
mergeFrom = [7,8,9]; | |
mergeTo = Array.prototype.concat(mergeTo, mergeFrom); | |
mergeTo; // is: [4, 5, 6, 7, 8, 9] | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function make_image_dir () { | |
TARGET_DIR=$1 | |
if [ ! -d "${TARGET_DIR}" ]; then | |
mkdir "${TARGET_DIR}" | |
fi | |
} | |
function ignore_image_dir () { | |
TARGET_DIR=$1 | |
GIT_IGNORE=$2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var allowCrossDomain = function(req, res, next) { | |
res.header('Access-Control-Allow-Origin', '*'); | |
res.header('Access-Control-Allow-Headers', 'X-Requested-With, Content-Type, Authorization, Accept'); | |
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS,TRACE'); | |
res.header('Access-Control-Allow-Credentials', true); | |
/** | |
* CORS OPTIONS request, simply return 200 | |
* --- | |
* Browser will try to see request is possible before actually doing it |