Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Yanick Champoux yanick

🏠
Working from home
View GitHub Profile
View ansiplay
#!/usr/bin/env fish
# always wanted Ansible to be --check by default.
# Well, through the magic of arg munging, it can be!
# add `--check --diff` to all commands, unless it ends
# with GO
# E.g.,
# ansiplay playbooks/foo.yml # --check and --diff added
# ansiplay playbooks/foo.yml GO # GO removed and playbook ran fo' realz
@yanick
yanick / cdr
Created May 28, 2020 17:31
cd to the repo root
View cdr
# Defined in /home/yanick/.config/fish/functions/cdr.fish @ line 1
function cdr --description 'cd to the repo root'
set -l repo_dir ( perl -MPath::Tiny \
-E'$x = path(".")->absolute; while(1){ exit say $x if $x->child(".git")->is_dir; exit if $x eq "/"; $x = $x->parent }' )
if [ $repo_dir != "" ]
cd $repo_dir
else
echo "not in a git repo"
@yanick
yanick / n
Created May 28, 2020 15:07
decides to run npm or yarn or pnpmdepending of the current project
View n
#!/usr/bin/env fish
set manager npm
if test -f pnpm-lock.yaml
set manager pnpm
else if test -f yarn.lock
set manager yarn
end
View git-cm
#!/usr/bin/env perl
use 5.30.0;
use List::MoreUtils qw/ first_index /;
my $index = first_index { $_ eq '--' } @ARGV;
$index = 0 if $index== -1;
View gist:35a6a2b5e1c818bba6a86bc3cfb05fc8
use App::Dothe::DSL;
use Path::Tiny::Glob pathglob => { all => 1 };
task feeds => (
deps => [qw/ entries summary /],
generates => [ map { './static/feed.'.$_ } qw/ atom json rss /],
sources => './static/entries.json',
cmds => './scripts/gen_feed.js'
);
@yanick
yanick / test_mw.ts
Created March 29, 2019 19:43
Less boilerplate to test Redux middleware (in Jest)
View test_mw.ts
type MWFixtures = Partial<{
dispatch: Function;
getState: Function;
next: Function;
action: object;
}>;
function mw_fixtures(fixtures: MWFixtures) {
return fp.defaults({
dispatch: jest.fn(),
View genesis_public_key
0483c791e5461a4d897984590d33ff52e1d6d2f5c8b9e02bd4a092dc07dc0ad42aacb8c314b08c637bf9ac24a492f4137c80e5c1bc3a031fb7dc9d8090c07a6884
@yanick
yanick / gist:a7db7c1906c820443c18bed331c0e0b0
Created March 9, 2017 18:08
synopsis of toronto's talk
View gist:a7db7c1906c820443c18bed331c0e0b0
# To JavaScript and Back: Transfixing Tales of Transglotting Thefts (in Toronto)
Last year, Yanick took a deep dive into the JavaScript ecosystem and avidly drank
from the framework firehose. As part of the journey to understanding, he was
caught uttering "I wonder what that would look like in Perl..." a few times.
In this talk, we'll visit the result of this clash between learning and
hubris. We'll touch
[Redux](http://redux.js.org/)/[Pollux](https://metacpan.org/release/Pollux),
[MobX](https://mobx.js.org/)/[MoobX](https://metacpan.org/release/MoobX), and might even
@yanick
yanick / mcpan.pl
Last active October 21, 2016 20:25
quick metacpan cli interface
View mcpan.pl
#!/usr/bin/env perl
=usage
mcpan moosex
=cut
use 5.20.0;
@yanick
yanick / 0_reuse_code.js
Created January 21, 2016 19:14
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console