Skip to content

Instantly share code, notes, and snippets.

View sunny's full-sized avatar
☀️

Sunny Ripert sunny

☀️
View GitHub Profile

Falsehoods programmers believe about prices

  1. You can store a price in a floating point variable.
  2. All currencies are subdivided in 1/100th units (like US dollar/cents, euro/eurocents etc.).
  3. All currencies are subdivided in decimal units (like dinar/fils)
  4. All currencies currently in circulation are subdivided in decimal units. (to exclude shillings, pennies) (counter-example: MGA)
  5. All currencies are subdivided. (counter-examples: KRW, COP, JPY... Or subdivisions can be deprecated.)
  6. Prices can't have more precision than the smaller sub-unit of the currency. (e.g. gas prices)
  7. For any currency you can have a price of 1. (ZWL)
  8. Every country has its own currency. (EUR is the best example, but also Franc CFA, etc.)
@sunny
sunny / git-checkout.rake
Last active August 19, 2022 10:04 — forked from skyriverbend/rails_switch_branch.py
Task to checkout a branch in rails and apply or rollback the migrations between the two.
# encoding: UTF-8
#
# $ rake checkout new_branch_name
#
# Via https://gist.github.com/jonlemmon/4076864
#
# 1. Roll back any migrations on your current branch which do not exist on the
# other branch
# 2. Discard any changes to the db/schema.rb file
# 3. Check out the other branch
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?

@mirisuzanne
mirisuzanne / fontface.scss
Created June 4, 2012 18:05
Naming convention for new Compass @font-face API
// New fontface naming conventions & API
// File Structure
//
// - fonts_dir/ [config setting]
// - simple.eot
// - simple.svg
// - simple.ttf
// - simple.woff
// - folder/
@hoverlover
hoverlover / savon_client.rb
Created March 19, 2012 14:45
Using my forks of Akami and Savon to sign a request with a X.509 certificate. See https://github.com/genuitytech/akami and https://github.com/genuitytech/savon.
client = Savon::Client.new do
# This can be a URL also
wsdl.document = "/Path/to/your.wsdl"
# These are optional, only if your WSDL sucks :)
wsdl.endpoint = "https://your_endpoint"
wsdl.namespace = "http://your_namespace"
certs = Akami::WSSE::Certs.new :cert_file => "/path/to/cert.crt", :private_key_file => "/path/to/private/key.pem", :private_key_password => "password"
wsse.sign_with = Akami::WSSE::Signature.new certs
@theamnesic
theamnesic / sunnytize.php
Created July 12, 2011 13:12 — forked from sunny/sunnytize.php
WordPress plugin that removes evil characters in file names
<?php
/*
Plugin Name: Sunnytize
Plugin URI:
Description: A better file name sanitizer
Version: 1.0
Author: Sunny Ripert
Author URI: http://sunfox.org
*/
#####
##### Easily enable clearType on windows.
#####
*** WHAT IT DOES ***
It asks the user to install an activex control, signed by microsoft.
This activex control allows cleartype options to be set using javascript.