- JavaScript
- The language
- http://jsfiddle.net/ - site for playing with javascript, html, css in your browser
- http://www.codecademy.com/en/tracks/javascript - good hands on introduction to javascript
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide - excellent deeper dive intro to javascript
- The language
This file contains hidden or 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 1 (function expression) | |
// | |
test(); // Won't work | |
var test = function () { | |
alert('Yolo'); | |
}; |
This file contains hidden or 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 h = require('virtual-dom/h'); | |
var diff = require('virtual-dom/diff'); | |
var patch = require('virtual-dom/patch'); | |
var createElement = require('virtual-dom/create-element'); | |
var rows = [ | |
{data: 'hello'}, | |
{data: 'there'}, | |
{data: 'friend.'} | |
]; |
This file contains hidden or 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 Rx = require('rx'); | |
// Create draggable element, nothing fancy going on here | |
var box = document.createElement('div'); | |
box.style.width = box.style.height = '100px'; | |
box.style.backgroundColor = 'grey'; | |
box.style.position = 'absolute'; | |
box.innerText = 'Drag me'; | |
document.body.appendChild(box); |
This file contains hidden or 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 Rx = require('rx'); | |
var $ = require('jquery'); | |
function searchWikipedia (term) { | |
return $.ajax({ | |
url: 'http://en.wikipedia.org/w/api.php', | |
dataType: 'jsonp', | |
data: { | |
action: 'opensearch', | |
format: 'json', |
This file contains hidden or 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
<?php | |
/* | |
* Recursively diff two arrays. This function expects the leaf levels to be | |
* arrays of strings or null | |
*/ | |
function diff_recursive($array1, $array2) { | |
$difference=array(); | |
foreach($array1 as $key => $value) { | |
if(is_array($value) && isset($array2[$key])){ // it's an array and both have the key | |
$new_diff = diff_recursive($value, $array2[$key]); |
This file contains hidden or 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 h = require('virtual-dom/h'); | |
var diff = require('virtual-dom/diff'); | |
var patch = require('virtual-dom/patch'); | |
var createElement = require('virtual-dom/create-element'); | |
// Create a deterministic function that declares what the DOM should look like | |
// Model data in, vtree out | |
function render(user) { | |
return h('div#bro', {}, [ | |
h('div', {}, 'First name: ' + user.firstName), |
This file contains hidden or 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 h = require('virtual-dom/h'); | |
var diff = require('virtual-dom/diff'); | |
var patch = require('virtual-dom/patch'); | |
var createElement = require('virtual-dom/create-element'); | |
// Create a deterministic function that declares what the DOM should look like | |
// Model data in, vtree out | |
function render(user) { | |
return h('div#bro', {}, [ | |
h('div', {}, 'First name: ' + user.firstName), |
This file contains hidden or 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 util = require('util'); | |
function TreeNode(data) { | |
this.data = data; | |
this.children = []; | |
} | |
TreeNode.prototype.isLeaf = function() { | |
return this.children.length === 0; | |
}; |
Create a file called ~/.ssh/save_ssh_agent.sh
on your remote box and make it executable:
#!/bin/sh
SSHVARS="SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION DISPLAY"
for var in ${SSHVARS} ; do
echo "export $var=\"$(eval echo '$'$var)\""
done 1>$HOME/.ssh/latest_ssh_agent.sh
ssh
into your box using ssh agent forwarding.