This file contains hidden or 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 bash | |
# Specify where we will install | |
# the ssl certificate | |
SSL_DIR="secrets" | |
# Set the wildcarded domain | |
# we want to use | |
DOMAIN="*.uvabht.org" |
This file contains hidden or 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
# /etc/sudoers.d/visudo-deb-conf (root:root, 0440) | |
# | |
# Visudo configuration for Debian (and Ubuntu?) systems | |
# Allows users in group 'staff' to do basic admin without a password | |
# | |
# Setup: | |
# groupadd staff | |
# usermod -a -G staff shuti | |
# chown root:root && chmod 0440 visudo-deb-conf | |
# cp ~/visudo-deb-conf /etc/sudoers.d/ |
This file contains hidden or 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
<!-- Around line 79 --> | |
<script src="mobile/player_compiled.js" type="text/javascript"></script> | |
<script> | |
// Insert the following 2 lines anywhere to enable autoplay on mobile | |
player.launch = $('<div></div>'); | |
window.setTimeout( player.revealPostInterstitial, 500 ); | |
// Storyline defaults | |
// player.autoplay = true; |
This file contains hidden or 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
class AverageTimes | |
# Accepts an array of objects (ActiveRecord collection probably) | |
# Computes the average time of day for a given :time_attr | |
# by converting times to degrees, calculating mean angle | |
# | |
# @sleep_diaries = Diary.all | |
# @average_times = AverageTimes( @sleep_diaries ) | |
# @average_bedtime = @average_times.of( :bed_at ) |
This file contains hidden or 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
## Find all time travel test participants | |
Participant.find( :all, :participant_type => 'Patient', :deleted => false, | |
:conditions => ['IFNULL(time_delta_days,0) != 0'] ) | |
## Reset time offset and timezone | |
@participant.time_delta_days = 0 | |
@participant.timezone = 'US/Eastern' | |
## Delete all of their moles and Diaries | |
@participant.moles.destroy_all |
This file contains hidden or 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
## /config/initializers/cast_value_as_boolean.rb | |
## | |
## Typecast a value to boolean using ActiveRecord(5.0) | |
## | |
## 'whatever'.to_b => true | |
## 0.to_b => false | |
## Supported types: | |
# Integer |
This file contains hidden or 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
-- Generated from prepared statements T1-T4 | |
CREATE VIEW t1_responses AS | |
SELECT participant_id, max(case prop_key when 't1_ethnicity' then prop_value else null end) AS t1_ethnicity,max(case prop_key when 't1_race_list' then prop_value else null end) AS t1_race_list,max(case prop_key when 't1_race_textbox' then prop_value else null end) AS t1_race_textbox,max(case prop_key when 't1_education' then prop_value else null end) AS t1_education,max(case prop_key when 't1_income' then prop_value else null end) AS t1_income,max(case prop_key when 't1_marital' then prop_value else null end) AS t1_marital,max(case prop_key when 't1_distress' then prop_value else null end) AS t1_distress,max(case prop_key when 't1_eyes' then prop_value else null end) AS t1_eyes,max(case prop_key when 't1_hair' then prop_value else null end) AS t1_hair,max(case prop_key when 't1_skincolor' then prop_value else null end) AS t1_skincolor,max(case prop_key when 't1_skinreaction' then prop_value else null end) AS t1_skinreaction,max(case prop |
This file contains hidden or 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
Use here documents with indentation | |
=================================== | |
Thanks to [@dhamidi](https://github.com/dhamidi) | |
```ruby | |
# somewhere in your code | |
# make sure to use tabs! | |
def some_method | |
<<-EOF.gsub(/^\t/, '') |
This file contains hidden or 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
(?:0?[1-9]|1[012])([\/.-])(?:0?[1-9]|[12]\d|3[01])([\/.-])(?:19|20)\d\d |
This file contains hidden or 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 | |
# message.sh | |
# Multicolored text formatting utility for bash | |
# | |
# Usage: | |
# message --help | |
# | |
# message -red "string1" -s -blue "string2" -t "string3" ... | |
# msg -error "ERROR:" -s -info "File not found" |