Skip to content

Instantly share code, notes, and snippets.

View joshhepworth's full-sized avatar
👾

Josh Hepworth joshhepworth

👾
  • Huckberry
  • Oklahoma City
View GitHub Profile
@ngauthier
ngauthier / bink.rb
Created March 31, 2014 14:08
Bink CLI Example
#!/usr/bin/env ruby
require_relative '../config/environment'
Bundler.require :bot
name = ARGV[1]
csv = "#{name}.csv"
bot = Bink.new csv
command = ARGV[0]
@diN0bot
diN0bot / index.html
Created September 1, 2012 18:13 — forked from syntagmatic/index.html
Wild Spiral
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Archimedean Spiral</title>
<script type="text/javascript" src="http://d3js.org/d3.v2.js"></script>
<style>
body {
font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif;
margin: 40px;
@joshhepworth
joshhepworth / lockdown.rb
Created September 3, 2013 18:28
Setup basic auth as a middleware for a rack application.
class Lockdown
def initialize(app)
@app = app
end
def call(env)
request = Rack::Request.new(env)
if request.path != '/'
auth = Rack::Auth::Basic::Request.new(env)
@weppos
weppos / capistrano_database_yml.rb
Created July 27, 2008 10:04
Provides a couple of tasks for creating the database.yml configuration file dynamically when deploy:setup is run.
#
# = Capistrano database.yml task
#
# Provides a couple of tasks for creating the database.yml
# configuration file dynamically when deploy:setup is run.
#
# Category:: Capistrano
# Package:: Database
# Author:: Simone Carletti <weppos@weppos.net>
# Copyright:: 2007-2010 The Authors
#!/usr/bin/env ruby
# Copyright (c) 2011 Henrik Hodne
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
@Gurpartap
Gurpartap / gist:1495827
Created December 19, 2011 07:10
Load custom fonts in iOS
#import <dlfcn.h>
NSUInteger loadFonts() {
NSUInteger newFontCount = 0;
NSBundle *frameworkBundle = [NSBundle bundleWithIdentifier:@"com.apple.GraphicsServices"];
const char *frameworkPath = [[frameworkBundle executablePath] UTF8String];
if (frameworkPath) {
void *graphicsServices = dlopen(frameworkPath, RTLD_NOLOAD | RTLD_LAZY);
if (graphicsServices) {
BOOL (*GSFontAddFromFile)(const char *) = dlsym(graphicsServices, "GSFontAddFromFile");
@henrik
henrik / string_filter.rb
Last active March 25, 2020 08:04
Share some parameter string filter between controller and view.
# Suitable when a controller and view share some parameter string.
#
# E.g. view:
#
# link_to_unless(filter.blank?, "All", filter: filter.blank)
# link_to_unless(filter.some?, "Some", filter: filter.some)
# link_to_unless(filter.others?, "Others", filter: filter.others)
#
# Or maybe:
#
@subelsky
subelsky / puma_rails_heroku.rb
Created October 31, 2012 13:51
Setting up Puma and Rails on Heroku
# Gemfile
gem "puma"
# Procfile
web: bundle exec puma -p $PORT -e $RACK_ENV -C config/puma.rb
# add to config block config/environments/production.rb
config.threadsafe!
# get rid of NewRelic after_fork code, if you were doing this:
@jdennes
jdennes / LICENSE
Last active March 7, 2024 04:40
Subscribing to a Campaign Monitor list using AJAX
The MIT License (MIT)
Copyright (c) James Dennes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@dhh
dhh / gist:1014971
Created June 8, 2011 18:09
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end