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
class Person | |
attr_accessor :name, :age | |
def initialize(name, age) | |
@name = name | |
@age = age.to_i | |
end | |
def inspect | |
"#@name (#@age)" | |
end | |
end |
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
#Newbie programmer | |
def factorial(x): | |
if x == 0: | |
return 1 | |
else: | |
return x * factorial(x - 1) | |
print factorial(6) | |
#First year programmer, studied Pascal |
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 | |
OLDCONF=$(dpkg -l|grep "^rc"|awk '{print $2}') | |
CURKERNEL=$(uname -r|sed 's/-*[a-z]//g'|sed 's/-386//g') | |
LINUXPKG="linux-(image|headers|ubuntu-modules|restricted-modules)" | |
METALINUXPKG="linux-(image|headers|restricted-modules)-(generic|i386|server|common|rt|xen)" | |
OLDKERNELS=$(dpkg -l|awk '{print $2}'|grep -E $LINUXPKG |grep -vE $METALINUXPKG|grep -v $CURKERNEL) | |
YELLOW="\033[1;33m" | |
RED="\033[0;31m" | |
ENDCOLOR="\033[0m" |
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
[ | |
{ "keys": ["ctrl+pagedown"], "command": "prev_view" }, | |
{ "keys": ["ctrl+pageup"], "command": "next_view" } | |
] |
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
interface Mail { | |
public function sendMail(); | |
public function getFuel(); | |
} | |
abstract class MyAbstractClass implements Mail { | |
function myAbstractFunction() { | |
echo "not abstract"; | |
} |
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
1. When there's unreleased feature on active branch A and its not on trunk. | |
-> Bring the feature to trunk and comment out on branch A so future merge won't bring the feature on branch A to trunk. |
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
//bad | |
$("#agree").bind("change", function() { | |
if ($("input[type=submit]").hasClass("disabled")) { | |
$("input[type=submit]").removeClass("disabled"); | |
} else { | |
$("input[type=submit]").addClass("disabled"); | |
} | |
}); | |
//good |
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
1. search | |
2. auto list file/url that references current function/class/namespace | |
3. framework specific tags like Angular directive, controller, module | |
4. nested functions |
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
1. Write semantic and accessible HTML5 | |
Goals: | |
+ Avoid div soup/code bloat | |
+ Accessibiity | |
+ Improve SEO | |
a/ Semantic aka has meaning | |
http://html5doctor.com/downloads/h5d-sectioning-flowchart.pdf | |
b/ Content models: | |
https://www.w3.org/TR/2011/WD-html5-20110525/content-models.html#kinds-of-content |
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
// Credits: http://matt.might.net/articles/implementation-of-recursive-fixed-point-y-combinator-in-javascript-for-memoization/ | |
// Ymem takes a functional and an (optional) | |
// cache of answers. | |
// It returns the fixed point of the functional | |
// that caches intermediate results. | |
function Ymem(F, cache) { | |
if (!cache) | |
cache = {} ; // Create a new cache. |
OlderNewer