Skip to content

Instantly share code, notes, and snippets.

Eric Bouchut ebouchut

Block or report user

Report or block ebouchut

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
@ebouchut
ebouchut / solarized-dark.css
Created Feb 7, 2017 — forked from qguv/solarized-dark.css
Solarized theme for Jekyll, updated to reflect toned-down line numbers
View solarized-dark.css
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
View set_SQL_sequence.sql
-- reset sequence to the max value of its ids
SELECT setval('public.mytable_id_seq', (SELECT MAX(id) FROM mytable));
-- get the last value of a sequence
SELECT last_value FROM mytable_id_seq;
@ebouchut
ebouchut / formatDateAsUTC.java
Created Oct 13, 2015
Format a Java Date as UTC String: yyyy-mm-dd HH:mm:ss'Z'
View formatDateAsUTC.java
publicString formatDateAsUTC(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
return sdf.format(date);
}
View Remove comment lines (#) from a file
# Remove comment that spans a whole line (like this one)
# and comments at the end of a line like the following
: echo "Hello" # comment at the end of a line
sed -e 's/#.*$//g' -e '/^[ \t]*$/d' file
@ebouchut
ebouchut / gist:83274db70170e363b444
Created Jul 20, 2015
Send a file to a URL using curl
View gist:83274db70170e363b444
curl $URL --data @$FILE -vv -L -H "Content-Type:application/json"
# curl $URL --trace-ascii - --data @$FILE -L -H "Content-Type:application/json"
View gist:ff0262995e93812b3790
tar cvzf ~/backup/project.tar.gz --dereference --exclude-vcs --exclude=/target/ project
@ebouchut
ebouchut / resize_image_increase_canvas_size
Last active Aug 29, 2015
Resize and increase the canvas size of an image to 225x100 using imagemagick
View resize_image_increase_canvas_size
# I want to resize an image from 600x128 to 225x100 while keeping its aspect ratio.
# Resizing the width to 225 while keeping the aspect ratio makes one dimension (height)
# smaller (225x48) than what I want to obtain (225x100).
# The workaround is to resize first,
# then increase the canvas of the other dimension (height)
# to obtain the desired size (225x100) then center the image in the canvas.
#~~~~~~~~~~~~~~~~~~~~~
@ebouchut
ebouchut / guard
Created Nov 24, 2014
Guard workaround to symlinks pointing to parent directories (another option is https://github.com/guard/listen/releases/tag/v2.8.1)
View guard
############
## Problem
############
bundle exec guard
...
(This may be due to symlinks pointing to parent directories).
Duplicate: /some/where/ebouchut/www/netadge/bo/rubymine/trunk/doc/simplecov
@ebouchut
ebouchut / activemodel_activerecord_generate_error_message
Created Nov 21, 2014
ActiveModel ActiveRecord generate error message
View activemodel_activerecord_generate_error_message
class User # class User < ActiveRecord::Base
include ActiveModel::Model #
attr_accessor :name, :age
validates :name, presence: true
validates :age, presence: true,
numericality: { only_integer: true, greater_than: 0 }
end
@ebouchut
ebouchut / find_xargs_file_with_name_containing_space
Created Nov 21, 2014
Remove files whose name contain a space using find and xargs
View find_xargs_file_with_name_containing_space
# I use find -print0 and xargs -0 when the filenames contain characters used as delimitors,
# like space in this case
#
find '/tmp/temp results' -name '*.tmp' -print0 | xargs -0 -n 1 -J % rm '%'
You can’t perform that action at this time.