This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns query-optim.core | |
(:require [clojure.spec :as s] | |
[clojure.spec.gen :as gen] | |
[clojure.string :refer [starts-with?]] | |
[clojure.test.check.generators :as generators])) | |
(s/def ::query | |
(s/cat :find-spec ::find-spec | |
:with-clause (s/? ::with-clause) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'csv' | |
require 'socket' | |
class AverageSessionsPerServer | |
Server = Struct.new(:name, :current_sessions, :status) do | |
META_SERVER_NAMES = ['FRONTEND', 'BACKEND'].freeze | |
def up? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'open3' | |
describe 'unnest' do | |
it 'can unnest nested class definitions in a file' do | |
example_input = <<-EOF | |
module A::B | |
class C::D::E < F::G | |
def initialize(foo) | |
@foo = foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Mixin | |
def fail | |
raise "ARRRGH!" | |
end | |
alias_method :blurgh, :fail | |
end | |
class Includer | |
include Mixin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% unless form.object.errors.empty? %> | |
<div class="alert alert-danger"> | |
<p><strong>Bummer!</strong> Try again after fixing this up:</p> | |
<% form.object.errors.full_messages.each do |message| %> | |
<ul> | |
<li><%= message %></li> | |
</ul> | |
<% end %> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH RECURSIVE ancestors(id, name, created_at, updated_at) AS ( | |
SELECT categories.id, categories.name, categories.created_at, categories.updated_at | |
FROM categories, categorizations | |
WHERE categorizations.subcategory_id = '667C9DF5-48C0-496B-922A-1B7D743B1A39' | |
AND categories.id = categorizations.category_id | |
UNION ALL | |
SELECT categories.id, categories.name, categories.created_at, categories.updated_at | |
FROM categories, categorizations, ancestors | |
WHERE categorizations.subcategory_id = ancestors.id | |
AND categories.id = categorizations.category_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns categories.core | |
(:require [datomic.api :as d])) | |
(let [uri (str "datomic:mem://" (gensym)) | |
conn (and (d/create-database uri) (d/connect uri))] | |
@(d/transact conn [{:db/id #db/id[:db.part/db] | |
:db/ident :category/name | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
renameKey = (from, to, obj) -> | |
results = {} | |
for k, v of obj | |
if k == from | |
results[to] = v | |
else | |
results[k] = v | |
results | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require 'bundler/inline' | |
rescue LoadError => e | |
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
raise e | |
end | |
gemfile(true) do | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Act like Vim | |
setw -g mode-keys vi | |
# Use the mouse | |
set -g mode-mouse on | |
# Look good | |
set -g default-terminal "screen-256color" | |
set -g status-right "#[fg=black]#(rbenv version | awk '{ print $1 }' 2> /dev/null)" | |
set -g status-bg "blue" |