Skip to content

Instantly share code, notes, and snippets.

View cosmo0920's full-sized avatar
🏠
Working from home

Hiroshi Hatake cosmo0920

🏠
Working from home
View GitHub Profile
@cosmo0920
cosmo0920 / vecpush.rs
Created January 25, 2012 13:01
Rustのpush_vectorを書いてみる
use std;
fn vec_push(&v: [int], elt: int){
v += [elt];
}
fn main() {
let v: [int] = [];
let vec_size: uint = 0u;
vec_push(v,5);
@cosmo0920
cosmo0920 / svn_config.patch
Created February 9, 2012 15:48
mikutterのリビジョンを取ってくる部分が動いてない…?
--- /media/Data/mikutter/core/config.rb.orig 2012-02-10 00:56:37.435758528 +0900
+++ /media/Data/mikutter/core/config.rb 2012-02-10 00:56:04.940757018 +0900
@@ -42,7 +42,7 @@
REVISION = 658
# このソフトのバージョン。
- VERSION = [0,1,0, ((/Last Changed Rev\s*:\s*(\d+)/.match(`sh -c 'LANG=C svn info ../'`)[1] || REVISION).to_i rescue REVISION)]
+ VERSION = [0,1,0, ((/Last Changed Rev\s*:\s*(\d+)/.match(`sh -c 'LC_ALL=C svn info ../'`)[1] || REVISION).to_i rescue REVISION)]
end
@cosmo0920
cosmo0920 / mikutter_socketserv.rb
Created March 16, 2012 22:07
mikutterでSocket通信を使う
# -*- coding: utf-8 -*-
require 'socket'
Plugin.create :socket_tweet do
#複数回ツイートを送信するために複数ソケット通信対応サーバーとする
@thread = SerialThreadGroup.new
@thread.new{
server = TCPServer.open(3900)
loop {
begin
client = server.accept
@cosmo0920
cosmo0920 / tcp_miku_client.cpp
Created March 17, 2012 14:41
C++でもみっくみく!!
#include <iostream>
#include <boost/asio.hpp>
int main(int argc, char** argv)
{
using namespace boost::asio;
using ip::tcp;
std::string buf;
try
{
@cosmo0920
cosmo0920 / TestSocClient.hs
Created March 17, 2012 17:23
Haskellでもみっくみく!
import Network
import System.IO
import System.Exit
import Control.Exception
import Prelude hiding (catch)
sendMessage :: String -> IO ()
sendMessage msg = withSocketsDo $ do
hSetBuffering stdout NoBuffering
h <- connectTo "127.0.0.1" (PortNumber 3939)
@cosmo0920
cosmo0920 / TextRegexURL.hs
Created March 18, 2012 15:54
URLが含まれてるかRegexしましょう
import Text.Regex.Posix
main = do name <- getLine
print (checkURL name)
-- URLの正規表現を定める
urlRegex :: [Char]
urlRegex = ".*(https?|ftp)(://[-_.!~*\'()a-zA-Z0-9;/?:@&=+$,%#]+).*$"
-- t.coのURL長
tcoLength :: Int
@cosmo0920
cosmo0920 / TextRegex.hs
Created March 18, 2012 17:42
モナドが絡んで訳のわからないことに…
import Text.Regex.Posix
main = do name <- getLine
print (checkURL name)
print (countURLLength name)
print (twitLength name)
checkLengthAndTwit name
-- URLの正規表現を定める
urlRegex :: [Char]
@cosmo0920
cosmo0920 / exec_bash.rb
Created March 20, 2012 21:41
Rubyからbash実行?
#bashシェルを埋め込んでみた。
#必要なヘッダーが有る時はなにもしないよ
fixshContent=
"#!/usr/bin/env bash\n
cd arch/x86/include/asm/\n
if [ -f unistd_32.h ] ; then
echo 'no need fix.'
else
ln -s ../generated/asm/unistd*.h .\n
fi"
@cosmo0920
cosmo0920 / growlnotify_alert.sh
Created March 22, 2012 01:23
Growlでもalert生活!
alias alert='growlnotify -t "$([ $? = 0 ] && echo terminal || echo error)" -m "$(history|tail -n1|sed -e '\''s/^..[0-9]*//;s/[;&|]\s*alert$//'\'')"'
@cosmo0920
cosmo0920 / make.conf
Created April 30, 2012 20:00
Gentoo Prefix Ubuntuのmake.conf
USE="unicode nls X gtk berkdb cups apng python ghcbootstrap ghcquickbuild x264 faac thread threads mp3 alsa"
LANGS=ja
LINGUAS=ja
CFLAGS="-O2 -pipe -march=native"
CXXFLAGS="${CFLAGS}"
RUBY_TARGETS=ruby19
ACCEPT_LICENSE="@GPL-COMPATIBLE @OSI-APPROVED @EULA atheros-hal BitstreamVera"
source /home/cosmo/gentoo/var/lib/layman/make.conf
PORTDIR_OVERLAY="/home/cosmo/portage-overlay ${PORTDIR_OVERLAY}"
CHOST=i686-pc-linux-gnu