Skip to content

Instantly share code, notes, and snippets.

@jplindstrom
jplindstrom / .ackrc
Created November 7, 2017 18:07
.ackrc Perl config
--ignore-directory=is:local/lib
--ignore-directory=is:local/man
--ignore-directory=is:local/bin
--type-add=perl:is:cpanfile
@jplindstrom
jplindstrom / ascii-art-cube.txt
Created April 12, 2017 10:22
ASCII art cube
_.-._
_,-' `-._
(_ '_)
(_`-._ _,-'_)
(_`-._`-'_,-'_)
(_`-._`-'_,-'_)
`-._`-'_.-'
`-'
@jplindstrom
jplindstrom / gist:868e4e2b0bed933d960070c1cee49f65
Created October 11, 2016 10:00
App::Benchmark::Accessors output with Moo
# Benchmark: timing 1000000 iterations of class_accessor, class_accessor_classy, class_accessor_complex, class_accessor_constructor, class_accessor_fast, class_accessor_fast_xs, class_accessor_lite, class_methodmaker, class_spiffy, class_xsaccessor, class_xsaccessor_array, mojo, moo, moose, moose_immutable, mouse, mouse_immutable, object_tiny, object_tiny_xs, rose, spiffy...
# class_accessor: 0.761038 wallclock secs ( 0.76 usr + 0.00 sys = 0.76 CPU) @ 1315789.47/s (n=1000000)
# class_accessor_classy: 0.459568 wallclock secs ( 0.45 usr + 0.01 sys = 0.46 CPU) @ 2173913.04/s (n=1000000)
# class_accessor_complex: 0.96933 wallclock secs ( 0.97 usr + 0.00 sys = 0.97 CPU) @ 1030927.84/s (n=1000000)
# class_accessor_constructor: 2.08857 wallclock secs ( 2.09 usr + 0.00 sys = 2.09 CPU) @ 478468.90/s (n=1000000)
# class_accessor_fast: 0.663317 wallclock secs ( 0.66 usr + 0.00 sys = 0.66 CPU) @ 1515151.52/s (n=1000000)
# class_accessor_fast_xs: 0.320578 wallclock secs ( 0.32 usr + 0.00 sys = 0.32 CPU) @ 3125
@jplindstrom
jplindstrom / visualise_length.pl
Created September 27, 2016 09:51
Display the length of time between log lines.
# Assumes the first digit is a timestamp, and that all of them have the same width. Most useful with ms precision.
# tail -f logfile | THIS_FILTER
perl -MList::Util=min -nE 'state $last= 0; /"([\dT:,-]+)"/ and do { my $c = ($1 =~ s/\D//gr); my $d = $c - $last; my $w = min(200, $d / 5); say $d . ": " . ("x" x $w); $last = $c }; print $_'
@jplindstrom
jplindstrom / org-simple-slides.el
Last active September 6, 2016 16:03
Super simple org-mode slides
;;
;; Super simple org-mode slides
;;
;; Narrow the display to a subtree and navigate between them. Super
;; simple stuff.
;;
;;
;;; Usage:
;;
@jplindstrom
jplindstrom / project.clj
Created June 15, 2015 12:02
Reminder: clojure project.clj when cider complains about bad versions
(defproject scaper "0.1.0-SNAPSHOT"
:description "FIXME: name"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]]
:main ^:skip-aot scaper.core
:target-path "target/%s"
@jplindstrom
jplindstrom / gist:e1d18058047c3a309f95
Last active August 29, 2015 14:16
R script graph

Install r and eog

sudo aptitude install r-base sudo aptitude install eog

Usage

Read from stdin and send graph output to r.png, eval $1 and display r.png

@jplindstrom
jplindstrom / gist:59f5e9450ad449633918
Last active August 29, 2015 14:16
PS copy package name from file name
(defun ps/project-buffer-file-name ()
"Return the current buffer file name, relative to the project
root dir."
(let* ((full-file-name (buffer-file-name))
(project-dir (or (ps/project-dir) (error "Not in a PerlySense project.")))
(project-file-name
(replace-regexp-in-string (regexp-quote (format "%s/" project-dir)) "" full-file-name))
)
project-file-name
@jplindstrom
jplindstrom / gist:cf4c82bd4f92de6d39f6
Created February 18, 2015 23:58
Emacs, Perl add deref
(defun ps/edit-deref-type (sigil)
"Enclose the text from point and backwards to the preceeding $
in SIGIL{TEXT}."
(let ((end (point)))
(when (search-backward "$" nil t)
(insert sigil)
(insert "{")
(goto-char (+ 2 end))
(insert "}")
)
@jplindstrom
jplindstrom / gist:ad7936feb3bf3123f49a
Created January 15, 2015 09:25
Start multiple processes in the background and kill them all with C-c
#!/bin/bash
source ~/.bashrc
nvm use
perl -Mlocal::lib=local bin/app.pl worker &
perl -Mlocal::lib=local local/bin/morbo bin/app.pl --listen=http://*:9000 &
ember serve --proxy=http://127.0.0.1:9000 &
trap "kill -TERM -$$" SIGINT