Skip to content

Instantly share code, notes, and snippets.

Philippe Creux pcreux

Block or report user

Report or block pcreux

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pcreux
pcreux / Gemfile
Last active Jun 25, 2019
Fast Rails + Heroku Configuration
View Gemfile
group :production do
gem 'unicorn'
# Enable gzip compression on heroku, but don't compress images.
gem 'heroku-deflater'
# Heroku injects it if it's not in there already
gem 'rails_12factor'
end
@pcreux
pcreux / format_bundle_outdated.rb
Created May 31, 2019
Format 'bundle outdated' into a CSV file ordered by version delta
View format_bundle_outdated.rb
#!/usr/bin/env ruby
#
# Run `bundle outdated | format_bundle_outdated`
# to get a CSV file listing the columns below for all outdated gems.
COLUMNS = [ "name", "newest", "installed", "requested", "groups", "delta" ].join(",")
class Version < Struct.new(:major, :minor, :patch, :beta)
def self.build(string)
new(*string.split('.').map(&:to_i))
@pcreux
pcreux / sendgrid via curl
Created Sep 27, 2013
Send email via the command line with sendgrid. Get notified when a long running script is done on a remote server.
View sendgrid via curl
curl "https://sendgrid.com/api/mail.send.json?api_user=YOUR_USER&api_key=YOUR_API_KEY&to=recipient@example.com&from=sender@example.com&subject=Import+done&text=Done"
@pcreux
pcreux / complete.sh
Created Feb 18, 2013
Github Commit Status API with Bamboo from Atlassian. Add those to your plan as Script.
View complete.sh
# specs and cukes results are stored in JUnit format under test-reports
if (grep 'failures="[^0]"' test-reports/* || grep 'errors="[^0]"' test-reports/*); then
curl -H "Authorization: token MY_TOKEN" --request POST --data '{"state": "failure", "description": "Failed!", "target_url": "${bamboo.buildResultsUrl}"}' https://api.github.com/repos/USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
else
curl -H "Authorization: token MY_TOKEN" --request POST --data '{"state": "success", "description": "Success!", "target_url": "${bamboo.buildResultsUrl}"}' https://api.github.com/repos/USER/REPO/statuses/${bamboo.repository.revision.number} > /dev/null
fi
@pcreux
pcreux / 0-gourmet-service-objects.md
Last active Dec 21, 2018
Gourmet Service Objects - Lightning Talk - http://vanruby.org - Feb 27, 2014
View 0-gourmet-service-objects.md

Gourmet Service objects

 @pcreux

 Feb 27, 2014
 http://vanruby.org
@pcreux
pcreux / Jabber-SH
Created Dec 17, 2009
Jabber-SH — SH console via XMPP/Jabber (GTalk) Jabber-SH allows to you to administrate a remote computer via a command line through a Jabber client. It’s like SSH via GoogleTalk! :)
View Jabber-SH
#!/usr/bin/env ruby
# Jabber-SH — SH console via XMPP/Jabber (GTalk)
#
# Jabber-SH allows you to administrate a remote computer via a command line
# through a Jabber client. It’s like SSH via GoogleTalk! :)
# This is just a hack but it might be usefull sometime to run basic commands
# on a machine that is not accessible via ssh.
#
# Philippe Creux. pcreux/AT/gmail/DOT/com
@pcreux
pcreux / pipable.rb
Last active Jun 12, 2018
*nix has pipes, Elixir has pipes, Ruby deserves pipes.
View pipable.rb
# Elixir has pipes `|>`. Let's try to implement those in Ruby.
#
# I want to write this:
#
# email.body | RemoveSignature | HighlightMentions | :html_safe
#
# instead of:
#
# HighlightMentions.call(RemoveSignature.call(email.body)).html_safe
#
@pcreux
pcreux / 000 Oh no conditionals!.png
Last active Jun 6, 2018
Turning imperative conditionals into declarative rules
@pcreux
pcreux / 000_robust_rails_apps.md
Last active May 14, 2018
Robust Rails Apps - VanRuby - March 29, 2017
View 000_robust_rails_apps.md

Robust Rails Apps

Philippe Creux - @pcreux

#vanruby - March 29th, 2017

@pcreux
pcreux / convert-to-ipad.rb
Last active May 3, 2018
ffmpeg - avi to mp4 - iPad
View convert-to-ipad.rb
# ruby convert-to-ipad.rb video1.avi video2.avi video3.avi
#
# Prereq: brew install ffmpeg
ARGV.each do |input_file|
output_file = input_file.gsub('.avi', '.ipad.mp4')
cmd = "ffmpeg -i #{input_file} -acodec aac -ac 2 -strict experimental -ab 160k -s 1024x768 -vcodec libx264 -preset slow -profile:v baseline -level 30 -maxrate 10000000 -bufsize 10000000 -b 1200k -f mp4 -threads 0 #{output_file}"
puts cmd
system cmd
end
You can’t perform that action at this time.