Skip to content

Instantly share code, notes, and snippets.

@syohex
syohex / filename.pl
Created April 2, 2014 09:54
Convert file descriptor to file name in Linux
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
my @fhs;
opendir my $dh, '/etc';
for my $entry (readdir $dh) {
@syohex
syohex / toggle-let.el
Created April 16, 2014 02:10
toggle between `let` and `let*`
(defun my/toggle-let ()
(interactive)
(save-excursion
(when (re-search-backward "(\\(let\\)\\(\\*\\)?" nil t)
(goto-char (match-end 1))
(if (and (match-string 2) (string= (match-string 2) "*"))
(delete-char 1)
(insert "*"))
(backward-up-list)
(indent-pp-sexp))))
@syohex
syohex / 0.05.log
Last active August 29, 2015 13:59
Amon2::Lite test with Data::Section::Simple@0.05 and Data::Section::Simple@0.06
% prove -bv t/300_setup/04_lite.t
t/300_setup/04_lite.t ..
# /tmp/eFPNmtcAka
[t::TestFlavor] Loading asset: jQuery
[t::TestFlavor] Loading asset: Bootstrap
[t::TestFlavor] Loading asset: ES5Shim
[t::TestFlavor] Loading asset: MicroTemplateJS
[t::TestFlavor] Loading asset: StrftimeJS
[t::TestFlavor] Loading asset: SprintfJS
[t::TestFlavor] Loading asset: MicroLocationJS
@syohex
syohex / ac-config.el
Created April 22, 2014 03:06
minimum configuration for auto-complete gtags source
;; set `load-path' auto-complete and its dependencies
(require 'auto-complete-config)
(ac-config-default)
(global-auto-complete-mode t)
@syohex
syohex / xslate-add-array-builtins.patch
Last active August 29, 2015 14:00
Patch for adding `first` and `last` method to builtin Array functions
diff --git a/lib/Text/Xslate/Manual/Builtin.pod b/lib/Text/Xslate/Manual/Builtin.pod
index 842c330..bdc51d3 100644
--- a/lib/Text/Xslate/Manual/Builtin.pod
+++ b/lib/Text/Xslate/Manual/Builtin.pod
@@ -35,6 +35,14 @@ The namespace of ARRAY references is C<array>.
Returns true;
+=head3 C<$a.first()>
+
@syohex
syohex / cleanup-cdr.pl
Created April 25, 2014 02:32
remove dead directories from cdr list
#!/usr/bin/env perl
use strict;
use warnings;
use File::Spec;
my $file = File::Spec->catfile($ENV{HOME}, ".chpwd-recent-dirs");
open my $fh, '<', $file or die "Can't open file $!";
my @lives;
@syohex
syohex / simple-download.py
Created April 29, 2014 00:52
simple image downloader
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import re
import requests
from bs4 import BeautifulSoup
if len(sys.argv) < 2:
(custom-set-variables
'(coffee-tab-width 2))
(eval-after-load "coffee-mode"
'(progn
(define-key coffee-mode-map (kbd "C-m") 'newline)))
@syohex
syohex / emamux-yank-tmux-buffer.patch
Created May 13, 2014 09:13
Implement yank tmux buffer
diff --git a/emamux.el b/emamux.el
index 6428e26..706d5e8 100644
--- a/emamux.el
+++ b/emamux.el
@@ -149,6 +149,17 @@
(push (match-string-no-properties 1) sessions))
sessions)))
+(defun emamux:get-buffers ()
+ (with-temp-buffer
@syohex
syohex / update_css_dictionary.rb
Created May 19, 2014 09:06
Script for updating auto-complete CSS dictionary
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'set'
old_url = 'https://raw.githubusercontent.com/auto-complete/auto-complete/master/dict/css-mode'
old_properties = SortedSet.new
open(old_url).read.each_line do |line|