Skip to content

Instantly share code, notes, and snippets.

View luctraonmilin's full-sized avatar

Luc Traonmilin luctraonmilin

View GitHub Profile
@luctraonmilin
luctraonmilin / redirect-clippy-output-to-stdout
Created March 4, 2022 14:11
Redirect Cargo Clippy output to STDOUT
cargo clippy 2>&1 >/dev/null
# OK so I found this in a code base I am currently working on...
def parse_boolean(string)
string == 'true' ? true : false
end
@luctraonmilin
luctraonmilin / CustomFileSelect.html
Created October 24, 2014 08:39
Custom HTML file select button trick
<html>
<head>
<title></title>
<script type="text/javascript">
function selectFile() {
document.getElementById('file').click();
}
</script>
<style type="text/css">
#select-file {
@luctraonmilin
luctraonmilin / deploy.rb
Created September 5, 2014 10:10
Restart server after deploy with Capistrano 3
namespace :deploy do
# Restart the server.
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
@luctraonmilin
luctraonmilin / lambda.rb
Created April 17, 2014 13:50
Minimal lambda calculus interpreter
# This can be used as a starting point to build a Scheme or other
# dynamic language interpreter.
module Lambda
def evaluate(expression, environment)
if expression.is_a? Symbol
environment[expression]
elsif expression[0] == "\\"
[expression, environment]
else
@luctraonmilin
luctraonmilin / each_in_ruby.rb
Created November 25, 2013 11:03
A Ruby programming interview question I had a few days ago: implement the method each for Array. Here is my answer.
class Array
def each(&block)
map &block
self
end
end
@luctraonmilin
luctraonmilin / mighty.rb
Created September 27, 2013 19:45
A simple script for downloading and converting online web pages to PDF files.
#
# = Mighty
#
# Convert Matt Might blog articles (or others by the way) to PDF format.
# This is useful for keeping as references and offline reading.
#
# Author:: Luc Traonmilin
# Date:: 2013-09-27
# License:: MIT
#