Skip to content

Instantly share code, notes, and snippets.

View hynkle's full-sized avatar

Jonathan Hinkle hynkle

View GitHub Profile
@henrik
henrik / poolboy_demo.ex
Last active December 16, 2020 13:56 — forked from sasa1977/poolboy_demo.ex
Example of using Poolboy in Elixir to limit concurrency (e.g. of HTTP requests).
defmodule HttpRequester do
use GenServer
def start_link(_) do
GenServer.start_link(__MODULE__, nil, [])
end
def fetch(server, url) do
# Don't use cast: http://blog.elixirsips.com/2014/07/16/errata-dont-use-cast-in-a-poolboy-transaction/
timeout_ms = 10_000
@clemens
clemens / minimum_rights_policy.json
Created September 5, 2014 09:39
Minimum rights policy for S3 that works just fine with CarrierWave/Fog
{
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket" ],
"Resource": [ "arn:aws:s3:::BUCKETNAME" ]
},
{
"Effect": "Allow",
"Action": [ "s3:PutObject", "s3:GetObject", "s3:DeleteObject"],
@avdi
avdi / gist:9038972
Created February 16, 2014 19:00
Get syntax highlighted source code for pasting into e.g. Google Docs on Linux
# You will need the pygments and xclip packages
# This example highlights some Bash source code
# '-O noclasses=true' tells pygments to embed colors inline in the source
# the '-t text/html' option tells xclip what "target" to specify for the selection
pygmentize -l bash -f html -O noclasses=true mysource.sh | xclip -selection clipboard -t text/html
require "timeout"
module WaitSteps
extend RSpec::Matchers::DSL
matcher :become_true do
match do |block|
begin
Timeout.timeout(Capybara.default_wait_time) do
sleep(0.1) until value = block.call
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@robertomiranda
robertomiranda / gist:1168322
Created August 24, 2011 15:34
Find tournament's players by categories
class Tournament < ActiveRecord::Base
#SELECT "players".*
#FROM "players"
#WHERE "players"."id" IN (
#SELECT "players"."id"
#FROM "players"
#INNER JOIN "pairs"
#ON ("pairs"."player_id" = "players"."id" OR "pairs"."partner_id" = "players"."id") AND "pairs"."tournament_id" = 4)
def player
players = Player.arel_table
@matthewmccullough
matthewmccullough / terminal.scpt
Created January 5, 2010 00:30
AppleScript to open a Terminal tab at the specified path
-----------------------------------------------------------------------
-- A Script that opens a specified command line folder name in a new
-- terminal tab.
--
-- Composed by Matthew McCullough, 2010
-- MIT License. Share freely.
-----------------------------------------------------------------------
--Reference for tab opening
-- http://lambie.org/2007/11/03/tabs-in-terminal-using-applescript-on-leopard/
--Reference for other scripting approaches with Terminal
require "rubygems"
require "nokogiri"
require "uri"
module Rack
class KarmaChameleon
def initialize(app, options = {})
@ext = options[:extension] || "aspx"
@ext_regexp = /\.#@ext$/
@app = app
@endolith
endolith / Has weird right-to-left characters.txt
Last active July 17, 2024 12:41
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶