Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark remarkablemark

View GitHub Profile
@remarkablemark
remarkablemark / reverse.js
Last active Jan 25, 2016
Reverse a string or array using JavaScript.
View reverse.js
'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 / insertion-sort.js
Last active Jan 19, 2016
Sorting algorithms written in JavaScript.
View insertion-sort.js
'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 / .slate.js
Last active Feb 13, 2016
My Slate configuration.
View .slate.js
'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 Feb 14, 2016
WebDriverJS example
View driver_test.js
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);
});
View webdriver_chrome_profile.js
'use strict';
/**
* Module dependencies.
*/
var webdriver = require('selenium-webdriver');
var chrome = require('selenium-webdriver/chrome');
/**
* Chrome options.
@remarkablemark
remarkablemark / wiki_search.js
Last active Apr 19, 2016
Search Wikipedia with WebDriverJS.
View wiki_search.js
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 / .eslintrc
Last active Aug 24, 2016
ESLint configuration
View .eslintrc
{
"parser": "babel-eslint",
"env": {
"browser": true, // allow browser globals like `window` and `document`
"node": true, // allow node globals like `process`
"commonjs": true, // allow globals like `require` and `exports`
"mocha": true // allow mocha globals like `describe` and `it`
},
@remarkablemark
remarkablemark / README.md
Last active Jan 14, 2021
Classes - ES5 vs ES6
View README.md

JavaScript Classes - ES5 vs ES6

An example that shows the difference between creating a JavaScript class and subclass in ES5 and ES6.

Reference

@remarkablemark
remarkablemark / arguments-to-array.js
Last active May 23, 2016
Convert arguments from array-like object to array.
View arguments-to-array.js
'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
Example of currying in JavaScript.
View curry.js
'use strict';
/**
* Curry the function.
*
* @param {Function} func - The function to curry.
* @param {...*}
* @return {Function}
*/
function curry(func) {