Skip to content

Instantly share code, notes, and snippets.

@ccnixon
ccnixon / 0_reuse_code.js
Created September 27, 2016 15:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ccnixon
ccnixon / sublime_text_2_perfect_key_bindings
Created August 3, 2016 22:32 — forked from koulmomo/sublime_text_2_perfect_key_bindings
Perfect Sublime Text 2 Key Bindings. Tab to skip out of brackets, braces, parentheses, and quotes/quotations but still be able to indent
[
// Move out of common paired characters () and [] with `Tab`
{
"keys": ["tab"],
"command": "move",
"args": {"by": "characters", "forward": true},
"context": [
{"key": "auto_complete_visible", "operand": false},
// Check if next char matches (followed by anything)
{ "key": "following_text", "operator": "regex_match", "operand": "(:?`|\\)|\\]|\\}).*", "match_all": true },
@ccnixon
ccnixon / iframeSnippet.html
Created June 20, 2016 21:27 — forked from sperand-io/iframeSnippet.html
Using Segment via iFrame Communication
<script>
/**
* Provides a fake analytics object that sends all calls to the parent window for processing
*/
var analytics = (function() {
var eventQueue = [];
// Send the events to the frame if it's ready.
function flush(method, args) {
while (eventQueue.length) {
@ccnixon
ccnixon / CorsRequest.js
Created February 17, 2016 19:39 — forked from subnetmarco/CorsRequest.js
Sample code for executing an AJAX request using jQuery.
$.ajax({
url: 'MASHAPE-URL', // The URL to the API. You can get this by clicking on "Show CURL example" from an API profile
type: 'POST', // The HTTP Method
data: {}, // Additional parameters here
dataType: 'json',
success: function(data) { alert(JSON.stringify(data)); },
error: function(err) { alert(err); },
beforeSend: function(xhr) {
xhr.setRequestHeader("X-Mashape-Authorization", "YOUR-MASHAPE-KEY"); // Enter here your Mashape key
}
@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 / 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 / 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 / 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 / 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 {
<!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>