Skip to content

Instantly share code, notes, and snippets.

View christhekeele's full-sized avatar
💜

Christopher Keele christhekeele

💜
View GitHub Profile
@christhekeele
christhekeele / a_list_of_styleguides.md
Last active August 29, 2015 13:56
My personal collection of styleguides, with rationalizations for most preferences.

Styleguides

These are my personally cultivated styleguides for different types of text (normally code or markup).

They're less about common conventions (ie. put single spaces between sentences or new lines between different contexts) and more about what syntax features to prefer or avoid in which contexts. As such, they expect the reader to be familiar with the language or markup in question. They are not suitable introductory material to a syntax.

Comments and discussion are welcome, otherwise I'd just keep these in my head instead of on a publicly available forum. I especially invite you to try and change my mind: these, like all opinions and code, are works in progress; not absolutes.

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in the OXFORD ENGLISH DICTIONARY.

@christhekeele
christhekeele / pre-commit
Last active May 3, 2016 00:19
Ever committed with `gem 'foobar', path: '~/source'` in your Gemfile and broken a build?This git pre-commit hook ensures you never will again.If you try and commit while a gem in your Gemfile is loading with the `:path` option, you will be stopped with a helpful message. The only exception: gems embedded within your project are allowed.
#!/usr/bin/env ruby
# A pre-commit hook script to ensure that no local gem dependencies (gem 'asdf', path: '~/local')
# exist in your Gemfile before commiting.`
# Allows gems to be loaded from source within the current project directory, but not from outside.
puts 'Checking for local dependencies in your Gemfile.'
ROOT_PATH = File.expand_path('../../..', __FILE__)
NESTED_GEMSPECS = Dir["#{ROOT_PATH}/**/*.gemspec"]
GEMFILE = ENV['BUNDLE_GEMFILE'] || File.join(ROOT_PATH, 'Gemfile')
@geedelur
geedelur / vagrant-librarian-chef-windows.md
Last active January 15, 2018 21:35
vagrant librarian chef windows
@edubkendo
edubkendo / atom_opal.md
Last active April 19, 2018 05:09
Writing Atom Plugins in Opal (Ruby)

I want to write plugins for Atom's editor in Ruby. Opal makes this possible. Atom is one of several projects in recent times to combine Chromium with Node.js for a desktop app. While it utilizes chromium for it's gui, and boasts "[e]very Atom window is essentially a locally-rendered web page", writing Atom plugins is more like writing a server-side node.js app than a typical single-page client-side app (albeit with really awesome integration with Chrome Devtools). Opal development, on the other hand, has to-date been focused primarily on the browser use-case.

Because of this, I had to make a choice between using the opal-node package from npm, using Opal via Ruby w/ a compile step, or packaging up opal-parser.js, including it with the app, and writing in compilation on the fly. Each choice came with compromises. Using opal-node would have been easiest, just create a top level index.coffee that required opal-node, and then require in your ruby

@twolfson
twolfson / README.md
Last active October 21, 2020 01:49
Leverage Flask-SQLAlchemy with Celery

Last update: Feb 3, 2015

Flask-SQLAlchemy has some nice built-ins (e.g. accessing query directly on classes). To continue leveraging these nicities while still inside of a Celery worker, we need to make sure we setup/teardown in a similar fashion to Flask-SQLAlchemy does on Flask.

Setup

Flask-SQLAlchemy uses create_scoped_session at startup which avoids any setup on a per-request basis.

https://github.com/mitsuhiko/flask-sqlalchemy/blob/2.0/flask_sqlalchemy/__init__.py#L668

This means Celery can piggyback off of this initialization.

defmodule Curried do
defmacro defc({name, _, args}, [do: body]) do
curried_args = Enum.map(Enum.with_index(args), fn({_, index}) ->
Enum.take(args, index + 1)
end)
for a <- curried_args do
if a == Enum.at(curried_args, Enum.count(curried_args) - 1) do
quote do
def unquote(name)(unquote_splicing(a)) do
unquote(body)
@jodosha
jodosha / Gemfile
Last active December 9, 2020 15:09
Full stack Lotus application example
source 'https://rubygems.org'
gem 'rake'
gem 'lotus-router'
gem 'lotus-controller'
gem 'lotus-view'
group :test do
gem 'rspec'
gem 'capybara'
@dpsk
dpsk / deploy.rb
Created July 5, 2012 12:42 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn (production-ready setup)
# Capistrano configuration
#
# require 'new_relic/recipes' - Newrelic notification about deployment
# require 'capistrano/ext/multistage' - We use 2 deployment environment: staging and production.
# set :deploy_via, :remote_cache - fetch only latest changes during deployment
# set :normalize_asset_timestamps - no need to touch (date modification) every assets
# "deploy:web:disable" - traditional maintenance page (during DB migrations deployment)
# task :restart - Unicorn with preload_app should be reloaded by USR2+QUIT signals, not HUP
{
"Inspect": {
"prefix": "ins",
"body": "|> IO.inspect(label: \"$0$TM_LINE_NUMBER\")",
"description": "Adds a pipeline with a labelled `IO.inspect`",
}
}
CREATE OR REPLACE FUNCTION rebuild_view() RETURNS event_trigger AS
$rebuild_view$
DECLARE
table_name text;
view_name text;
BEGIN
SELECT object_identity INTO table_name FROM pg_event_trigger_ddl_commands() LIMIT 1;
SELECT split_part(table_name, '.', 1) || '.v_' || split_part(table_name, '.', 2)
INTO view_name;
EXECUTE 'DROP VIEW IF EXISTS ' || view_name;