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
$('input,textarea').each(function() { | |
// set this attr placeholder into val, if ie. | |
if ($.browser.msie) { | |
if ($(this).val() == '') { | |
$(this).val($(this).attr('placeholder')); | |
} | |
} | |
}).focus(function() { | |
if ($.browser.msie) { | |
if ($(this).val() == $(this).attr('placeholder')) { |
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
/* | |
* Enhances 'require' from RequireJS with Promises API while preserving its original semantics. | |
*/ | |
(function() { | |
if (!Promise || !require) { | |
return; | |
} |
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
task default: %w[version] | |
version_sizes = ["major", "minor", "patch"] | |
task :version, [:version_size] do |t, args| | |
args.with_defaults(:version_size => "patch") | |
version_size = args.version_size | |
unless version_sizes.include?(version_size) | |
fail "invalid version size, please use: major, minor, or patch" |
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
import Foundation | |
class Node { | |
var val: Int | |
var next: Node? | |
init(val: Int) { | |
self.val = val |
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
import Foundation | |
class Node { | |
var val: String? | |
var parent: Node? | |
var children: [String: Node] = [:] |
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
import Foundation | |
class Node { | |
var val: Int | |
var left: Node? | |
var right: Node? | |
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
// Implement a min heap: | |
// -> insert, extract_min | |
// property: | |
// - elements are in ascending order | |
// - complete binary tree (node is smaller than it’s children) | |
// - root is the most minimum | |
// - insert takes O(logn) time | |
// - insert to the bottom right |
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
// Implement a stack using LinkedLists. | |
// Operations: | |
// -> push | |
// -> pop | |
// -> peek | |
function StackNode(val) { | |
this.val = val; | |
this.next = null; |
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
// Implement a Queue using LinkedLists | |
// we know that queue is LIFO | |
// operations: enqueue, dequeue | |
function QueueNode(val) { | |
this.val = val; | |
this.next = null; | |
} | |
function Queue() { |
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
// Implement a Graph | |
// basic operations: | |
// - add vertex (node) | |
// - add edge (node -> node) | |
function GraphNode(val) { | |
this.val = val; | |
this.edges = {}; | |
} |
OlderNewer