This file contains hidden or 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
#!/bin/zsh | |
git push $@ | |
if [ $? = 0 ]; then | |
growlnotify Succeed -a GitX -m 'successfully pushed' | |
else | |
growlnotify Fail -a CyberDuck -m 'git push failed' | |
fi |
This file contains hidden or 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 copy-current-file-name () | |
(interactive) | |
(let ((name (buffer-file-name))) | |
(shell-command (format "echo %s | pbcopy" name)) | |
(message (format "copied: %s" name)))) |
This file contains hidden or 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
;; open the current (file's) directory in Terminal.app | |
(defun mac-open-terminal () | |
(interactive) | |
(let ((dir "")) | |
(cond | |
((and (local-variable-p 'dired-directory) dired-directory) | |
(setq dir dired-directory)) | |
((stringp (buffer-file-name)) | |
(setq dir (file-name-directory (buffer-file-name)))) | |
) |
This file contains hidden or 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
$ history -n 1 | awk {'print $1'} | sort | uniq -c | sort -k1 -rn | head | |
1275 sudo | |
910 ls | |
908 git | |
835 rm | |
808 gg | |
773 gc | |
727 cp | |
678 less | |
615 make |
This file contains hidden or 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
;; for Mac | |
;; return to terminal after edit files via emacsclient | |
(defadvice server-edit (after server-edit-and-return) | |
(do-applescript | |
(format " | |
tell app \"Terminal\" | |
activate | |
end tell"))) | |
(ad-activate-regexp "server-edit-and-return") |
This file contains hidden or 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Coro; | |
use Coro::Semaphore; | |
sub p { warn shift; } | |
my $sem = new Coro::Semaphore 1; # 0: locked, 1: unlocked (default) | |
p sprintf 'semaphores: %d', $sem->count; |
This file contains hidden or 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
package debug; | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
BEGIN { | |
*CORE::GLOBAL::warn = sub { | |
my ($package, $file, $line) = caller; | |
ref $_[0] ? CORE::warn(Data::Dumper::Dumper(@_), sprintf(" at %s line %d\n", $file, $line)): CORE::warn @_, sprintf(" at %s line %d\n", $file, $line); | |
};} |
This file contains hidden or 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Linux::Pid qw/getpid getppid/; | |
my $pid = fork; | |
if( $pid ){ | |
warn "Parent: " . getpid(); | |
warn "Parent's parent: " . getppid(); | |
exit; |
This file contains hidden or 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
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
long long int fib(int n) | |
{ | |
double sqrt5 = sqrt(5); | |
return (1.0 / sqrt5) * (pow((1.0+sqrt5) / 2, n) - pow((1.0-sqrt5) / 2, n)); | |
} |
This file contains hidden or 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
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
// calculate fib(n+2)-1 | |
int fib_total(long long int val1, long long int val2, long long int n) { | |
if (n < 1) return val2 - 1; | |
return fib_total(val2, val1+val2, n-1); |