Skip to content

Instantly share code, notes, and snippets.

@matthewlehner
matthewlehner / user.rb
Created May 30, 2012 17:47 — forked from andresgutgon/user.rb
Migrate Authlogic SHA512 Passwords to BCryt
# Because we have some old legacy users in the database, we need to
# override #has_secure_passwords' method for checking if a password is valid.
# We first ask if the password is valid, and if it throws an InvalidHash
# exception, we know that we're dealing with a legacy user, so we check the
# password against the SHA1 algorithm that was used to hash the password in
# the old database.
#SOURCES OF SOLUTION:
# http://stackoverflow.com/questions/6113375/converting-existing-password-hash-to-devise
# https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/crypto_providers/sha512.rb
@daz
daz / appleevent.rb
Created September 13, 2012 04:09
Watch for Apple event video posting
#!/usr/bin/ruby
# encoding: utf-8
# Pings Apple events page until the video is posted
# Videos are usually live ~6 hours after official start time
#
# $ git clone https://gist.github.com/3711799.git appleevent
# $ ruby appleevent/appleevent.rb
require 'date'
@Tafkas
Tafkas / computeSunrise.js
Last active August 3, 2023 20:04
A simple sunrise-sunset algorithm taken from http://williams.best.vwh.net/sunrise_sunset_algorithm.htm in JavaScript
function computeSunrise(day, sunrise) {
/*Sunrise/Sunset Algorithm taken from
http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
inputs:
day = day of the year
sunrise = true for sunrise, false for sunset
output:
time of sunrise/sunset in hours */
@daz
daz / f1calendar.rb
Last active December 14, 2015 14:59
Formula1 calendar script. P1-3, qualifying. and race start times for the year
# Dependencies
#
# $ gem install icalendar
#
# Usage
#
# $ git clone https://gist.github.com/5104840.git f1calendar
# $ ruby f1calendar/f1calendar.rb
#
# FORMULA 1 GRANDE PRÊMIO DO BRASIL 2015 - Sao Paulo - 2015-11-13 12:00:00 UTC - Practice 1
@vitorgalvao
vitorgalvao / Right Click.applescript
Last active March 16, 2023 14:30
Make right-clicking on OSX accessible via a keyboard shortcut
(*
A [native solution][1] exists but it suffers from a major flaw: it right-clicks where the cursor is, not what on the selection.
This code addresses that limitation, though it only works on Finder windows and not the Desktop.
You can install it as a [Finder Service, and later asign it a keyboard shortcut][2].
[1]: http://stackoverflow.com/questions/9171613/right-click-shortcut-for-mac-lion-os
[2]: http://www.macosxautomation.com/services/learn/tut01/index.html
*)
@radiosilence
radiosilence / 1-vanilla.coffee
Last active December 24, 2015 09:59
Three ways of chaining callbacks that are dependant on the previous one. In CoffeeScript.
http = require 'http'
yellIP = (callbacks, data) ->
console.log "OI!! YOUR IP IS #{data.ip}!!!"
printIP = (callbacks, data) ->
console.log "Your IP address: #{data.ip}"
parseJSON = (callbacks, string) ->
callbacks.shift()(callbacks, JSON.parse(string))
@jtadeulopes
jtadeulopes / server.md
Last active March 29, 2024 10:23
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo reboot

Configure timezone

@mkdizajn
mkdizajn / function.php
Last active May 6, 2020 15:59
Wordpress Bootstrap 3 responsive images
<?php
//----------------------------------------------------------/
// responsive images [ 1) add img-responsive class 2) remove dimensions ]
//----------------------------------------------------------/
function bootstrap_responsive_images( $html ){
$classes = 'img-responsive'; // separated by spaces, e.g. 'img image-link'
// check if there are already classes assigned to the anchor
if ( preg_match('/<img.*? class="/', $html) ) {
@blacktm
blacktm / install_ruby_rpi.sh
Last active February 28, 2024 23:24
A Bash script to install Ruby on the Raspberry Pi
#!/bin/bash
# --------------------------------------------------------------------------------------------
# Installs Ruby using rbenv/ruby-build on the Raspberry Pi (Raspbian)
#
# Run from the web:
# bash <(curl -s https://gist.githubusercontent.com/blacktm/8302741/raw/install_ruby_rpi.sh)
# --------------------------------------------------------------------------------------------
# Set the Ruby version you want to install
@ryanzhou
ryanzhou / pf.md
Last active October 21, 2019 03:52
Getting Pow to work in OS X Yosemite

Getting Pow to work in OS X Yosemite

Some parts taken from: https://gist.github.com/kujohn/7209628

ipfw is officially deprecated and removed in OS X Yosemite. Pow requires another program pf to handle the port forwarding.

1. Anchor file

Create file /etc/pf.anchors/pow