Skip to content

Instantly share code, notes, and snippets.

View remarkablemark's full-sized avatar

Mark remarkablemark

View GitHub Profile
@remarkablemark
remarkablemark / insertion-sort.js
Last active January 19, 2016 06:17
Sorting algorithms written in JavaScript.
'use strict';
/**
* Sorts an array using the insertion algorithm.
*
* @param {Array} array - The array to be sorted.
* @return {Array}
*/
function insertionSort(array) {
if (array.constructor !== Array) {
@remarkablemark
remarkablemark / reverse.js
Last active January 25, 2016 17:17
Reverse a string or array using JavaScript.
'use strict';
/**
* Reverses a string or array.
*
* @param {(String|Array)} i - The string or array.
* @return {(String|Array)}
*/
function reverse(i) {
var isString = false;
@remarkablemark
remarkablemark / .slate.js
Last active February 13, 2016 21:00
My Slate configuration.
'use strict';
/**
* Fullscreen (CTRL + F)
*/
slate.bind('f:ctrl', function(window) {
window.doOperation(move({
x: 'screenOriginX',
y: 'screenOriginY',
width: 'screenSizeX',
@remarkablemark
remarkablemark / driver_test.js
Last active February 14, 2016 21:26
WebDriverJS example
var webdriver = require('selenium-webdriver');
// since no browser is specified in the builder
// you can set the target browser at runtime
// through the SELENIUM_BROWSER environment variable
// e.g., SELENIUM_BROWSER=phantomjs node driver_test.js
var driver = new webdriver.Builder().build();
driver.get('https://www.google.com');
driver.getTitle().then(function(title) {
console.log(title);
});
'use strict';
/**
* Module dependencies.
*/
var webdriver = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');
/**
* Chrome options.
@remarkablemark
remarkablemark / wiki_search.js
Last active April 19, 2016 17:28
Search Wikipedia with WebDriverJS.
var webdriver = require('selenium-webdriver');
var By = webdriver.By;
var driver = new webdriver.Builder().forBrowser('safari').build();
driver
.get('https://www.wikipedia.org')
.then(function() {
return driver.sleep(1000);
})
.then(function() {
@remarkablemark
remarkablemark / arguments-to-array.js
Last active May 23, 2016 19:13
Convert arguments from array-like object to array.
'use strict';
/**
* Convert arguments from array-like object to array.
*
* @param {...*}
* @return {Array}
*/
function argumentsToArray() {
return Array.prototype.slice.call(arguments, 0);
@remarkablemark
remarkablemark / curry.js
Created May 23, 2016 21:09
Example of currying in JavaScript.
'use strict';
/**
* Curry the function.
*
* @param {Function} func - The function to curry.
* @param {...*}
* @return {Function}
*/
function curry(func) {
@remarkablemark
remarkablemark / bind.js
Created May 23, 2016 22:23
Recreate the `bind` method using functional JavaScript.
'use strict';
/**
* Create a bound function.
*
* @param {Function} func - The function to be bound.
* @param {Array} args - The function arguments.
* @param {*} [context] - The function context.
*/
function bind(func, args, context) {