Skip to content

Instantly share code, notes, and snippets.

View dleve123's full-sized avatar

Daniel Levenson dleve123

View GitHub Profile
@dleve123
dleve123 / commit-count.sh
Created August 11, 2017 21:28
Commit Counts
# USAGE: run from directory that contains Git directories to iterate over
summary() {
for directory in $( ls -d */ ); do
cd $directory
if [ -d ".git" ]; then
git pull > /dev/null 2>&1
echo $directory,`commit_count`
fi
cd ..
@dleve123
dleve123 / query.rb
Created May 10, 2016 15:26
String Types Matter For Complicated ActiveRecord Queries
[29] pry(main)> Clinic.where("subdomain LIKE ?", "%\_%")
=> [#<Clinic:0x007f8212b97b98
id: 1,
name: "Factory Clinic 1",
subdomain: "factory-clinic-1",
privacy_policy: nil,
optional_data_sharing: false,
automated_texting: false,
company_id: 2>,
#<Clinic:0x007f8212b97a08
@dleve123
dleve123 / .vimrc
Last active August 7, 2023 15:34
Minimal vimrc for Git commit messages
" Motivated by https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message
syntax on " Turn on color syntax and allow custom Git commit message messages
autocmd Filetype gitcommit setlocal spell textwidth=72 " Spell check git commit messages and wrap text at column 72
@dleve123
dleve123 / switch_to_vundle.sh
Created July 26, 2015 22:04
Switch to Vundle
#!/bin/bash
vim_plugin_dirs=$(find vim/bundle -type d -maxdepth 1 -mindepth 1 | grep -v Vundle)
for dir in "${vim_plugin_dirs[@]}"; do
git rm --dry-run $dir
done
@dleve123
dleve123 / 01_failing_spec.rb
Last active August 29, 2015 14:25
RSpec Regex Match Woes
describe '#users_dropdown' do
subject { helper.users_dropdown(user) }
let(:team) { create(:team) }
let(:user) { create(:user, first_name: 'Current', last_name: 'User', userable: team) }
let(:same_team_user1) { create(:user, first_name: 'John', last_name: 'Friend', userable: team) }
let(:same_company_user2) { create(:user, first_name: 'Jack', last_name: 'Goodfriend') }
let(:other_company_user) { create(:user, first_name: 'Jane', last_name: 'Enemy') }
let(:deactivated_user) do
@dleve123
dleve123 / new_survey_creation.rb
Created October 30, 2014 22:31
Possible Refactoring for Survey Creation
class NewSurveyCreation
attr_reader :patient
def initialize(subdomain, params)
# store the data in instance variables
] end
def create!
set_patient_age!
set_bmi!
@dleve123
dleve123 / csv_stuff.rb
Created September 30, 2014 18:04
do something with headers one time in CSV
headers_read = false
CSV.foreach(headers: true) do |row|
validate_header_row(headers) unless headers_read
headers_read = true
# everything else
end
@dleve123
dleve123 / deploy.sh
Created June 18, 2014 16:52
not super secure deploy from travis to aptible
if [[ $TRAVIS_BRANCH == "master" && $TRAVIS_PULL_REQUEST == "false" ]]; then
echo "branch will be deployed!"
echo -e "Host beta.aptible.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
chmod 600 .travis/travis_key.pem
ssh-add .travis/travis_key.pem
git remote add staging git@beta.aptible.com:healthify-staging-aptible.git
git fetch --unshallow
@dleve123
dleve123 / incoming_texts_controller.rb
Created February 8, 2014 21:44
`rake routes` output and IncomingTexts Controller @ commit that implements POST endpoint for Twilio
class IncomingTextsController < ApplicationController
skip_before_filter :authenticate_user!
skip_before_filter :verify_authenticity_token
def parse
# parse incoming params from Twilio and conditionally text response to patient
end
end