Skip to content

Instantly share code, notes, and snippets.

Comments? sacha@sachachua.com

  • Emacs learning curve?

Meta information

Assumptions

  • Mix of Emacs geeks skewed towards people who’ve been using this for a while (after all, takes a certain commitment to come all the way to an Emacs conference!)

Outcomes

(require 's)
(defun rlb3/toggle-file ()
(interactive)
(let* ((full-path (buffer-file-name))
(path (rlb3/remove-ulc full-path))
(file-type (rlb3/determine-file-type path)))
(if (eq file-type 'test)
(rlb3/jump-to-related-test path)
(rlb3/jump-to-related-module path))))
(eval-when-compile (require 'cl))
(require 'json)
(require 'url)
(require 'url-http)
(defgroup cpanel nil
"cPanel customization group"
:group 'cpanel
:prefix "cpanel-")
(require 'multiple-cursors)
(global-set-key (kbd "C-c C-e") 'mc/edit-lines)
(global-set-key (kbd "C-c C-f") 'mc/mark-next-like-this)
(global-set-key (kbd "C-c C-b") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-x f") 'mc/mark-all-like-this)
(require 's)
(defun rlb3/toggle-related-file ()
(interactive)
(let* ((full-path (buffer-file-name))
(path (rlb3/remove-ulc full-path))
(file-type (rlb3/determine-file-type path)))
(if (eq file-type 'test)
(rlb3/jump-to-related-module path)
(rlb3/jump-to-related-test path))))
(defun show-frame (&optional frame)
(raise-frame)
(select-frame-set-input-focus (selected-frame))
(select-frame-set-input-focus (selected-frame)))
@rlb3
rlb3 / reader.pl
Created June 6, 2013 15:39
tail-like
#!/usr/bin/env perl
use strict;
use warnings;
my $pid = $ARGV[0];
my $file = '/tmp/logfile.log';
open my $fh, '<', $file;
while (pid_exists()){
(require 's)
(defun rlb3/toggle-file ()
(interactive)
(let* ((full-path (buffer-file-name))
(path (rlb3/remove-ulc full-path))
(file-type (rlb3/determine-file-type path)))
(if (eq file-type 'test)
(rlb3/jump-to-related-test path)
(rlb3/jump-to-related-module path))))
@rlb3
rlb3 / destructor.rb
Created July 2, 2013 14:45
Destructor in ruby?
#!/usr/bin/env ruby
class MyObject
def initialize
ObjectSpace.define_finalizer(self, proc { destroy })
end
def start
puts 'start'
end

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.