Skip to content

Instantly share code, notes, and snippets.

View zenchild's full-sized avatar

Dan Wanek zenchild

View GitHub Profile
@zenchild
zenchild / README.md
Last active August 12, 2022 21:51
[2022-08-12] Fun Friday Code Challenge

Code Challenge for 2022-08-12

A Window into SQL

For this code challenge, we will be diving into a bit of SQL. There are two datasets, one with programmers (id, first_name, last_name) and another with their pull requests (id, user_id, language, created_at). The challenge is to simply get the coders with the top 20 amount of pull-requests and order first by the total number of pull requests and then by language. We are only interested in results newer than '2022-07-13T00:00:00Z'.

Hint: this can be done in one SQL statement.

Bonus: Can you do this without creating a table or temp table? Bonusly points for the first to figure this out.

@zenchild
zenchild / .gitignore
Last active February 4, 2021 01:51
Sync Gmail to Outlook
Gemfile.lock
credentials.json
ews_config.yaml
token.yaml
@zenchild
zenchild / pre-commit
Last active April 15, 2016 14:41
Git pre-commit to check for mistakes
#!/usr/bin/env bash
# vi:syntax=sh
check_for="(binding.pry|byebug)"
ignore_files="(Gemfile|Gemfile.lock)"
files_to_check=$(git diff-index --name-only HEAD -- | grep -Ev "^${ignore_files}$")
matches=$(grep -E "${check_for}" $files_to_check)
if [ ! -z "${matches}" ]; then
@zenchild
zenchild / prepare-commit-msg
Last active April 15, 2016 14:40
A prepare-commit-msg for Pivotal Tracker
#!/usr/bin/env bash
# This assumes that your branch is formatted like so:
# bug/<ticket_id>_<whatever here>
# feature/<ticket_id>_<whatever here>
edit_commit_message() {
local story_id="[#$1]"
sed -i "1i ${story_id}" "${msg_file}"
}
@zenchild
zenchild / database.sh
Created November 20, 2015 20:00
Save database functions
# vi: syntax=sh
backupDatabase() {
local db=$1
if [ -z $db ]; then
echo "You must pass a database name"
return 1
fi
if [ ! -z $2 ]; then
@zenchild
zenchild / upsertable.rb
Created September 9, 2015 03:51
Postgresql upsert
module Concerns::Upsertable
extend ActiveSupport::Concern
CASTABLE_TYPES = [
"boolean", "date", "integer", "double precision", "hstore",
"json", "jsonb", "timestamp without time zone"
].freeze
class_methods do
@zenchild
zenchild / kuchen.md
Last active August 29, 2015 14:21
Great Grandma's Kuchen Recipe

Great Grandma’s Kuchen

  • 1 Tube of Buttermilk Biscuit dough
  • 1 9” pie pan
  • 2-3 Peaches
  • 2 eggs
  • ½ C sugar
  • 1 C sour cream
  • 1 Tbsp corn starch
  • 1 Tsp vanilla
@zenchild
zenchild / ntlm_sign_seal.rb
Created November 21, 2014 16:33
ntlm sign + seal in ruby
rc4 = OpenSSL::Cipher::Cipher.new("rc4")
rc4.encrypt
key = ["6f0d99535033951cbe499cd1914fe9ee"].pack("H*")
rc4.key = key
crypt = rc4.update "jCIFS"
crypt << rc4.final
magicver = "\x01\x00\x00\x00"
seq = "\x00\x00\x00\x00"
@zenchild
zenchild / find_cal_items.rb
Created November 20, 2014 20:53
Find Calendar Items between 2 dates
items = client.find_items(folder_id: :calendar) {|builder|
builder.opts[:calendar_view] = {
start_date: (DateTime.now - 2).iso8601,
end_date: DateTime.now.iso8601
}
}
@zenchild
zenchild / random_tz.sh
Last active August 29, 2015 14:08
Set a random TZ variable for testing
TZ_SIGN=('-' '+')
export TZ=UTC${TZ_SIGN[$(( RANDOM % 2 ))]}$(( RANDOM % 25 ))
echo "Set TZ to: ${TZ}"