Skip to content

Instantly share code, notes, and snippets.

View callumj's full-sized avatar
🙌
writing code

Callum Jones callumj

🙌
writing code
View GitHub Profile
@jgamblin
jgamblin / slackspotify.sh
Created April 19, 2017 01:10
A Script To Set Current Spotify Song As Slack Status
#!/bin/bash
APIKEY="From Here https://api.slack.com/custom-integrations/legacy-tokens"
SONG=$(osascript -e 'tell application "Spotify" to name of current track as string')
URLSONG=$(echo "$SONG" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"\n"')
while true
do
curl -s -d "payload=$json" "https://slack.com/api/users.profile.set?token="$APIKEY"&profile=%7B%22status_text%22%3A%22"$URLSONG"%22%2C%22status_emoji%22%3A%22%3Amusical_note%3A%22%7D" > /dev/null
sleep 60
done
@ssrihari
ssrihari / postgres-clusters-nuances.org
Last active April 15, 2024 04:46
Postgres clusters and their nuances

Postgres clusters and their nuances

Why

  • Do you even need a cluster of postgreses? Why did we choose to create a cluster ourselves?
  • Why didn’t RDS work for us? Why it might not work for you.
  • What are other RDS like services out there?

Postgres side of things:

  • What you need to know within postgres so your data can be streamed down to multiple nodes quick, and efficiently.
@ijin
ijin / myFunction.js
Last active June 21, 2017 04:06
AWS Lambda function to set an Auto Scaling instance to be Unhealthy in response to a SNS message
console.log('Loading event');
var aws = require('aws-sdk');
var s3 = new aws.S3({apiVersion: '2006-03-01'});
var autoscaling = new aws.AutoScaling({apiVersion: '2011-01-01'});
exports.handler = function(event, context) {
console.log('Received event:');
console.log(event);
//console.log(typeof event.Subject);
if (event.hasOwnProperty('Message')) {
@sj26
sj26 / agent-setup.sh
Last active October 2, 2018 03:17
Buildbox agent setup (elastic)
# On a new ubuntu 14.04 box, as root, with the following variables
# export BUILDBOX_AGENT_TOKEN="<your token here>"
# export BUILDBOX_AGENT_SSH_PRIVATE_KEY="<ssh private key>"
# export BUILDBOX_AGENT_SSH_PUBLIC_KEY="<ssh public key>"
# Make tmp totally in memory
echo "none /tmp tmpfs size=8g 0 0" >> /etc/fstab
mount /tmp
@rwjblue
rwjblue / rspec-uncommitted.sh
Last active May 17, 2021 15:18
Run rspec only on uncommited files. No more accidentally pushing a :focus tag to master!
rspec `git ls-files --modified --others spec`
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jimsynz
jimsynz / rgb_spectrum.c
Created January 5, 2011 20:59
Arduino sketch to cycle an RGB LED through the colour spectrum.
const int redPin = 11;
const int greenPin = 10;
const int bluePin = 9;
void setup() {
// Start off with the LED off.
setColourRgb(0,0,0);
}
void loop() {
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
def doRummbleMethod(method, queryString)
consumer = OAuth::Consumer.new(API_KEY, API_SECRET, { :site => "http://api.rummble.com", :request_token_url => "http://www.rummble.com/oauth/request_token", :access_token_url => "http://www.rummble.com/oauth/access_token", :authorize_url => "http://www.rummble.com/oauth/authorize" })
paramsString = ""
if queryString.size > 0
queryString.to_a.collect {|key, value| paramsString << "#{key}=#{value}&"}
paramsString[paramsString.length - 1] = '' #remove last &
end
returnObj = consumer.request(:get, "/?method=#{method}&#{paramsString}", nil, {:scheme => :query_string})
returnObj.body
end