Skip to content

Instantly share code, notes, and snippets.

@djcp
djcp / elasticsearch.sh
Created April 23, 2019 14:43
Super simple elasticsearch init
#! /bin/sh
# TODO: check for openjdk-8-jre and fail out
DIR=~/code/work/elasticsearch
start_es(){
./elasticsearch-5.6.16/bin/elasticsearch
}
@djcp
djcp / interactive session
Created July 10, 2015 14:31
parsing URL paths deeply in the rails context
$ ./bin/rails runner parse_urls_deeply.rb
{:controller=>"videos", :action=>"index"}
{:controller=>"videos", :action=>"update", :id=>"2923e492348234981"}
@djcp
djcp / gist:0099e701515ae410ca07
Last active August 29, 2015 14:17
Materialized view aggregate index example
col1 | col2 | col_1_sum
------+------+-----------
1 | 2 | 2
1 | 2 | 2
(2 rows)
if ! pgrep -qf donuts; then
echo
echo "To start the image import app, please run:"
echo "cd ~/gameface_apps/donuts && RAILS_ENV=production foreman start -f Procfile"
echo "Leave the terminal running."
echo
fi;
@djcp
djcp / gist:e5569155b402fd62d837
Created June 18, 2014 17:43
Monkeypatch paperclip for fast processing during specs
module ImageHelpers
def fixture_file(path)
File.open(path)
end
end
module Paperclip
class Geometry
def self.from_file file
parse("100x100")
diff --git a/app/assets/javascripts/qdw/controllers/home_page_controller.js.coffee b/app/assets/javascripts/qdw/controllers/home_page_controller.js.coffee
index ed7acde..24c8ee3 100644
--- a/app/assets/javascripts/qdw/controllers/home_page_controller.js.coffee
+++ b/app/assets/javascripts/qdw/controllers/home_page_controller.js.coffee
@@ -1,2 +1,3 @@
-qdw.controller 'HomePageCtrl', ($scope, PageConfiguration) ->
+qdw.controller 'HomePageCtrl', ($scope, PageConfiguration, DateFilters) ->
$scope.layout = PageConfiguration.current()
+ DateFilters.hideDateFilters = true
diff --git a/app/assets/javascripts/qdw/controllers/initiatives_page_controller.js.coffee b/app/assets/javascripts/qdw/controllers/initiatives_page_controller.js.coffee

Keybase proof

I hereby claim:

  • I am djcp on github.
  • I am djcp (https://keybase.io/djcp) on keybase.
  • I have a public key whose fingerprint is 3E74 5BD8 D612 AE13 B9B9 B698 94BA 18C5 3BC1 C2C3

To claim this, I am signing this object:

@djcp
djcp / mime_type_tester.sh
Created February 14, 2014 18:32
Randomly sample files recursively from PWD to test for mime-types
#!/bin/bash
COMMAND='RAND=`shuf -n 1 -i 1-100`;
if [ $RAND = 1 ]; then
if [ -e "{}" ]; then
MIME_TYPE=`file -b --mime-type "{}"`
echo "$MIME_TYPE\t\t => {}"
if [ "$MIME_TYPE" = "" ]; then
echo "******************";
echo "{} HAD AN EMPTY MIME TYPE"
@djcp
djcp / parse.rb
Created November 6, 2013 21:40
Parse apache logs into a sqlite3 database via ruby. Pass log lines in via a plain ol' unix pipe - 'ruby parse.rb < access.log'. This assumes combined log format.
require 'rubygems'
require 'apachelogregex'
require 'sqlite3'
require 'time'
# LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
db = SQLite3::Database.new "access_log.db"
format = '%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"'
parser = ApacheLogRegex.new(format)
@djcp
djcp / Debian Jessie
Last active July 3, 2022 18:03
ubuntu / debian /etc/os-release files - and there was much gnashing of teeth and rending of flesh. . .
PRETTY_NAME="Debian GNU/Linux jessie/sid"
NAME="Debian GNU/Linux"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"