Skip to content

Instantly share code, notes, and snippets.

@ryantology
ryantology / install-keys.sh
Last active December 6, 2018 19:18 — forked from codeslinger/gist:3494
Retrieve SSH public keys from GitHub and install to authorized_keys.
#!/bin/bash
# vim:set ts=4 sw=4 et ai:
# Retrieve SSH public keys from GitHub and install to authorized_keys.
GITHUB_USERS=(USER1 USER2)
INSTALL_FILE=/home/USER/.ssh/authorized_keys
TMP_KEY=/tmp/ssh.key
CURL=/usr/bin/curl
CURLOPTS="--retry 3 --retry-delay 2 --silent --fail -o $TMP_KEY"
@ryantology
ryantology / upgrade-mysql-mamp.sh
Last active July 18, 2017 03:19 — forked from dj1020/migrate.sh
Upgrade MAMP 4.0 to Mysql 5.7
#!/bin/sh
FILE='mysql-5.7.16-osx10.11-x86_64.tar.gz'
# MySQL direct is typically VERY slow. This uses a mirror. You can change the file source here.
#wget http://dev.mysql.com/get/Downloads/MySQL-5.7/$file
wget http://mysql.he.net/Downloads/MySQL-5.7/$FILE
#Signature from http://dev.mysql.com/downloads/mysql/
signature='e8c10d4600fc42bf8e111246982a57f4'
match=`md5 -q $FILE`
@ryantology
ryantology / README.md
Last active July 7, 2016 02:26 — forked from benschwarz/README.md
Intercom CSP (Content security policy)

You'll need to add a whole slew of hosts for intercom if you've got CSP in place (which you should).

Heres what you'll need to add (updated from intercom support request):

connect-src:
    api.intercom.io
    api-iam.intercom.io
    api-ping.intercom.io
 nexus-websocket-a.intercom.io
@ryantology
ryantology / hipchat-notify.js
Last active December 28, 2015 20:29
MineCraft + HipChat notification though nodejs. This is a quick little snippet that will let people in your hipchat server know that users have joined the minecraft server. Not sure what happens when the log file rotates.
Tail = require('tail').Tail;
tail = new Tail("latest.log");
HipChatClient = require('node-hipchat')
hipchat = new HipChatClient("*************************");
var loginPattern = /.*\[Server thread\/INFO\]: (.*) joined the game/;
tail.on("line", function(data) {
var loginMatch = data.match(loginPattern);
@ryantology
ryantology / gist:4248434
Created December 10, 2012 04:50
redmine 2.1 cookie error
Environment:
Redmine version 2.1.4.stable.10973
Ruby version 1.8.7 (i486-linux)
Rails version 3.2.8
Environment production
Database adapter MySQL
Redmine plugins:
no plugin installed
NoMethodError (cannot parse Cookie header: undefined method `size' for nil:NilClass):
# Intended Query
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "intel",
"fields": [
"Name^5",
@ryantology
ryantology / snatch.php
Created August 14, 2012 18:02
Grab embed id for youtube / vimeo videos
<?php if (preg_match('/http:\/\/www.youtube.com\/watch.*/', $this->request->data['Upload']['embed'], $matches)) {
parse_str(parse_url($this->request->data['Upload']['embed'],PHP_URL_QUERY),$vars);
$videoid = $vars['v'];
if (!$videoid) { break; }
$this->request->data['Upload']['type'] = 'youtube';
$this->request->data['Upload']['attribution'] = $videoid;
$videoThumb = $this->_getThumbYoutube($videoid);
}
if (preg_match('/http:\/\/(www\.)?vimeo.com\/(\d+)/', $this->request->data['Upload']['embed'], $matches)) {
$videoid = $matches[2];
@ryantology
ryantology / edgecast-cidr.txt
Created September 13, 2011 16:01
Edgecast Edge IP's in CIDR format
110.232.176.0/22
117.18.232.0/21
46.22.64.0/20
68.232.32.0/20
72.21.80.0/20
93.184.208.0/20
108.161.240.0/20
117.103.183.0/24
46.22.78.0/23
@ryantology
ryantology / gist:1150536
Created August 17, 2011 00:38
MySQL query for closest X records to Y point
# Query to get closest 10 records
SELECT `Idea`.`id`, `Idea`.`title`, `Idea`.`description`, `Idea`.`vote_count`, `Idea`.`fullname`, `Idea`.`location`, `Idea`.`orgname`, `Idea`.`finalist`, `Idea`.`semifinalist`, `Idea`.`winner`, `Idea`.`broker_winner`, `Idea`.`receive_donations`, `User`.`broker`, `User`.`brokerage_id`, `Category`.`id`, `Category`.`file_name`, `User`.`id` FROM `ideas` AS `Idea` LEFT JOIN `users` AS `User` ON (`Idea`.`user_id` = `User`.`id`) LEFT JOIN `categories` AS `Category` ON (`Idea`.`category_id` = `Category`.`id`) WHERE `Idea`.`removed` = 0 AND `Idea`.`approved` = 1 AND `contestyear` = '2010-01-01' AND ((((ROUND(`Idea`.`lat`, 4) != 43.666700) AND (ROUND(`Idea`.`lon`, 4) != -79.416700))) OR (((`Idea`.`lat` = 43.666700) AND (`Idea`.`lon` = -79.416700)))) ORDER BY (6371 * 2 * ATAN2( SQRT( SIN(RADIANS(43.6667 - `Idea`.`lat`)/2) * SIN(RADIANS(43.6667 - `Idea`.`lat`)/2) + SIN(RADIANS(-79.4167 - `Idea`.`lon`)/2) * SIN(RADIANS(-79.4167 - `Idea`.`lon`)/2) * COS(RADIANS(43.6667)) * COS(RADIANS(-79.
<?php
uses('http_socket');
class GeocodedBehavior extends ModelBehavior {
/**
* Index of geo-data lookup services. Each item contains a lookup URL with placeholders,
* and a regular expression to parse latitude and longitude values.
*
* @var array