Skip to content

Instantly share code, notes, and snippets.

@youpy
youpy / gist:59d39a509e7b38f9841c
Last active August 29, 2015 14:03
show image on iTerm
def main
url = ARGV.shift
filename = '/tmp/image_on_iterm'
system('curl %s > %s 2>/dev/null' % [url, filename])
command =<<CMD % filename
osascript -e "
tell application \\"iTerm\\"
tell the first terminal
tell the last session
set background image path to \\"%s\\"
@youpy
youpy / file.rb
Created June 20, 2014 14:36
Android 作成 Gist
Add my Yo username by tapping here: http://justyo.co/YOUPY
(if you don't have Yo app get it here http://justyo.co)
package main
import (
"errors"
"fmt"
"math/rand"
"time"
)
func main() {
@youpy
youpy / no_sleep.rb
Last active August 29, 2015 13:56
Disable sleep (for OS X)
reuire 'mac-robot'
r = Mac::Robot.new
loop {
# 0xff is not listed in <HIToolbox/Events.h>, so it doesn't affect user's interaction
# http://forums.macrumors.com/showpost.php?p=8428116&postcount=2
r.key_press(0xff)
@youpy
youpy / gist:8800251
Created February 4, 2014 08:57
Sharing clipboard between Emacs and OS X without invoking a shell
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(defun copy-from-osx ()
(let ((buf (get-buffer-create "*pbpaste*")))
(with-current-buffer buf
(erase-buffer)
(call-process "pbpaste" nil "*pbpaste*")
@youpy
youpy / ej
Last active November 6, 2017 00:44
#!/bin/bash
# src: http://taka.no32.tk/diary/20050826.html
set -e
KEY=`echo $@ | nkf -w -w80 | sed 's/ /+/g'`
URI="https://eow.alc.co.jp/search?q=$KEY"
CONTENT=`curl -s -e='http://eow.alc.co.jp/' \
-A 'Mozilla/5.0' "$URI" | \
sed -ne '/<ul/,/<\/ul>/p' | grep -v '<li[^>]*><a ' | grep -v '"tango"' | w3m -dump -T 'text/html'`
@youpy
youpy / waa_timer.coffee
Last active December 30, 2015 06:09
A timer implementation using "onended" event dispatched to AudioBufferSourceNode and OscillatorNode
window.AudioContext = window.AudioContext||window.webkitAudioContext
class Timer
constructor: (@useOscillatorNode) ->
@url = 'http://dl.dropbox.com/u/334064/silence100ms.wav'
@cxt = new AudioContext
@gainNode = @cxt.createGain()
@gainNode.gain.value = 0.0
@gainNode.connect(@cxt.destination)
@oninit = () ->
@youpy
youpy / say.rb
Created October 18, 2013 10:00
eathquake.gem plugin to speech tweets
# -*- coding: utf-8 -*-
require 'shellwords'
require 'uri'
Earthquake.init do
output_filter do |item|
text = item["text"]
if text
@youpy
youpy / gls
Last active December 25, 2015 01:29
A shell script to show specific revision using percol
#!/bin/sh
# http://hail2u.net/blog/software/easy-to-read-git-log.html
git log --graph --pretty='format:%h%d %s %an, %ar' $1 \
| percol \
| sed 's/^[ \|\*]*//' \
| awk '{print $1}' \
| xargs git show
@youpy
youpy / fabric_passwd_on_parallel_task.py
Created October 1, 2013 02:59
fabric: password prompt on a parallel task
def password():
return getpass.getpass()
@parallel
def _foo():
sudo('foo')
@task
def foo():
"""execute foo"""