Skip to content

Instantly share code, notes, and snippets.

@syohex
syohex / u-nya.el
Created April 18, 2012 14:58
Emacs u-nya-mode
(defgroup u-nya nil
"Showing u-nya on mode-line."
:prefix "u-nya-"
:group 'frames)
(defface u-nya:face
nil
"Face for modeline"
:group 'u-nya)
@syohex
syohex / how_to_build_gcc4.7.txt
Created May 26, 2012 13:38
how to build GCC 4.7 on i386 Ubuntu 10.04
Platform i386 Ubuntu 10.04
[GMP 5.0.5]
% CPPFLAGS=-fexceptions ../configure \
--prefix=/home/syohei/local --enable-cxx
% make
% make check
% make install
[MPFR 3.1.0]
@syohex
syohex / freebsd_zaw_cdr.diff
Created June 13, 2012 04:05
Use zaw-cdr in FreeBSD
--- orig_cdr.zsh 2012-06-13 13:02:54.283074133 +0900
+++ cdr.zsh 2012-06-13 13:03:06.091074311 +0900
@@ -14,7 +14,8 @@
}
function zaw-src-cdr-cd () {
- BUFFER="cd $1"
+ VAR=`echo -n $1 | awk '{ print \$2 }'`
+ BUFFER="cd $VAR"
zle accept-line
@syohex
syohex / gitdir.zsh
Created June 24, 2012 14:39
zaw plugin for moving directory in git repository
#
# zaw-src-gitdir
#
# zaw source for git command
#
function zaw-src-gitdir () {
_dir=$(git rev-parse --show-cdup 2>/dev/null)
if [ $? -eq 0 ]
then
@syohex
syohex / merge.pl
Created June 28, 2012 08:00
merge sort in perl
#!perl
use strict;
use warnings;
sub merge_sort {
my $target_array_ref = shift;
my $len = scalar @{$target_array_ref};
if ($len <= 1) {
return $target_array_ref;
@syohex
syohex / mergesort.rb
Created June 29, 2012 08:52
merge sort in ruby
#!/usr/bin/env ruby
# -*- coding:utf-8 -*-
def merge_sort(a)
if a.length <= 1
a
else
(b, c) = split(a)
merge( merge_sort(b), merge_sort(c))
end
@syohex
syohex / rss_parse.pl
Created June 29, 2012 14:58
リハビリ用
#!perl
use strict;
use warnings;
use Furl;
use XML::RSS::LibXML;
use Encode;
my $rss_url = shift or die "Usage: $0 rss_url";
my $ua = Furl->new();
@syohex
syohex / neon_test.c
Created June 30, 2012 13:10
sample code of generation ARM NEON instruction
/*
arm-linux-gnueabi-gcc-4.6 -O2 -march=armv7-a -mtune=cortex-a9 -ftree-vectorize -mhard-float -mfloat-abi=softfp -mfpu=neon -ffast-math -mvectorize-with-neon-quad -S neon_test.c
*/
void NeonTest(short int * __restrict a, short int * __restrict b, short int * __restrict z)
{
int i;
for (i = 0; i < 200; i++) {
z[i] = a[i] * b[i];
}
}
@syohex
syohex / kill-then-dired.el
Created June 30, 2012 14:24
kill current buffer then dired current directory
(defun kill-buffer-and-dired ()
(interactive)
(let (dir (file-name-directory (buffer-file-name (current-buffer))))
(kill-buffer (current-buffer))
(dired dir)))
(global-set-key (kbd "C-x C-k") 'kill-buffer-and-dired)
all' :: (a -> Bool) -> [a] -> Bool
all' _ [] = True
all' f (x:xs) = if f x then all' f xs else False
any' :: (a -> Bool) -> [a] -> Bool
any' _ [] = False
any' f (x:xs) = if f x then True else any' f xs
takeWhile' :: (a -> Bool) -> [a] -> [a]
takeWhile' _ [] = []