Skip to content

Instantly share code, notes, and snippets.

#> lower_bound upper_bound fdo_count_to_suspend_on
#> 1 0 18 2
#> 2 19 86 3
#> 3 87 180 4
#> 4 181 310 5
#> 5 311 inf 6
@djburdick
djburdick / docker_cheatsheet
Last active May 28, 2019 18:21
Docker cheatsheet
Commands:
docker run hello-world # run container
docker run -d -p 4000:80 hello-world # run in the background on port 4000
docker container stop CONTAINER_ID # stop container id
docker stop $(docker ps -a -q) # stop all containers
docker image ls # list images
docker container ls --all # list all containers
docker build -t appname . # build the app in currect dir
### TODO: dockerize all envs to avoid env specific hacks like this
group :development, :test, :production do
gem 'wkhtmltopdf-binary'
end
### TODO: dockerize all envs to avoid env specific hacks like this
# wkhtmltopdf-binary library needed a different binary to work on staging server
group :staging do
gem 'wkhtmltopdf-binary', git: 'https://github.com/djburdick/wkhtmltopdf_binary_gem.git', branch: 'master'
end
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-i386.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-i386.tar.bz2
sudo mv wkhtmltopdf-i386 /usr/local/bin/wkhtmltopdf
  1. Order cert (Godaddy wildcard etc...)
  2. openssl genrsa -des3 -out server.pass.key 2048
  3. openssl rsa -in server.pass.key -out server.key
  4. openssl req -nodes -new -key fixed.key -out fixed.csr Common name must be domain name (eg: www.fixed.com or *.fixed.com for wildcard)
  5. Go to Ec2->Load Balancers->Listeners then upload the new cert and private key
    a. pbcopy < fixed.key # private key
    b. pbcopy < 8sdf23ljksfds.crt # public key certificate
    c. pbcopy < gd_bundle-g2-g1.crt # certificate chain
@djburdick
djburdick / search_and_replace_all
Created July 21, 2015 18:14
Search and replace command line. #linux
find . -name '*rb' -type f -exec perl -pi -e 's/OldClassName(?!\w)/NewClassName/g;' \{\} \;
@djburdick
djburdick / add_rand_time_to_delayed_jobs
Created January 6, 2015 20:19
Add rand time to delayed_jobs. #mysql
update `delayed_jobs` set run_at = DATE_ADD(NOW(), INTERVAL 480+rand()*45 MINUTE) where `last_error` like "%ticketNumber=%"
@djburdick
djburdick / rubocop_circleci.rb
Created November 11, 2014 20:18
Run rubocop with circleci
# In spec_helper.rb
RSpec.configure do |config|
....
rubocop_output = `rubocop`
print rubocop_output
fail "RuboCop Errors" unless rubocop_output.match(/files inspected, no offenses detected/)
end
@djburdick
djburdick / network_lookup_tools
Last active August 29, 2015 14:08
Network lookup tools. #linux
curl -I fixed.com - show header info
host fixed.com
host www.fixed.com
whois fixed.com
nslookup fixed.com
nslookup -query=mx fixed.com
nslookup -type=ns fixed.com
ping fixed.com
dig +trace http://fixed.com
curl -s -w '\nLookup time:\t%{time_namelookup}\nConnect time:\t%{time_connect}\nPreXfer time:\t%{time_pretransfer}\nStartXfer time:\t%{time_starttransfer}\n\nTotal time:\t%{time_total}\n' -o /dev/null http://www.fixed.com
@djburdick
djburdick / ios_uiscrollview
Created June 6, 2014 18:43
Setup UIScrollView
1. embed content in uiview (select all and Editor -> Embed In)
2. embed that uiview in a uiscrollview
3. set uiscrollview size to phone screen size (eg: 320x568)
4. set uiview size to the size of the entire contest (eg: 320x900)
5. create property outlets for both uiview and uiscrollview
6. set the scrollview content size to the uiview size. self.scrollView.contentSize = self.contentView.bounds.size;
7. make sure the contentSize code is in - (void)viewDidAppear:(BOOL)animated (not in viewDidLoad)
or if in a navigation controller it must be in: viewDidLayoutSubviews