Skip to content

Instantly share code, notes, and snippets.

View niittymaa's full-sized avatar

Sakari Niittymaa niittymaa

View GitHub Profile
@niittymaa
niittymaa / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/**
*
* Javascript color conversion
* http://www.webtoolkit.info/javascript-color-conversion.html
*
**/
function HSV(h, s, v) {
if (h <= 0) { h = 0; }
if (s <= 0) { s = 0; }
@niittymaa
niittymaa / bitcolor.js
Created November 12, 2015 05:48 — forked from lrvick/bitcolor.js
Javascript functions for doing fast binary/hex/RGB color conversions using bitwise operations.
// convert 0..255 R,G,B values to binary string
RGBToBin = function(r,g,b){
var bin = r << 16 | g << 8 | b;
return (function(h){
return new Array(25-h.length).join("0")+h
})(bin.toString(2))
}
// convert 0..255 R,G,B values to a hexidecimal color string
RGBToHex = function(r,g,b){
@niittymaa
niittymaa / cvwebv.sh
Created February 24, 2016 21:27 — forked from gabstv/cvwebv.sh
Convert videos to HTML5 friendly video formats (mp4, ogg and webm).
#!/bin/bash
# For this to work, you need to have ffmpeg
# installed with libvorbis, theora and libvpx ENABLED
# to do that in Homebrew:
# brew reinstall ffmpeg --with-libvpx --with-libvorbis --with-theora
#
# encoding reference:
# https://blog.mediacru.sh/2013/12/23/The-right-way-to-encode-HTML5-video.html
@niittymaa
niittymaa / shell_video_converter.sh
Created February 24, 2016 21:28
Bash: Convert mp4 to ogv and/or WebM
# convert mp4 to ogv and/or webm
# mp4: http://caniuse.com/#search=mp4
# ogv: http://caniuse.com/#search=ogv
# webm: http://caniuse.com/#search=webm
# install
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with- --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools
# mp4 to ogv
@niittymaa
niittymaa / combine.js
Created February 28, 2016 08:58
Combine all page scripts or styles
/**
* Combine page scripts and styles.
*
* Usage:
* 1. Copy/Paste and execute this script in the browser console
* 2. Call combineScripts() or combineStyles()
*
* Press ESC to hide textarea.
*
* P.S. Use http://refresh-sf.com/ to create min.js and min.css
@niittymaa
niittymaa / mkfavicon.sh
Created March 14, 2016 10:27 — forked from pfig/mkfavicon.sh
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png
@niittymaa
niittymaa / bootstrap-tabs.html
Created March 26, 2016 16:57 — forked from mnewt/bootstrap-tabs.html
bootstrap tabs example
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Le styles -->
<link href="../bootstrap/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
</head>
<body>
@niittymaa
niittymaa / get_css.js
Created September 7, 2016 09:17 — forked from carymrobbins/get_css.js
Get all CSS attributes for an element.
var getCss = function(el) {
var style = window.getComputedStyle(el);
return Object.keys(style).reduce(function(acc, k) {
var name = style[k],
value = style.getPropertyValue(name);
if (value !== null) {
acc[name] = value;
}
return acc;
}, {});
@niittymaa
niittymaa / How to use Images as Radio buttons.md
Created November 3, 2016 15:45 — forked from rcotrina94/How to use Images as Radio buttons.md
How to use images for radio buttons (input-radio).