This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'appscript' | |
require 'titleize' | |
def set_tags_from_filename(track) | |
f=track.location.get.path.split('/')[-1] | |
m=f.match(/(\d\d) (.+?) - (.+?)\.mp3/); | |
track.track_number.set m[1] | |
track.artist.set m[2].titleize | |
track.name.set m[3].titleize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just before switching jobs: | |
// Add one of these. | |
// Preferably into the same commit where you do a large merge. | |
// | |
// This started as a tweet with a joke of "C++ pro-tip: #define private public", | |
// and then it quickly escalated into more and more evil suggestions. | |
// I've tried to capture interesting suggestions here. | |
// | |
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_, | |
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Class | |
def method_to_instance(*names) | |
names.each{|name| | |
meth = method(name) | |
self.send(:define_method, name, meth.to_proc) | |
} | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://timelessrepo.com/chained-comparisons | |
[:<, :>, :<=, :>=].each do |operator| | |
[Float, Fixnum, Comparable].each do |klass| | |
klass.class_eval { | |
alias_method("__#{operator}__", operator) | |
define_method(operator) do |operand| | |
send("__#{operator}__", operand) and operand | |
end | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from http://maettig.com/code/css/text-shadow.html | |
var handle = false; | |
var textBrightness = 50; | |
var fireCount = 6; | |
var fireDelta = new Array(); | |
var step = 0; | |
var angle = 0; | |
var radius = 6; | |
function animate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun exec-path-search (regexp) | |
(flatten (remove-if-not 'identity | |
(mapcar (lambda (dir) (directory-files dir t regexp)) | |
exec-path)))) | |
(defun load-path-search (&optional regexp full-path) | |
(unless regexp (set 'regexp "elc?$")) | |
(uniq (sort (flatten | |
(remove-if-not 'identity | |
(mapcar (lambda (dir) (directory-files dir full-path regexp)) load-path))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new folder on desktop, named: | |
GodMode.{ED7BA470-8E54-465E-825C-99712043E01C} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static public class A_Z_cycle | |
{ | |
static public Func<char> Next = () => { | |
const char a='A', b='Z', c=(char)(b-a+1); | |
int n=-1; | |
return (Next=(()=>(char)(a + (n=(n+1)%c))))(); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static public class FunFactory | |
{ | |
static public Func<TResult> Make<TResult>(TResult a, Func<TResult, TResult> step) | |
{ | |
TResult next=a; | |
return ()=>{ TResult cur=next; next=step(cur); return cur; }; | |
} | |
static public Func<TResult> Cycle<TResult>(IEnumerable<TResult> values) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Date | |
# prev_week and next_week, add/remove 7 days * optarg | |
['prev_','next_'].each{|n|define_method(n+'week'){|w=1|send n+'day',7*w}} | |
# other is Date to compare to | |
# wants tells what to include in timediff. default is years,months,weeks,days | |
# by default returns <timediff> from <earlier> to <later> | |
# if abs=true returns <self> is <timediff> later|earlier than <other> | |
def diff_str other, want="ymwd",abs=false | |
return "Both dates are #{self}" if self==other |
OlderNewer