Skip to content

Instantly share code, notes, and snippets.

@utaani
utaani / makedate
Created July 23, 2008 05:41
make datetime string like "20080720192345"
##-- makedate: 日付文字列の作成
sub makedate {
my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=(localtime);
sprintf( "%04.4d%02.2d%02.2d%02.2d%02.2d%02.2d",
1900+$year,$mon+1,$mday,$hour,$min,$sec);
}
@utaani
utaani / str2japan_phone_number.js
Created March 20, 2012 23:09
Javascriptで日本の電話番号にハイフンをつける
<script type="text/javascript">
<!--
function str2japan_phone_number(org) {
// Japan Phone Number add Hyphen
// c.f. http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/index.html
// c.f. http://www.soumu.go.jp/main_sosiki/joho_tsusin/top/tel_number/q_and_a-2001aug.html
// c.f. http://oshiete.goo.ne.jp/qa/2888873.html
var num_format = new Array(
// special numbers
@utaani
utaani / seteth1.sh
Created March 22, 2012 23:14
ifconfig eth1 with fixed IP address on Amazon-VPC ENI(Elastic Network Interface)
#!/bin/sh
# set IP address with Amazon-VPC ENI(Elastic Network Interface) address and other.
# get eth0/1 MAC addresses
MACADDR0=`cat /sys/class/net/eth0/address`
MACADDR1=`cat /sys/class/net/eth1/address`
# get eth0/1 IP addresses on ENI
IPADDR0=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MACADDR0}/local-ipv4s/`;
IPADDR1=`/usr/bin/curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/${MACADDR1}/local-ipv4s/`;
# ifconfig on eth1 (ENI)
/sbin/ifconfig eth1 inet ${IPADDR1} netmask 255.255.255.0 2>&1 >> /tmp/seteth1.log
@utaani
utaani / ltsv2tsv.pl
Created July 10, 2013 23:42
LTSVのラベルをはずしてTSVに変換。cutとかで処理しやすいように。
#!/usr/bin/perl
my $line;
my $param;
my @params;
while($line=<STDIN>) {
my @keys;
my @vals;
chomp($line);
@params=split(/\t/,$line);
foreach $param (@params) {
@utaani
utaani / node-red-google-cloud-vision-ocr.json
Created February 24, 2016 05:24
Google Cloud Vision OCR test
[
{
"id": "b9814cc7.854288",
"type": "template",
"z": "cec74554.ecbe",
"name": "JSON template",
"field": "payloadrule",
"fieldType": "msg",
"format": "json",
"syntax": "plain",

firefox alert image

@utaani
utaani / rPi3-ap-setup.sh
Last active January 5, 2017 12:03 — forked from Lewiscowles1986/rPi3-ap-setup.sh
Raspberry Pi 3 access-point-setup
#!/bin/bash
#
# This version uses September 2016 rpi jessie image, please use this image
#
if [ "$EUID" -ne 0 ]
then echo "Must be root"
exit
fi
@utaani
utaani / get_cybozulive_access_taken.pl
Created September 2, 2013 02:07
get_cybozulive_access_taken.pl : サイボウズLive! にAPIでアクセスするのに必要なアクセストークンをxAuthで取得する。 OAuth::Lite::Consumer http://search.cpan.org/~lyokato/OAuth-Lite-1.31/ を使う。 Developer Center https://developer.cybozulive.com/ でデベロッパー登録した上で、アプリケーション登録をして Consumer Key/Consumer Secretを取得する。 SSLをProxy経由で用いるため、Net::SSLを使うように上書きする。 参考: https://developer.cybozulive.com/…
#!/usr/bin/perl
use OAuth::Lite::Consumer;
use Data::Dumper;
$ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
$ENV{HTTPS_PROXY} = 'http://192.168.11.254:8080';
my $consumer = OAuth::Lite::Consumer->new(
[
{
"id": "34d42654.9be66a",
"type": "switch",
"z": "1f17baae.3051ed",
"name": "補正あり",
"property": "payload",
"propertyType": "msg",
"rules": [
{
@utaani
utaani / nrpiadminpass.sh
Last active October 2, 2019 05:12
admin password creator for Node-RED on Raspberry Pi
#!/bin/bash
# password setter for Node-RED on Raspberry Pi
# auther: utaani@ueno.org
#
# usage: bash nrpiadminpass.sh password
#
# this script will change Pi default Node-RED file.
# after that, you need nodered restart with node-red-restart
# password