Skip to content

Instantly share code, notes, and snippets.

@oylenshpeegul
oylenshpeegul / diamond.go
Last active August 29, 2015 14:14
Emulate Perl's diamond operator in Go.
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
@oylenshpeegul
oylenshpeegul / refcounts.pl
Created June 3, 2015 01:56
Compare Devel::Refcount::refcount with Internals::SvREFCNT
#!/usr/bin/env perl
use v5.16;
use warnings;
use Devel::Refcount qw(refcount);
my $href = {};
say "BEGIN:" . refcount($href);
@oylenshpeegul
oylenshpeegul / gist:1445090
Created December 7, 2011 22:44
no trailing commas in json
$ perl -MJSON -E 'say encode_json [1, 2, 3,]'
[1,2,3]
$ python -c 'import json; print(json.dumps([1, 2, 3,]))'
[1, 2, 3]
$ ruby -r json -e 'puts [1, 2, 3,].to_json'
[1,2,3]
$ coffee -e 'console.log [1, 2, 3,]'
$ notes init
Initializing notes (/home/tim/.notes)...
Initialized empty Git repository in /home/tim/.notes/.git/
$ notes add Hello World
Waiting for Emacs...
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using
git remote add <name> <url>
@oylenshpeegul
oylenshpeegul / tunesio.pl
Created September 16, 2012 23:18
Perl script to download a playlist from tunes.io
#!/usr/bin/env perl
# Download all the files in a daily playlist from tunes.io
#
# https://gist.github.com/3734797
$ENV{MOJO_MAX_MESSAGE_SIZE} = 30_000_000;
use v5.16;
use warnings;
@oylenshpeegul
oylenshpeegul / jsonlint.py
Created March 17, 2013 21:29
Check a JSON file against a Schema.
#!/usr/bin/env python
import argparse
import json
import jsonschema
parser = argparse.ArgumentParser(
description='validate the json file against the json schema')
parser.add_argument(
'datafile', type=argparse.FileType('r'),
@oylenshpeegul
oylenshpeegul / call_perl.el
Last active August 14, 2016 02:49
Emacs - insert the date with Perl
;; Use some Perl to insert the date.
(defun myday ()
"print the date"
(interactive)
(call-process "perl" nil t nil "-e" "
# perl code here
my @Monat = qw(Januar Februar Maerz April Mai Juni Juli August
September Oktober November Dezember);
my @Tag = qw(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag
#!/usr/bin/env perl
use v5.28;
use warnings;
use experimental qw(signatures);
use Data::Printer;
use Encode qw(encode);
use Getopt::Long::Descriptive;
use Interpolation E => 'eval';
use Mojo::JSON qw(decode_json encode_json);
{"ANA":{"Adam Henrique":{"lastName":"Henrique","nationality":"CAN"},"Ben Hutton":{"lastName":"Hutton","nationality":"CAN"},"Cam Fowler":{"lastName":"Fowler","nationality":"USA"},"Carter Rowney":{"lastName":"Rowney","nationality":"CAN"},"Danton Heinen":{"lastName":"Heinen","nationality":"CAN"},"Derek Grant":{"lastName":"Grant","nationality":"CAN"},"Hampus Lindholm":{"lastName":"Lindholm","nationality":"SWE"},"Isac Lundestrom":{"lastName":"Lundestrom","nationality":"SWE"},"Jacob Larsson":{"lastName":"Larsson","nationality":"SWE"},"Jakob Silfverberg":{"lastName":"Silfverberg","nationality":"SWE"},"Jani Hakanpaa":{"lastName":"Hakanpaa","nationality":"FIN"},"John Gibson":{"lastName":"Gibson","nationality":"USA"},"Josh Mahura":{"lastName":"Mahura","nationality":"CAN"},"Josh Manson":{"lastName":"Manson","nationality":"CAN"},"Kevin Shattenkirk":{"lastName":"Shattenkirk","nationality":"USA"},"Max Comtois":{"lastName":"Comtois","nationality":"CAN"},"Max Jones":{"lastName":"Jones","nationality":"USA"},"Nicolas Deslaurie
@oylenshpeegul
oylenshpeegul / to_mp3.pl
Created June 10, 2021 22:57
Convert .opus and .m4a files to .mp3
#!/usr/bin/env perl
use v5.28;
use warnings;
use Path::Tiny;
use String::ShellQuote;
my $dir = path(shift // '..');
# Convert the .opus files by piping to opusdec first.