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
$('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
// 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
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
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
function MergeSort() { } | |
MergeSort.prototype.sort = function(values) { | |
if (values.length < 2) { | |
return values; | |
} | |
var mid = Math.floor(values.length/2); | |
var left = this.sort(values.slice(0, mid)); | |
var right = this.sort(values.slice(mid, values.length)); |
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
//SPDX-License-Identifier: Unlicense | |
pragma solidity ^0.7.0; | |
import "@openzeppelin/contracts/utils/Counters.sol"; | |
import "@openzeppelin/contracts/utils/EnumerableSet.sol"; | |
library OfferManager { | |
using EnumerableSet for EnumerableSet.UintSet; | |
using EnumerableSet for EnumerableSet.AddressSet; | |
using Counters for Counters.Counter; |
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
// LRUCache.js - super simple JavaScript Implementation | |
// LRU stands for "Least Recently Used" | |
// https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU | |
// ----------------------------------------- | |
function LRUNode(key) { | |
this.key = key; | |
this.next = this.prev = null; | |
} |
OlderNewer