Skip to content

Instantly share code, notes, and snippets.

View ryangraham's full-sized avatar
😝

Ryan Graham ryangraham

😝
View GitHub Profile
@ryangraham
ryangraham / aws-apigw-delete-base-path-mapping.sh
Created February 12, 2021 21:14 — forked from mikaelvesavuori/aws-apigw-delete-base-path-mapping.sh
AWS API Gateway: Delete base path mapping
aws apigateway delete-base-path-mapping --domain-name domain.tld --base-path "(none)"
# Reference: https://docs.aws.amazon.com/cli/latest/reference/apigateway/delete-base-path-mapping.html
@ryangraham
ryangraham / print_tree.c
Created May 25, 2020 03:32 — forked from ximik777/print_tree.c
Printing Binary Trees in Ascii
/*
Copy from: http://web.archive.org/web/20090617110918/http://www.openasthra.com/c-tidbits/printing-binary-trees-in-ascii/
Source: http://web.archive.org/web/20071224095835/http://www.openasthra.com:80/wp-content/uploads/2007/12/binary_trees1.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ryangraham
ryangraham / nested_maps.md
Created March 10, 2020 20:48 — forked from blackode/nested_maps.md
Nested Maps in Elixir

#Get a value from nested maps

The get_in function can be used to retrieve a nested value in nested maps using a list of keys.

nested_map = %{ name: %{ first_name: "blackode"} }     #Example of Nested Map
first_name = get_in(nested_map, [:name, :first_name])  # Retrieving the Key

# Returns nil for missing value 
nil = get_in(nested, [:name, :last_name])              # returns nil when key is not present
@ryangraham
ryangraham / 016_session_store.rb
Created April 24, 2012 22:29 — forked from jstorimer/016_session_store.rb
Multiple session store implementation
RedisSessionStore.logger = Rails.logger
session_options = {:expire_after => 1.day, :key_prefix => 'sessions'}
MultiSessionStore.stores[:plain] = [RedisSessionStore, session_options.merge(:key => '_session_id')]
MultiSessionStore.stores[:secure] = [RedisSessionStore, session_options.merge(:key => '_secure_session_id', :secure => ['production', 'staging'].include?(Rails.env))]
MultiSessionStore.default_store = :plain
MultiSessionStore.routes = [
['/admin', :secure],
]
@ryangraham
ryangraham / cookbooks.sh
Created March 26, 2012 21:53 — forked from dysinger/cookbooks.sh
Re-write Opscode Cookbooks as individual Git repos
#!/bin/bash
for cookbook in $(find * -type d -maxdepth 0); do
git clone ./ ../${cookbook}
cd ../${cookbook}
git remote rm origin
git filter-branch --subdirectory-filter ${cookbook} -- --all
git gc --aggressive
done
@ryangraham
ryangraham / poke_everyone.user.js
Created November 3, 2011 22:10 — forked from Eckankar/poke_everyone.user.js
Poke everyone on Facebook!
// ==UserScript==
// @name Poke everyone!
// @description Pokes everyone you specify.
// @author Sebastian Paaske Tørholm
// @include http://*.facebook.com/*
// @include https://*.facebook.com/*
// @match http://*.facebook.com/*
// @match https://*.facebook.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js
// @version 1.0
@ryangraham
ryangraham / model-tests-in-tornado.py
Created July 21, 2011 16:54 — forked from didip/model-tests-in-tornado.py
Example on how to tests your model classes in Tornado
import unittest, os, os.path, sys
import tornado.database
import tornado.options
from tornado.options import options
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
# import your model module
import your.model as model