Skip to content

Instantly share code, notes, and snippets.

// create a toggler link...is there a better way?
var toggler = new Ext.BoxComponent({
autoEl: {
tag: 'a',
href: '#',
html: 'All'
},
listeners: {
'render': function(comp) {
var el = comp.getEl();
@slackorama
slackorama / js-beautify.el
Created November 23, 2010 19:51
beautify some js code in emacs
;;; js-beautify.el -- beautify some js code
(defgroup js-beautify nil
"Use jsbeautify to beautify some js"
:group 'editing)
(defcustom js-beautify-args "--jslint-happy --brace-style=end-expand --keep-array-indentation"
"Arguments to pass to jsbeautify script"
:type '(string)
:group 'js-beautify)
@slackorama
slackorama / git-bz
Created November 22, 2010 18:21
Git task to create an email for bugzilla actions (fixing a ticket or merging a ticket)
#!/usr/bin/env perl
# git-bz -- given a version and target, print out a merge
# email for sending to bz
use warnings;
use strict;
use Carp;
use Git;
;;;==========================================================================
;;; DATE MADNESS
;;;==========================================================================
;;; from ejacs...a whole other type of madness
(defun js-date-js-to-elisp (time)
"Turn a JavaScript ms TIME value into (high low . ignored)
`high' is the most signifcant 16 bits; `low' is the 16 lsb."
(let ((sec (/ time 1000.0)))
(list (truncate (/ sec 65536)) ; high 16 bits of sec
@slackorama
slackorama / perlweirdness
Created May 4, 2010 23:09
perl weirdness or is it me?
>>> perl -e 'warn ${"::x'\'')"}'
2034 2034 203 103 100 at -e line 1.
# Binary search solves the problem [of searching within a pre-sorted array] by
# keeping track of a range within the array in which T [i.e. the sought value]
# must be if it is anywhere in the array. Initially, the range is the entire
# array. The range is shrunk by comparing its middle element to T and
# discarding half the range. The process continues until T is discovered in the
# array, or until the range in which it must lie is known to be empty. In an
# N-element table, the search uses roughly log(2) N comparisons.
def bin_search(A, T):
"""
diff --git a/src/gl-compile-conf b/src/gl-compile-conf
index c9b953b..71ef61b 100755
--- a/src/gl-compile-conf
+++ b/src/gl-compile-conf
@@ -362,6 +362,12 @@ for my $fragment_file (glob("conf/fragments/*.conf"))
parse_conf_file($fragment_file, $fragment);
}
+# these 4 lines prevent a segfault on the Data::Dumper line
+for my $key ( keys %repos) {
@slackorama
slackorama / perl crap I deal with.pl
Created February 27, 2010 00:46
Seriously, WTF?
$self->assign(
'ext_list',
[ map {
my @l = split /,/;
my $count = 0;
my $r = [
$l[0],
{ map +( int( $count++ % 2 ) == 0 ? lc $_ : $_ ),
@l[ 1 .. $#l ]
}
@slackorama
slackorama / *scratch*
Created January 16, 2010 00:49
My .gitconfig aliases
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
lol = log --pretty=oneline --abbrev-commit --graph --decorate
unstage = reset HEAD
who = shortlog -s --
#!/bin/sh
# rtm - simply use twitter to send off a direct message to rtm to add a task
username=$1
shift
password=$2
shift
curl -s --basic --user "$username:$password" --data-ascii \