Skip to content

Instantly share code, notes, and snippets.

@kurosuke
kurosuke / gist:2633082
Created May 8, 2012 06:43
excel workbooks combine with PHPExcel
<?php
//
// 複数のExcel Workbooks を 1つに結合
// combine excel Workbooks
// (merge excel Worksheets to one Workbooks)
//
// 結合元のexcelファイル名列
$org_books = array('sample1.xls', 'sample2.xls', 'sample3.xls');
@kurosuke
kurosuke / gist:2633152
Created May 8, 2012 06:54
effect round and shadow to image with ImageMagick command
#!/bin/sh
for i in `/bin/ls *.jpg`
do
FILE=$i
GEOM=`identify $FILE | awk '{print $3}'`
WIDTH=`echo $GEOM| awk -Fx '{print $1}'`
HEIGHT=`echo $GEOM| awk -Fx '{print $2}'`
C_WIDTH=`expr $WIDTH + 5`
@kurosuke
kurosuke / weather_img.sh
Created June 12, 2012 01:39
get Tokyo weather image file(png)
#!/bin/sh
#
# yahoo weather
#
# weather image
URL=`curl --silent "http://weather.yahoo.com/japan/tokyo-prefecture/tokyo-1118370/" | \
grep background:url | sed -e "s/.*background:url('//" -e 's/png.*/png/' | grep -v partner-logo`
curl --silent -o /tmp/weather.png $URL
@kurosuke
kurosuke / weather_text.sh
Created June 12, 2012 01:40
get Tokyo weather text file
#!/bin/sh
#
# yahoo weather
#
# weather text
TEXT_INFO=`curl --silent "http://xml.weather.yahoo.com/forecastrss?p=JAXX0085&amp;u=c" | grep yweather:conditio `
TEXT=`echo $TEXT_INFO | sed -e 's/.*text="//' -e 's/".*//'`
TEMP=`echo $TEXT_INFO | sed -e 's/.*temp="//' -e 's/".*//'`
TEMP=`expr $TEMP - 50`
@kurosuke
kurosuke / led_onoff.py
Created November 24, 2012 15:17
pyhon GPIO control on Raspberry Pi
import time
import RPi.GPIO as GPIO
# GPIO setup
GPIO.setmode(GPIO.BCM)
# GPIO4(PIN7) setup for output
GPIO.setup(4, GPIO.OUT)
# 1sec on and 0.5sec off
@kurosuke
kurosuke / scan_switch.py
Created December 5, 2012 11:12
Raspberry Pi GPIO(11) INPUT status check
import time
import RPi.GPIO as GPIO
# GPIO setup
GPIO.setmode(GPIO.BCM)
# GPIO11(PIN23) setup for output
GPIO.setup(11, GPIO.IN)
# default status switch off(False)
@kurosuke
kurosuke / hostip.py
Created November 20, 2013 13:04
hostname convert to host ip. try mypc/mypc.local/mypc.localdomain
#!/usr/bin/python
# -*- coding: utf-8 -*-
import socket
import sys
def hostip(hostname):
try:
print socket.gethostbyname(hostname)
#!/bin/sh
domain=sample.com
maildir_path=/var/vhosts
new_user=$1
password=$2
if [ "$password" = "" ]; then
echo Usage: $0 user password
#!/bin/sh
domain=sample.com
new_user=$1
password=$2
if [ "$password" = "" ]; then
echo Usage: $0 user password
exit 1
Bleacon = require('bleacon');
Bleacon.startScanning();
Bleacon.on('discover', function(bleacon) {
console.dir(bleacon);
});