Skip to content

Instantly share code, notes, and snippets.

View jhnsnc's full-sized avatar
🐢
Slow to respond on Github. Most personal projects are on hold, sorry! 🙇

Chris Johnson jhnsnc

🐢
Slow to respond on Github. Most personal projects are on hold, sorry! 🙇
View GitHub Profile
@jhnsnc
jhnsnc / ClassNames.js
Created January 26, 2018 01:05
Utility class for adding/removing class names by chaining function calls rather than doing manual string manipulation
/**
* Conditionally add/remove classes and render the result to a class list string
*
* @param {...string} initialClasses - initial class names to add
*/
export class ClassNames {
constructor(...initialClasses) {
this.arrClasses_ = initialClasses;
this.breakUpSpaces_();
return this;
@jhnsnc
jhnsnc / install-nvm-node-npm.sh
Created October 2, 2017 20:26
Snippet to install NVM and set it up with a stable version of Node/NPM
#-------------------------------------------------------------------------------
# Install NVM
#-------------------------------------------------------------------------------
echo -e "Installing nvm, our Node version manager..." true
NVM_DIR="$HOME/.nvm"
if [[ -e "$NVM_DIR" ]]; then
echo -e "Already installed. Moving on..."
@jhnsnc
jhnsnc / glsl-function-snippets.glsl
Last active April 20, 2017 00:34
GLSL Function Snippets
// Sineless hash - Dave Hoskins ( https://www.shadertoy.com/view/4djSRW )
// License: CC BY-SA v4.0 (this function only)
float hash11(float p)
{
const float HASHSCALE1 = .1031;
vec3 p3 = fract(vec3(p) * HASHSCALE1);
p3 += dot(p3, p3.yzx + 19.19);
return fract((p3.x + p3.y) * p3.z);
}
function colorInterpolate(t) {
var color1 = 0xffcc00;
var color2 = 0x0066ff;
var r = Math.floor((color2>>16)*t + (color1>>16)*(1-t));
var g = Math.floor((color2>>8&0xff)*t + (color1>>8&0xff)*(1-t));
var b = Math.floor((color2&0xff)*t + (color1&0xff)*(1-t));
return '#' + ((1<<24)+(r<<16)+(g<<8)+b).toString(16).slice(1);
}
// Written by Chris Johnson
// 2013-07-21
// Assumes jQuery is available as `$`
/*
* USAGE
* spritify($(element), { //should already have spritesheet set as background
* spriteSheetWidth: 300, //width of spritesheet
* spriteSheetHeight: 150, //height of spritesheet
* offsetX: 0, //offset applied to each frame
@jhnsnc
jhnsnc / remove_bum_tweets.js
Created April 19, 2016 04:18
A quick bookmarklet for when @Worthless_Bums is filling up your Twitter feed.
javascript:var c=0;Array.prototype.forEach.call(document.querySelectorAll('.tweet[data-user-id="371635567"]'),function(t){t.parentNode.remove(),c+=1}),window.alert('Removed '+c+' Bum tweets.');
/**
* USAGE: Create a new bookmark in your browser.
* Copy/Paste the entire line above into the URL/location field.
* Name the bookmarklet something like "Remove Bum Tweets".
* Click the bookmarklet you created when you're on Twitter.com and feeling overwhelmed with tweets from @Worthless_Bums.
*/
@jhnsnc
jhnsnc / .editorconfig
Created February 13, 2016 04:27
Standard .editorconfig for Node projects
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
# Change these settings to your own preference
indent_style = space
@jhnsnc
jhnsnc / PersistedSettings.json
Created February 5, 2016 00:00
League of Legends config customization for easier kiting (left-click attack move). From this thread: https://www.reddit.com/r/leagueoflegends/comments/3vgw7a/how_to_bind_attack_move_to_left_click_with_full/ Should be located at C:\Riot Games\League of Legends\Config\.
{
"description": "The settings in this file are persisted server-side. This file is generated automatically. Editing it is not recommended. Modify SettingsToPersist.json to specify which settings are persisted.",
"files": [
{
"name": "Game.cfg",
"sections": [
{
"name": "Chat",
"settings": [
{
@jhnsnc
jhnsnc / ddo-aliases.layout
Created February 4, 2016 22:59
Aliases file for useful chat aliases in DDO
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<UI>
<Version Value="1.0"/>
<!-- this is the part that actually matters (also, remove this line) -->
<Aliases>
<Alias String=";black" Value="&lt;rgb=#000000>"/>
<Alias String=";blue" Value="&lt;rgb=#1050FF>"/>
<Alias String=";gold" Value="&lt;rgb=#FFD700>"/>