Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am ryantology on github.
* I am ryantology (https://keybase.io/ryantology) on keybase.
* I have a public key whose fingerprint is FF9D 7C56 0875 58A4 BB45 B935 A1DD B652 4A1F 4255
To claim this, I am signing this object:
@ryantology
ryantology / routes.php
Last active August 29, 2015 13:58
Laravel Admin Routing
<?php
// routes.php
Route::group(array('before' => 'check_auth', 'prefix' => 'admin', 'namespace' => 'Admin'), function() {
Route::resource('ideas', 'IdeasController');
});
// app/Controllers/Admin/IdeasController.php
namespace Admin;
class IdeasController extends \IdeasController {
MS Word smart quote: Projet d’apprentissage, la présentation d’idée doit être faite au nom d’un organisme
VS Straight Quotes: Projet d'apprentissage, la présentation d'idée doit être faite au nom d'un organisme
<?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
@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.
@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 / 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];
# Intended Query
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "intel",
"fields": [
"Name^5",
@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):
@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);