Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<script src='jquery.js'></script>
<script src="main.js"></script>
</head>
<body>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
@ccnixon
ccnixon / depthFirstSearcher.js
Created October 10, 2015 15:36 — forked from jvalen/depthFirstSearcher.js
Depth-first searcher: Depth-first search through a tree of nodes. It returns the given name node.
/**
* Depth-first search tree
* @param {string} nodeName - Name of the node to find
* @param {object} tree - Node example: {name: 'a', children: [nodeA, nodeB, ...]}
* @return {object} Returns the node with the given name
*/
function depthFirstSearch(nodeName, tree) {
if (tree.name === nodeName) {
return tree; //Node found
} else {
@ccnixon
ccnixon / breadthFirstSearch.js
Created October 10, 2015 15:37 — forked from ionox0/breadthFirstSearch.js
Breadth First Search
function BFS(node){
var list = [node];
var current = list.shift();
while(current){
console.log(current.data);
var i = 1;
@ccnixon
ccnixon / flatten.js
Created October 10, 2015 15:39 — forked from bonpixel/flatten.js
Recursion Example
/**
* A Little example of recursion
**/
(function(){
var flatten = function(toFlatten){
var flatArr = [],
result,
tmp;
@ccnixon
ccnixon / bubbleSort.js
Created October 10, 2015 15:43
Bubble Sort
var bubbleSort = function(array) {
var len = array.length;
var swap = function(i,j,array){
var holder = array[i];
array[i] = array[j];
array[j] = holder;
}
for(var j = 0; j < len - 1; j++){
var swaps = false;
@ccnixon
ccnixon / composeAndPipe.js
Created October 10, 2015 16:16
Compose and Pipe
var compose = function(){
//Your code here
var args = Array.prototype.slice.call(arguments);
return function(val){
return args.reduceRight(function(memo, fn){
return fn(memo);
}, val);
};
};
@ccnixon
ccnixon / app.js
Created October 22, 2015 22:40 — forked from rnkoaa/app.js
A simple angularjs with angular-ui modal form which includes validation on the client side. Thanks http://scotch.io/tutorials/javascript/angularjs-form-validation
var app = angular.module("modalFormApp", ['ui.bootstrap']);
app.controller("modalAccountFormController", ['$scope', '$modal', '$log',
function ($scope, $modal, $log) {
$scope.showForm = function () {
$scope.message = "Show Form Button Clicked";
console.log($scope.message);
var modalInstance = $modal.open({
@ccnixon
ccnixon / gitflow-tutorial.sh
Created October 30, 2015 16:30 — forked from peterdeweese/gitflow-tutorial.sh
Gitflow Tutorial
set -o verbose
set -o errexit
echo '* Create and initialize a repository.'
git init gitflow-tutorial
cd gitflow-tutorial/
git flow init -d
echo '* Develop a Feature'
@ccnixon
ccnixon / spiralTraversal.js
Last active December 12, 2015 17:21
Write a function that accepts a 2-dimensional array (that is, an array containing many same-length arrays), and prints out every value found, but in a spiral from the upper left in to the center.
var matrix =
[ [ 1, 2, 3, 4, 5 ],
[ 6, 7, 8, 9, 10 ],
[ 11, 12, 13, 14, 15 ],
[ 16, 17, 18, 19, 20 ],
[ 21, 22, 23, 24, 25 ] ];
var spiralTraversal = function(matrix){
var results =[];
var startRowIndex = 0;
@ccnixon
ccnixon / eventingLibrary.js
Created December 12, 2015 17:23
Make an eventing system mix-in that adds .trigger() and .on() to any input object.
/*
Example usage:
var obj = mixEvents({ name: 'Alice', age: 30 });
obj.on('ageChange', function(){ // On takes an event name and a callback function
console.log('Age changed');
});
obj.age++;
obj.trigger('ageChange'); // This should call our callback! Should log 'age changed'.
*/