Skip to content

Instantly share code, notes, and snippets.

@sha1sum
sha1sum / groupme_random_fact.php
Created December 15, 2014 20:10
Random Fact Generator for a GroupMe Bot (via callback URL)
<?php
/*
* Output a random fact to GroupMe via a bot.
*
* Trigger the bot with "!randomfact" or "!random fact".
* Enter the bot ID on line 43.
*
*/
function ordinal($number) {
$ends = array('th','st','nd','rd','th','th','th','th','th','th');
$mod100 = $number % 100;
return $number . ($mod100 >= 11 && $mod100 <= 13 ? 'th' : $ends[$number % 10]);
}
@carlosefonseca
carlosefonseca / json2gfmtable.py
Last active June 24, 2016 04:41
Creates a GitHub Flavored Markdown table from a JSON array passed to the stdin. Accepts a list of column names as the argument for column ordering and filtering.
#!/usr/bin/env python3
# coding=utf-8
import json
import sys
# only reads from stdin
j = json.loads(sys.stdin.read())
# reads a list of column names from the argument "col1,col2" etc
@max-mapper
max-mapper / readme.md
Created August 22, 2012 05:08
things I wish github notified me about

the new github notifications (https://github.com/blog/1204-notifications-stars) leaves me wanting more!

  • when someone comments on a gist that I either own or have also commented on
  • when someone comments on a commit (in a project that I'm not part of) that I have commented on
  • when someone makes a commit to a fork of one of my repos

notifications settings should let you choose whether or not to receive emails for the above things. there should also be a web UI that shows you a list of all comments/messages for the above scenarios. at the moment https://github.com/notifications only shows you github issue names which is less useful than showing the actual message (the old notifications page showed actual messages)

@paulirish
paulirish / gist:292907
Created February 2, 2010 18:50
ascii art that's perfect for code comments
/* __
/ _)
.-^^^-/ /
__/ /
<__.|_|-|_|
*/
/*_/|
=0-0=
@Decicus
Decicus / setmulti_with_kadgar.md
Last active July 12, 2018 01:52
Miscellaneous Nightbot commands using variables

Usage

!setmulti <streams> where <streams> is just the channel names for the ones you're streaming with, separated by a space between every channel.

Command

!commands add -a=!commands !setmulti edit !multi http://kadgar.net/live/$(channel)/$(eval const streams = '$(query)'.split(" ");streams.join("/");)

@jeromer
jeromer / orthodromicdistance.py
Created February 22, 2012 10:06
Orthodromic distance using the Harversine formula in Python
# -*- coding: utf-8 -*-
import math
def calculate_orthodromic_distance(pointA, pointB):
"""
Calculates the great circle distance between two points.
The great circle distance is the shortest distance.
This function uses the Haversine formula :
- https://en.wikipedia.org/wiki/Haversine_formula
@IanSimpson
IanSimpson / imb.php
Created May 28, 2015 11:03
PHP IMB Barcode Converter
<?
/**
* IMB Converter
* =============
* This class takes a numeric code (in the valid format) and returns a string in ATDF format, ready to be printed
* with the USPS IMB font
*
* Code extracted from TCPDF and modified to operate standalone. See http://www.tcpdf.org
*
* Usage:
@calebporzio
calebporzio / timer_helpers.php
Last active August 18, 2019 00:07
A simple helper function and macro for timing php scripts and eloquent queries
<?php
// Helper function.
if (! function_exists('timer')) {
function timer($expression)
{
$start = microtime(true);
if ($expression instanceof Closure) {
$expression();
@MattCheetham
MattCheetham / siri_homekit_colours.txt
Last active August 30, 2019 10:24
Siri HomeKit Light Colours
// A list of all colours that Siri understands when controlling light bulbs. E.g. "Hey Siri, set the bedroom lights to red"
// Please contribute any that you have come accross
Blue
Red
Green
Yellow
White
Champagne
Direct Sunlight