Skip to content

Instantly share code, notes, and snippets.

View cngondo's full-sized avatar
🎯
Focusing

Cornellius Ngondo cngondo

🎯
Focusing
  • Galvanize
  • Mexico City, Mexico
View GitHub Profile
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@wrburgess
wrburgess / gist:2438607
Created April 21, 2012 17:27
Notes from CodeSchool Journey into Mobile Course
@phette23
phette23 / current-dir-in-iterm-tab-title.sh
Last active June 4, 2024 01:52
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html
@alexhawkins
alexhawkins / HashTable.js
Last active August 7, 2021 23:33
Correct Implementation of a Hash Table in JavaScript
var HashTable = function() {
this._storage = [];
this._count = 0;
this._limit = 8;
}
HashTable.prototype.insert = function(key, value) {
//create an index for our storage location by passing it through our hashing function
var index = this.hashFunc(key, this._limit);
@Cfeusier
Cfeusier / hashTable.js
Last active May 14, 2018 20:47
Hash Table implementation in JavaScript
var HashTable = function() {
this._limit = 8; // choose any size of hash table bucket limit
this._count = 0;
this._storage = [];
};
HashTable.prototype.insert = function(k, v) {
var i = this._getHashIndex(k, this._limit);
this._checkLimit(i); // make sure hashidx is in bounds
var bucket = this._storage[i];
@Cfeusier
Cfeusier / simple-tree.js
Created December 14, 2014 09:13
Simple Tree implementation in JavaScript
var Tree = function(value) {
var newTree = {};
newTree.value = value;
newTree.children = [];
_.extend(newTree, treeMethods);
return newTree;
};
var treeMethods = {};
@Cfeusier
Cfeusier / undirected-graph.js
Created December 14, 2014 09:20
Simple undirected graph implementation in JavaScript
var Graph = function() {
this.nodes = {};
this.edges = {};
};
Graph.prototype.addNode = function(node) {
this.nodes[node] = node;
};
Graph.prototype.contains = function(node) {
@Cfeusier
Cfeusier / singly-linked-list.js
Created December 14, 2014 09:25
Singly Linked List implementation in JavaScript
var Node = function(value) {
var node = {};
node.value = value;
node.next = null;
return node;
};
var LinkedList = function() {
var list = {};
list.head = null;
@vitorbritto
vitorbritto / rm_mysql.md
Last active June 29, 2024 15:21
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql