Skip to content

Instantly share code, notes, and snippets.

View jennz0r's full-sized avatar
🍦
.

Jenn jennz0r

🍦
.
View GitHub Profile
@jennz0r
jennz0r / fibonacci.js
Created January 14, 2015 23:05
Fibonacci
function fib(n) {
return function(n, a, b) {
return n > 0 ? arguments.callee(n - 1, b, a + b) : a;
}(n, 0, 1);
}
@jennz0r
jennz0r / syntaxHighlight.js
Created January 20, 2015 23:51
Syntax Highlighting
function cloneElementWithStyles(element) {
var clonedEl = $(document.createElement(element.tagName));
// CSS styles to copy over from the generated node.
var stylesToCopy = ['font', 'color'];
// Copy css styles.
clonedEl.attr('style', getComputedStyles(stylesToCopy, element));
// Clone children.
@jennz0r
jennz0r / Example 5.html
Created February 25, 2013 19:06
Example 5 of my HTML & CSS workshop. A simple example of what one can do with just a bit of HTML and CSS.
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" media="screen"/>
</head>
<body>
<div id="wrapper">
<div id="cats">
<div class="title">
<h1>CATS</h1>
@jennz0r
jennz0r / index.html
Last active July 17, 2018 02:40
Button Click!
<html>
<body>
<button onclick="clicked()">Hello</button>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
JavaScript Python
Boolean true false True False
Nothing null None
Empty Value undefined
Number Number int float long complex
Sequences Array list tuple bytearray buffer xrange
Key Value Store Object Dictionary
// You can coerce an integer into string in JavaScript
let coerced = 1;
let concatenated = coerced + 'string';
function drSeuss(catInTheHat, thing1, thing2) {
if (catInTheHat == true &&
thing1 == true &&
thing2 == true) {
console.log('is cray');
} else if (catInTheHat != true) {
console.log('boring');
} else {
console.log('so boring');
}
def fish_and_chips():
ingredients = ['fish', 'potatoes', 'batter']
print 'cooking %s together' % (', '.join(ingredients))
# cooking fish, potatoes, batter
class Baking(object):
def __init__(self, supplies):
self.supplies = supplies
function simpleExample(value) {
if (value) {
var varValue = value;
let letValue = value;
console.log(varValue, letValue); // value value
}
// varValue is available even though it was defined
// in if-block because it was "hoisted" to function scope
console.log(varValue); // value
JavaScript Python
Scope Lexical Lexical
Namescape Functions Classes [ES6!] Modules [ES6!] Blocks [ES6!] Functions Classes Modules
New Identifiers Variables Functions Variables Functions Classes