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
def index(conn, _params) do | |
conn = conn | |
|> put_resp_content_type("text/csv") | |
|> put_resp_header("content-disposition", "attachment; filename=export.csv") | |
|> send_cunked(200) | |
Repo.transaction fn -> | |
Ecto.Adapters.SQL.stream(Repo, "COPY expensive_report TO STDOUT CSV HEADER") | |
|> Stream.map(&(chunk(conn, &1.rows))) | |
|> Stream.run |
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
#!/bin/bash | |
# | |
# DESCRIPTION | |
# | |
# Simple read-only comand-line interface to your Things 2 database. Since | |
# Things uses a SQLite database (which should come pre-installed on your Mac) | |
# we can simply query it straight from the command line. | |
# | |
# We only do read operations since we don't want to mess up your data. | |
# |
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
import Html.App as App | |
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Http | |
import Task | |
import Json.Decode as Json exposing ((:=)) | |
-- MODEL | |
type alias Model = |
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
#!/bin/sh | |
# Add this to .git/hooks/pre-commit to reject any commits | |
# that contain Git conflict markers. | |
if git diff --cached --name-only --diff-filter=ACM | xargs grep -H -n -E '^(<|>|=|\|){7}' > /dev/null; then | |
echo "\033[31mWarning:\033[0m You have left some Git conflict markers in." | |
echo 'Your commit is bad and you should feel bad.' | |
echo | |
git diff --cached --name-only --diff-filter=ACM | xargs grep -H -n -E '^(<|>|=|\|){7}' | |
exit 1 |
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
#!/bin/bash | |
git diff --cached --name-status --diff-filter=ACM | awk '/\.rb$/ { print $2 }' | xargs rubocop -f s | |
exit_code=$? | |
if [[ $exit_code != 0 ]] ; then | |
echo 'Your commit was rejected because Rubocop found style guide violations.' | |
echo 'Run `rake rubocop` to test your code and inspect the offenses Rubocop' | |
echo 'has found.' | |
echo | |
echo 'If you really, REALLY want to commit this code, skip your pre-commit' | |
echo 'hooks with `git commit --no-verify`.' |
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
#!/bin/sh | |
set -e | |
OLDREV=$1 | |
NEWREV=$2 | |
IS_BRANCH_CHECKOUT=$3 | |
function has_changes_to() { | |
git diff --name-only "$OLDREV" "$NEWREV" -- "$1" | grep "$1" > /dev/null |
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 | |
# ## Introduction | |
# | |
# Auto-labeling Git commits with issues tracker IDs found in the current | |
# branch name. This script is meant to be used as a Git commit-msg hook. It | |
# expects a single argument, the location of the temporary file with the commit | |
# message the user entered, and it outputs that same message with maybe some | |
# extra labels added to it. | |
# | |
# ## Example |
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
export COL=$COLUMNS; awk -F '[ ()]|ms' '/\[CatalogItem\] Retrieved/ { c[int($8 / $6 / 100) * 100 + 50] += $6 } END { for(l in c) { print l, c[l] } }' production.log | awk 'BEGIN { max = 0 } { if($2 > max) max = $2; c[$1] = $2 } END { for(l in c) { printf("%5d %d\n", l, c[l] / max * (ENVIRON["COL"] - 7)) } }' | awk '{ r = ""; s = $2; while(s-- > 0) { r = r "#" }; printf("%6d %s\n", $1, r); }' | sort -n |
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
export COL=$COLUMNS ; grep '\[CatalogItem\] Retrieved' production.log | awk '{ print $6 $7 }' | ruby -ne 'BEGIN { puts ENV.inspect;$columns = ENV["COL"].to_i; $all = Hash.new { |h,k| h[k] = 0 } }; a, b = $_.split("(").map(&:to_f); next if a < 1; $all[((b/a/100).floor)] += a.to_i; END { max_value = $all.values.max; puts "\e[2J\e[f"; puts "Average request time".center($columns); print "\033[37m" ; puts "ms/req ±50ms".center($columns); print "\033[0m" ; puts ("─" * $columns); $all.keys.sort.each { |k| puts "#{(k * 100 + 50).to_s.rjust(6)}: \033[31m#{"▓" * ($all[k].to_f / max_value * ($columns - 8))}\033[0m"; }; puts "─" * $columns; print "\033[5m\033[35m" ; puts "(╯°□°)╯︵ ┻━┻ © Arjan & Ariejan".center($columns); print "\033[0m" }' |
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 'fileutils' | |
NAME = ARGV[0] | |
MODULE_NAME = NAME.gsub(/(?:^|_)(.)/) { $1.upcase } | |
ROOT = File.join(FileUtils.pwd, NAME) | |
def in_dir(dir) | |
old_dir = FileUtils.pwd | |
FileUtils.cd dir | |
yield | |
FileUtils.cd old_dir |
NewerOlder