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
defmodule Rocket.Stringer do | |
def sanitize_phone(ph) do | |
ph = Regex.replace(~r/[^0-9]/,ph,"") | |
case Regex.run(~r/\d{5,10}$/,ph) do | |
[phone] -> phone | |
_ -> nil | |
end | |
end |
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
# Install dependencies | |
# | |
# * checkinstall: package the .deb | |
# * libpcre3, libpcre3-dev: required for HTTP rewrite module | |
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module | |
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \ | |
mkdir -p ~/sources/ && \ | |
# Compile against OpenSSL to enable NPN |
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
with v(dfrom, dto) as ( | |
VALUES('2014-01-01'::date, '2014-11-12'::date) | |
--VALUES(_from, _to) | |
), failures as ( | |
select user_id, 'data-entry'::citext as action, count(*) as "count" from ad_histories, v | |
where action='qc-fail' and created_at>=v.dfrom and created_at<=v.dto | |
and exists(select 1 from ad_histories subq where ad_id=subq.ad_id and subq.action='data-entry' limit 1) group by user_id | |
), elapsed as ( | |
select r.user_id,r.action,avg(r.elapsed) as "avg_time" from ( | |
select user_id,action, lead(created_at,1,now()) over w - created_at as elapsed |
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
type Repository struct { | |
Name string `json:"name"` | |
Description string `json:"description"` | |
Private bool `json:"private"` | |
} | |
// response to blog post https://willnorris.com/2014/05/go-rest-apis-and-pointers | |
type RepositoryPatch struct { | |
Repository |
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
deliver {reset_code: user.password_reset_code_deliver!} | |
#SyntaxError (/Users/troy/Projects/church/app/controllers/api/users_controller.rb:126: syntax error, unexpected ':', expecting '}' | |
# deliver {reset_code: user.password_reset_code_deliver!} | |
# ^): | |
deliver({reset_code: user.password_reset_code_deliver!}) | |
# umm, ok ruby so parens are optional when? |
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
# A Roberto Url is a tiny url. It depends on the cross-language hashids lib http://www.hashids.org/ | |
class RobertoUrlController < ApplicationController | |
layout false | |
# cursory glance at the code, this appears to be threadsafe | |
HASHER = ::Hashids.new("no offense rob, this is a tribute to your carb intake not your manhood") #change the salt and all urls are invalid! | |
PREFIX = "#{Rails.configuration.base_url}/l" | |
# note, extremely important that you do not change the keys of the object map as the | |
# hashing is tied to the sequence key: So add class maps to the end of the list! | |
# also, because classes can be models, use the string representation of the class |
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
// DAMN: THIS NO WORK because it watches the model, some how this also needs to tied | |
// into form submit for the cases where the model value was left blank | |
// for now, use this: ng-class || ng-show ="{ error: inviteForm.email.$invalid && inviteForm.email.$dirty }" | |
// Will toggle the css error class on the .control-group container and create/remove | |
// the error message. Also assumes data is not invalid in a pristine state | |
// depends on bootstrap form layout and jQuery; TODO: make work without jQuery | |
angular.module('blitUi', []).directive('showsValidation', function() { | |
return { | |
restrict: 'A', | |
link:function (scope, element, attrs) { |
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
select (select array(select a.e from unnest(matches) as a(e) where a.e != '%CHAN%')) from sms_keywords; |
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
COPY( | |
SELECT | |
p.id as "id", | |
p.payor_email as "email", | |
to_char(p.created_at,'YYYYMMDD') as "date", | |
pgroup.gross*0.01::money as "gross", | |
pgroup.refunded*0.01::money as "refunded", | |
f.name as "fund", | |
pgroup.fee*0.01::money as "fee", | |
(SELECT 'Paid') as "status", |
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
# download and install pcre | |
# download and unpack (mine was 2.4.3) latest stable apache | |
cd httpd-2.4.3 | |
export LTFLAGS='--tag CC' | |
# might have to symlink this file if you get a toolchain error | |
# sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain | |
./configure --silent --prefix=/usr/local/ --disable-debug --disable-dependency-tracking | |
cd support | |
make -s ab |