Skip to content

Instantly share code, notes, and snippets.

@Dubhead
Dubhead / sape.vim
Created June 5, 2012 05:58
a Vim script to insert spaces around punctuations and equals automatically
"""" Spaces Around Punctuations and Equals """"
let s:sape_no_space_before_equal = split('-!~=+*/&|<>%', '\zs')
let s:sape_followed_by_space = split(',;=', '\zs')
function s:sape(c)
if a:c == ' ' || a:c == '\t' || col(".") == 1
return a:c
endif
let prevchar = getline(".")[col(".") - 2]
#!/bin/zsh -x
# ファイルに変更があったらブラウザを自動リロードする。
# ブラウザ側に拡張などを入れる必要なし。
# 要: inotifywait, xdotool
# 参考: http://stackoverflow.com/questions/4680109/how-to-reload-refresh-a-web-page-without-leaving-my-web-development-ide/10739606#10739606
# 参考: http://unix.stackexchange.com/questions/37258/refresh-reload-active-browser-tab-from-command-line/42933#42933
RELOAD_KEYS="CTRL+R"
# RELOAD_KEYS="SHIFT+CTRL+R"
@Dubhead
Dubhead / gist:5574285
Created May 14, 2013 07:30
Falcon new_engine doesn't start with 2013-05-13 18:17:00 (GMT) commit, the latest as of this writing. Fedora 18, x86_64.
% gdb ./falcon
GNU gdb (GDB) Fedora (7.5.1-38.fc18)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
@Dubhead
Dubhead / gc.dart
Created May 23, 2013 07:08
calculating GC content in Dart
#!/usr/local/dart/dart-sdk/bin/dart
// gc.dart
// cf. http://saml.rilspace.org/moar-languagez-gc-content-in-python-d-fpc-c-and-c
import 'dart:io';
import 'dart:async';
main()
{
@Dubhead
Dubhead / gc.py
Created May 23, 2013 07:19
A Python version gets a lot slower when str.count(I) is inhibited.
#!/usr/bin/python
def main():
gcCount = 0
atCount = 0
with open("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa", "r") as f:
for line in f:
if not line.startswith('>'):
# gcCount += line.count('G') + line.count('C')
# atCount += line.count('A') + line.count('T')
// simple HTTP client, based on
// https://mail.mozilla.org/pipermail/rust-dev/2013-August/005117.html
//
// Note: Envvar RUST_NEWRT=1 is required to compile and run this.
use std::rt::io::net::ip::{Ipv4Addr, SocketAddr};
use std::rt::io::net::tcp::TcpStream;
use std::rt::io::{Reader, Writer};
use std::str;
@Dubhead
Dubhead / gist:d8cfa77cad28394d318c
Created December 3, 2014 08:50
cannot build Falcon new_engine
on Fedora 20 x86_64, after setting all FALCON_BUILD_* to OFF in ccmake
% git log -1 HEAD | cat
commit 5c5ca3d39db30c22a4218bea40a45d2f94465f2d
Author: Giancarlo Niccolai <[email protected]>
Date: Wed Dec 3 00:05:30 2014 +0100
Fixed compilation on FreeBSD 10.1 64Bit - Clang
%
% ninja-build -k 1000
@Dubhead
Dubhead / gist:a51904c9e55908c747d0
Last active August 29, 2015 14:21
「ソフトウェアエンジニアならば1時間以内に解けなければいけない5つの問題」の5問目を Pure で解いてみた
数式の文字列を eval できる言語ならどれでも大差なく解けそうなもの。
というわけで Pure (http://purelang.bitbucket.org/) で解いてみた。
#!/usr/bin/pure
using system; // for 'puts'
add100 acc 9
= puts acc if eval acc == 100;
= _ otherwise;
#!/bin/sh
#!/bin/zsh -x
# flac_renamer.sh - Renames FLAC files by tracknumbers.
#
# usage:
# $ ./flac_renamer.sh *.flac
# : e.g. MyArtist-MyTitle.flac is renamed to 01.flac
FLAC_FILES="$@"
@Dubhead
Dubhead / gist:84a1d9a6fcef57d8448265f8f90880b9
Created October 24, 2018 18:14
term-rewriting rule in Kit
% cat src/test.kit
rules AddOne {
(ADD_ONE(${x: Int})) => x + 1;
}
using rules AddOne;
function main() {
var foo = ADD_ONE(42_i);
}
%