Skip to content

Instantly share code, notes, and snippets.

use v5.14;
use JSON::PP;
use JSON::Hyper;
use Data::Dumper;
use Devel::Confess;
# Construct a URI which has some JSON data. I'm using a
# data: URI because I'm too lazy to upload some JSON
# somewhere, but any URI that returns JSON should be OK.
#
@arturadib
arturadib / pre-commit
Last active December 21, 2023 08:54
Pre-commit hook to prevent debug code from being committed
#
# Paste this script in your .git/hooks/pre-commit file (create one if it doesn't exist yet)
# To prevent debug code from being accidentally committed, simply add a comment near your
# debug code containing the keyword !nocommit and this script will abort the commit.
#
if git commit -v --dry-run | grep '!nocommit' >/dev/null 2>&1
then
echo "Trying to commit non-committable code."
echo "Remove the !nocommit string and try again."

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.)
@tombeynon
tombeynon / createVhost.sh
Last active August 25, 2023 06:56
Programmatically create Apache VHost
#!/bin/bash
# /usr/local/bin/createSite.sh -d domain -t com -u user -p password -r git@github.com:user/repo.git
# TODO: SCP could be done in reverse
domain=''
tld=''
username=''
password=''
@darkliquid
darkliquid / beautified.js
Last active August 22, 2019 02:28
Bookmarklet to estimate reading time of a page
javascript:(function () {
function getTextNodesIn(element) {
var wordcount = 0,
whitespace = /^\s*$/;
function getTextNode(node) {
// type 3 is a textnode
if (node.nodeType == 3) {
// We skip text nodes that are only whitespace
if (!whitespace.test(node.nodeValue)) {
@brianpattison
brianpattison / README.md
Created November 22, 2012 07:41 — forked from tjogin/README.md
PHP on Pow.cx

PHP on Pow.cx

Install Pow

$ curl get.pow.cx | sh

Install PHP with MySQL

$ curl -O https://raw.github.com/gist/4129846/7ae1709453a8a19ce9c030bf41d544dd08d96d85/php.rb

$ mv php.rb brew --prefix/Library/Formula

@codeincontext
codeincontext / gist:3707167
Created September 12, 2012 14:53
Facebook and Twitter login with Sinatra
require 'rubygems'
require 'sinatra'
require 'json'
require 'omniauth'
require 'omniauth-facebook'
require 'omniauth-twitter'
class SinatraApp < Sinatra::Base
configure do
set :sessions, true
@mikedfunk
mikedfunk / README.md
Created August 28, 2012 21:17
CodeIgniter Pagination for Twitter Bootstrap

This uses Twitter Bootstrap classes for CodeIgniter pagination.

Drop this file into application/config.

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 15, 2024 11:43
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jcsrb
jcsrb / dabblet.css
Created May 3, 2012 13:51
Top and Bottom inset shadow
/**
* Top and Bottom inset shadow
*/
#element{
background-color: #E3F2F7;
height: 55px;
position: relative; /* to position pseudo absolute*/
overflow: hidden; /* to cut of overflow shadow*/