Skip to content

Instantly share code, notes, and snippets.

@nikolas
nikolas / insert-into-sorted-array.js
Last active January 15, 2020 20:12 — forked from mir4ef/insert-into-sorted-array.js
insert an element into a sorted array of objects
// 1d array
for (var i = 0, len = arr.length; i < len; i++) {
if (somevalue < arr[i]) {
arr.splice(i, 0, somevalue);
break;
}
}
return arr;
@nikolas
nikolas / insert-into-sorted-array.js
Created January 15, 2020 20:11 — forked from mir4ef/insert-into-sorted-array.js
insert an element into a sorted array of objects
// 1d array
for (var i = 0, len = arr.length; i < len; i++) {
if (somevalue < arr[i]) {
arr.splice(i, 0, somevalue);
break;
}
}
return arr;
@nikolas
nikolas / lerp-color.js
Last active June 29, 2023 14:12 — forked from rosszurowski/lerp-color.js
Linear interpolation for hexadecimal colors.
/**
* A linear interpolator for hex colors.
*
* Based on:
* https://gist.github.com/rosszurowski/67f04465c424a9bc0dae
*
* @param {Number} a (hex color start val)
* @param {Number} b (hex color end val)
* @param {Number} amount (the amount to fade from a to b)
*
@nikolas
nikolas / gist:7603812
Last active December 29, 2015 02:58 — forked from jalcine/gist:7297333
require 'spec_helper'
describe Users::OauthCallbacksController, "handle facebook authentication callback" do
describe "#annonymous user" do
context "when facebook email doesn't exist in the system" do
before(:each) do
stub_env_for_omniauth
get :facebook