Skip to content

Instantly share code, notes, and snippets.

@ArtemGr
ArtemGr / openid_store.py
Created March 5, 2009 09:57
memcache openid store
"""Store implementation for the openidenabled.com python library, using the GAE's memcache."""
from openid.store.interface import OpenIDStore
from openid.store import nonce
import string, logging
import google.appengine.api.memcache
memcache = google.appengine.api.memcache.Client()
class MemcacheStore(OpenIDStore):
"""Implements http://openidenabled.com/files/python-openid/docs/2.2.1/openid.store.interface.OpenIDStore-class.html"""
@nutrun
nutrun / sinatra_reloader.rb
Created June 24, 2010 00:56
Code reloading for Sinatra
# For "Classic" style/top-level type of apps do something like:
#
# configure :development do
# require File.join(File.dirname(__FILE__), 'sinatra_reloader')
# set :reload_paths, [File.join(File.dirname(__FILE__), '**', '*.rb')]
# end
#
# For "Modular" style/Sinatra::Base subclasses:
#
# configure :development do
@weavejester
weavejester / gist:1001206
Created May 31, 2011 20:27
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
@mrrooijen
mrrooijen / .gitignore
Created February 1, 2012 18:04
MiddleMan on Heroku configuration.
.DS_Store
*.swp
*.swo
Gemfile.lock
@rberenguel
rberenguel / friendly_reddit_button.js
Last active December 23, 2015 10:49
A slightly better reddit upvote/downvote button
jQuery(document).ready(function() {
// This is the poor man's way of doing an straightforward, async load.
// I needed the reddit button in our pages, and our technical guy asked me
// to get an async version, since we have a very fast website and we'd rather
// keep it. Since reddit does not offer an async version this is the best I
// could come up after giving it 5 minutes thought. I could probably get
// something better which is actually async. Waiting for document.ready means that
// if something else is "very" blocking, the reddit button may never appear. But
// I'd rather settle for good enough than spend an stupidly long amount of time
// looking for the perfect solution to a minor problem.
@treeder
treeder / README.md
Last active April 27, 2018 20:34
Serving static site on app engine with golang

Put all your static files in /static directory. If you put index.html into /static, it will be served up as welcome file.

@roylines
roylines / remote-terraform-s3-policy
Created September 19, 2015 10:46
IAM policy to allow storing of remote terraform state in S3
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::my.bucket",
@macournoyer
macournoyer / Output
Last active January 9, 2023 15:12
A Neural Network framework in 25 LOC
$ python xor.py
Training:
Epoch 0 MSE: 1.765
Epoch 100 MSE: 0.015
Epoch 200 MSE: 0.005
* Target MSE reached *
Evaluating:
1 XOR 0 = 1 ( 0.904) Error: 0.096
0 XOR 1 = 1 ( 0.908) Error: 0.092
1 XOR 1 = 0 (-0.008) Error: 0.008
@kenoir
kenoir / gist:bed1a6ee7749137959fe2d372edeba86
Created March 31, 2016 15:17
AWS CLI Infra list incantations
aws cloudformation list-stacks | jq ".StackSummaries[].StackId" -r | grep "PROD"
aws ec2 describe-instances --filters Name=tag:Stage,Values=PROD | jq ".Reservations[].Instances[].InstanceId" -r
aws elb describe-load-balancers | jq ".LoadBalancerDescriptions[].LoadBalancerName" -r
aws autoscaling describe-auto-scaling-groups | jq ".AutoScalingGroups[].AutoScalingGroupName" -r | grep "PROD"
aws s3 ls | grep "prod" | awk '{print $3}'
aws ec2 describe-vpcs | jq ".Vpcs[].VpcId" -r
aws dynamodb list-tables | jq ".TableNames[]" -r | grep "PROD"
aws sqs list-queues | jq ".QueueUrls[]" -r | grep "PROD"
aws sns list-topics | jq ".Topics[].TopicArn" -r | grep "PROD"
@robertberry-zz
robertberry-zz / countPermutations.js
Created September 4, 2016 18:38
O(n) algorithm for counting permutations of a string in another string
function countChars(word) {
var counts = {};
for (var i = 0; i < word.length; i++) {
var letter = word[i];
if (letter in counts && counts.hasOwnProperty(letter)) {
counts[letter]++;
} else {
counts[letter] = 1;