Skip to content

Instantly share code, notes, and snippets.

Tony Meyer thm-design

Block or report user

Report or block thm-design

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thm-design
thm-design / MergeSort.js
Created Mar 28, 2016
Merge Sort Algorithm
View MergeSort.js
/*
Merge Sort
*/
const mergeSort = (nums) => {
if (nums.length < 2) return nums;
const length = nums.length;
const middle = Math.floor(length / 2);
const left = nums.slice(0, middle);
const right = nums.slice(middle, length);
@thm-design
thm-design / Recursion.js
Created Mar 28, 2016
Simple recursion example
View Recursion.js
/*
Make a function that computes a factorial recursively.
A factorial is when you take a number n and multiply by each preceding integer until you hit one.
n * (n-1) * (n-2) ... * 3 * 2 * 1
Call the function factorial
factorial(1) = 1
factorial(2) = 2
factorial(3) = 6
@thm-design
thm-design / InsertionSort.js
Created Mar 28, 2016
Insertion Sort Algorithm
View InsertionSort.js
/*
Insertion sort
The idea here is that the beginning of your list is sorted and the everything else is assumed to be an unsorted mess.
The outer loop goes over the whole list, the index of which signifies where the "sorted" part of the list is. The inner
loop goes over the sorted part of the list and inserts it into the correct position in the array.
*/
var insertionSort = (nums) => {
for (let i = 1; i < nums.length; i++) {
for (let j = 0; j < i; j++) {
snapshot(nums);
@thm-design
thm-design / BubbleSort.js
Created Mar 28, 2016
Bubble Sort Algorithm
View BubbleSort.js
/*
Bubble sort works by comparing two adjacent numbers next to each other and then
swapping their places if the smaller index's value is larger than the larger
index's. Continue looping through until all values are in ascending order
*/
const bubbleSort = (arr) => {
arr.forEach((n, i) => {
if (arr[i] > arr[i + 1]) {
arr[i] = arr[i + 1];
@thm-design
thm-design / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@thm-design
thm-design / Mobile device detection (JS)
Created Oct 29, 2014
Simple mobile device detection (JS)
View Mobile device detection (JS)
var isMobile = {
Android: function() { return navigator.userAgent.match(/Android/i); },
BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); },
iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); },
Opera: function() { return navigator.userAgent.match(/Opera Mini/i); },
Windows: function() { return navigator.userAgent.match(/IEMobile/i); },
any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } };
// var isTouch = ("ontouchstart" in document.documentElement);
// Chrome Version 37.0.2062.103 m (this version of chrome is firing touchstart event even tho it is not a mobile browser)
View ajaxify-html5.js
// https://gist.github.com/3069522
;(function($, window, document, undefined) {
// Prepare our Variables
var History = window.History;
// Check to see if History.js is enabled for our Browser
if (!History.enabled) {
return false;
}
View iOS Media Queries.css
.ipad-only, .iphone-only, .retina-only, .non-retina-only, .retina-iphone-only, .non-retina-iphone-only { display: none; }
/* ---------- iPad Only ---------- */
@media only screen and (device-width: 768px) {
.ipad-only { display: block; }
}
/* ---------- iPhone/iPod Only ---------- */
@media only screen and (device-width: 320px) {
.iphone-only { display: block; }
View media_queries.css
/* Media queries used on blog.staydecent.ca by Adrian Unger
check my full source at:
http://blog.staydecent.ca/static/css/style-0.1.6.css */
@media only screen and (min-width:768px) and (max-width:1269px) {
/* In my particular design, I used a fluid grid limited to a
max-width of 1140px, while (if there is enough room)
pushing the menu outside of layout, requiring a total
limit of at least 1270px.
So, this first query applies to any screen-width less
View JShintrc
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true
You can’t perform that action at this time.