Skip to content

Instantly share code, notes, and snippets.

@mjackson
mjackson / color-conversion-algorithms.js
Last active April 1, 2025 17:53
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
#!/bin/bash
# 下記を参考にしつつ作成
# https://gist.github.com/matchy2/3956266
# https://gist.github.com/saiten/1185755
if [ $# -eq 1 ]; then
channel=$1
case $1 in
r1) playpath='NetRadio_R1_flash@63346' ;;
@jtadeulopes
jtadeulopes / gist:5041735
Created February 26, 2013 20:13
Ruby 2.0 with rbenv
# https://github.com/sstephenson/rbenv
#
# I'm using rbenv-build to install ruby
# https://github.com/sstephenson/ruby-build
cd ~/.rbenv/
git pull
cd plugins/ruby-build/
git pull
rbenv install 2.0.0-p0
@tkdave
tkdave / gist:4150916
Created November 26, 2012 21:58
Installing OpenCV python libs on mac to work with virtualenv and brew
# Installing OpenCV python libs on mac to work with virtualenv
# OpenCV 2.4.3
# Python 2.7.3 installed with brew
# assuming you have virtualenv, pip, and python installed via brew
# assuming $WORKON_HOME is set to something like ~/.virtualenvs
# using homebrew - make sure we're current
brew update
@hachibeeDI
hachibeeDI / lemowl.py
Created November 21, 2012 14:06
change iTerm's transparency
#!/usr/bin/env python
import sys
import appscript
def main():
iterm_transparency = appscript.app('iTerm').current_terminal.current_session.transparency
iterm_transparency.set("0.9" if sys.argv[1] == '-' else "0.1")
if __name__ == '__main__':
@mbostock
mbostock / .block
Last active August 10, 2024 04:03
Path Tween
license: gpl-3.0
@urbushey
urbushey / switch_profile.py
Created October 9, 2012 22:35
Swap color themes (between Solarized Light and Solarized Dark) in Sublime Text 2 based on the time of day. Meant to be scheduled by the Windows Task Scheduler or cron.
from os import path, environ
import datetime
import json
import sys
appdata = environ['APPDATA']
sublime_path = 'Sublime Text 2'
settings_path = 'Packages\User\Preferences.sublime-settings'
day_profile = 'Packages/Color Scheme - Default/Solarized (Light).tmTheme'
night_profile = 'Packages/Color Scheme - Default/Solarized (Dark).tmTheme'
@mbostock
mbostock / .block
Last active October 20, 2023 14:09
General Update Pattern, I
license: gpl-3.0
redirect: https://observablehq.com/@d3/selection-join
@jasongrout
jasongrout / run_once.py
Created September 29, 2012 17:46
run once decorator
# from http://stackoverflow.com/questions/4103773/efficient-way-of-having-a-function-only-execute-once-in-a-loop
from functools import wraps
def run_once(f):
"""Runs a function (successfully) only once.
The running can be reset by setting the `has_run` attribute to False
"""
@wraps(f)
def wrapper(*args, **kwargs):
if not wrapper.has_run:
@L-A
L-A / moonobject.js
Created August 28, 2012 13:20
Moon phase calculation
var MoonInfo = function(day, month, year) {
var n0 = parseInt( "0" );
var f0 = parseFloat( "0.0" );
var AG = f0; // Moon's age
var DI = f0; // Moon's distance in earth radii
var LA = f0; // Moon's ecliptic latitude
var LO = f0; // Moon's ecliptic longitude
var Phase = " ";
var Zodiac = " ";