Skip to content

Instantly share code, notes, and snippets.

View thash's full-sized avatar
🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️

Takuya Hashimoto thash

🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️
View GitHub Profile
@thash
thash / gist:808854
Created February 3, 2011 01:09
testpub.rb
#!/usr/bin/ruby
puts "hoge"
@thash
thash / get_extension.sh
Created February 3, 2011 11:55
sed regexp to separate filename by dot
#!/bin/sh
echo "file.txt" | sed -e 's/\(.\+\)\(\..\+\)/\1\2/g'
#!/bin/sh
ls -lh */* | grep vmdk | awk '{print $5}' | sed -e 's/\(.\+\)G/\1/' | awk '{s += $1; print s}'
#!/usr/bin/ruby
print 'Input> '
val = gets.chomp
@thash
thash / cmd.txt
Created April 12, 2011 22:15
log
% sudo port selfupdate && sudo port install opencv
---> Configuring ffmpeg
Error: Target org.macports.configure returned: configure failure: shell command failed (see log for details)
Log for ffmpeg is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_multimedia_ffmpeg/main.log
Error: Unable to upgrade port: 1
Error: Unable to execute port: upgrade ffmpeg failed
To report a bug, see <http://guide.macports.org/#project.tickets>
@thash
thash / mvim
Created May 8, 2011 09:58
mvim (MacVim.app included)
#!/bin/sh
#
# This shell script passes all its arguments to the binary inside the
# MacVim.app application bundle. If you make links to this script as view,
# gvim, etc., then it will peek at the name used to call it and set options
# appropriately.
#
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007).
@thash
thash / sketch.js
Created May 17, 2011 15:58
plain mouse events
var down = false;
canvas.addEventListener('mousedown', function (e) {
down = true;
ctx.beginPath();
ctx.moveTo(e.clientX, e.clientY);
}, false);
window.addEventListener('mousemove', function (e) {
if (!down) return;
console.log(e.clientX, e.clientY);
ctx.lineTo(e.clientX, e.clientY);
@thash
thash / app.js
Created May 17, 2011 16:01
app.js
var socket = new io.Socket();
socket.connect();
socket.on('connect', function(data) {
console.log("connect session: " + socket.transport.sessionid);
});
var down = false;
canvas.addEventListener('mousedown', function (e) {
down = true;
ctx.beginPath();
ctx.moveTo(e.clientX, e.clientY);
socket.send({
act: "down",
x: e.clientX,
y: e.clientY,
color: ctx.strokeStyle
io = require('socket.io');
var socket = io.listen(app);
socket.on('connection', function(client) {
client.on('message', function(data) {
client.broadcast(data);
});
});