Skip to content

Instantly share code, notes, and snippets.

@sparkertime
sparkertime / convert.sh
Last active April 19, 2022 16:32
Supplementary files for converting Pivotal to JIRA
sed -i -e "s/######/h6./" $1
sed -i -e "s/#####/h5./" $1
sed -i -e "s/####/h4./" $1
sed -i -e "s/###/h3./" $1
sed -i -e "s/##/h2./" $1
@sparkertime
sparkertime / ecto_postgres_fulltext_search_querying_example.ex
Created November 22, 2021 22:21 — forked from renesugar/ecto_postgres_fulltext_search_querying_example.ex
How to set up postgres fulltext search triggers, index, and tsvector column on Elixir/Phoenix, with Ecto querying, including ranking and sorting by rank
defmodule YourAppName.Search do
# ...
@doc """
Queries listings.
"""
def query_listings(query, current_user) do
default_scope = from l in Listing, where: l.draft == false or l.user_id == ^current_user.id, order_by: [desc: l.updated_at], limit: 50
id = _try_integer(query)
@sparkertime
sparkertime / gist:7978e9e474d40359a550
Created May 26, 2015 17:55
OggDude format - barebones
<?xml version='1.0'?>
<Adversary xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
<LastChanged>2014-01-01T00:00:00.000</LastChanged>
<NotPersisted>false</NotPersisted>
<FileName>Adver3.xml</FileName>
@sparkertime
sparkertime / GlobalExtensions.cs
Created July 30, 2014 19:27
When a Rubyist writes C#...
using System;
public static class GlobalExtensions {
public static bool IsNull<T>(this T self) {
return self == null;
}
public static bool IsPresent<T>(this T self) {
return !self.IsNull();
}
@sparkertime
sparkertime / maximum-verbosity.md
Last active December 21, 2015 02:49
A response to http://blog.softwarecurmudgeon.com/blog/2013/08/13/compojure-is-letting-us-down/, a well written and clearly thought-provoking article from my friend William.

I understand where your pain is coming from, but I think the cure is worse than the disease. Your currying approach introduces "argument noise" that is prevalent amongst dependency injection techniques. Namely, a change in the dependencies of one low-level method percolates all the way to the very top of your application. So in your example, every bit of shared configuration bubbles to the very top of your application like so:

(defn create-bid [db]
  (fn [request]
    (transact db tx-data)

(defn build-routes [db]
  (defroutes routes
 (POST "/bids" [] (actions/create-bid db))
@sparkertime
sparkertime / gist:3895759
Last active October 11, 2015 17:47
Junior-level Developer @ The Greatest Good

This position has been filled for now - sorry!

Hey, you junior-level developer with a love of learning! Let’s work together!

Since I can’t say too much publicly about the fun consumer-facing projects we’re building here at The Greatest Good, let me tell about our values.

Love what you do - If we don’t consistently love our work and coming into the office, something is broken. We proactively work to identify and eliminate those problems to keep the love alive.

Always be learning - I’m frequently the dumbest guy in the room here. It’s awesome. If hearing phrases like “chi-squared distribution” or “k-means clustering” sets your heart a-flutter, we might be perfect for each other.

@sparkertime
sparkertime / temporary_dsl.rb
Created July 18, 2012 02:15 — forked from heisters/temporary_dsl.rb
A Ruby 1.9 DSL strategy
# An unintrusive, temporary DSL strategy.
#
# Why discusses Ruby DSLs and instance_eval vs. block arguments:
# http://hackety.org/2008/10/06/mixingOurWayOutOfInstanceEval.html
#
# This takes advantage of some Ruby 1.9 features to implement a DSL mixin that
# is temporary and doesn't override locally defined methods.
class DslInstance
attr_accessor :script
@sparkertime
sparkertime / chicago.rake
Created July 13, 2012 23:10
Thresher - Separates the Wheat from the Chaff
require "rake"
require "csv"
require_relative '../../lib/thresher_sketch'
namespace :chicago_new do
namespace :contracts do
desc "Load city contracts"
task :load => :environment do
file_name = path_to(ENV["contracts_file"] || "Contracts.csv")
/* Prototype JavaScript framework, version 1.6.1
* (c) 2005-2009 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site: http://www.prototypejs.org/
*
*--------------------------------------------------------------------------*/
var Prototype = {
Version: '1.6.1',
require 'haml'
require 'haml/html'
require 'httparty'
module Jekyll
class SyntaxBlock < Liquid::Block
def initialize(tag_name, language, tokens)
super
@language = language
end