This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// トリガー設定で1時間毎ぐらいに起動する | |
function myFunction() { | |
threads = GmailApp.search('label:kin is:unread') // ラベルはフィルタ設定でつける | |
if (threads.length == 0) { | |
return | |
} | |
message = threads[0].getMessages()[0] // どの一通でも通知されれば見にいくので | |
text = "メールだよ\n" + message.getFrom() + "\n「" + message.getSubject() + "」" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
var sheet = SpreadsheetApp.getActive().getActiveSheet(); | |
var file = DriveApp.getFilesByName("test_1.csv").next(); | |
import_csv(sheet, file); | |
} | |
function import_csv(sheet, file, r, c, enc) { | |
var table = Utilities.parseCsv(file.getBlob().getDataAsString(enc || "SHIFT_JIS"); | |
sheet.getRange(r || 1, c || 1, table.length, table[0].length).setValues(table); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for pid_file in /var/run/*.pid; do | |
t=${pid_file##*/} | |
cmd=${t%.*} | |
pid=`cat $pid_file` | |
comm=/proc/$pid/comm | |
if [ -e $comm ]; then | |
if [ `cat $comm` == $cmd ]; then | |
continue | |
fi | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# vim:fileencoding=utf-8 | |
# xのn乗根 | |
def root(x, n) | |
r = 0 | |
a = 1 << (Math.log(x) / n / Math.log(2)) | |
while a > 0 | |
ra = r | a | |
d = x - ra ** n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
missing='' | |
for cmd in curl unzip fontforge; do | |
if ! type $cmd &>/dev/null; then | |
missing="$missing$sep$cmd" | |
sep=', ' | |
fi | |
done | |
if [ -n "$missing" ]; then |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
# ESC [ 38 ; 5 ; %3d m ForeGround | |
# ESC [ 48 ; 5 ; %3d m BackGround | |
my @formats = ( "\e[48;5;%dm \e[m ", "%3d " ); | |
print "System colors:\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LIMIT = 4; // 自主的に中断する時間(分) | |
var INTERVAL = 1; // 再開まで(分) | |
var CHUNK = 20; // 一気に処理するアイテム数。この数ごとに時間を気にする | |
var PROPERTY_NAME = "storage"; // データのセーブ用プロパティ名 | |
function myFunction() { | |
// タイムリミットの時刻を計算 | |
var time_limit = new Date() -0 + LIMIT * 60 * 1000; | |
var sheet = SpreadsheetApp.getActiveSheet(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl -w | |
use strict; | |
package CIDRs { | |
sub new { bless +{}, shift } | |
sub add { | |
my ($self, $cidr) = @_; | |
my ($ipv4, $w) = split '/', $cidr; | |
my $b = (hex join '', map { sprintf '%02X', $_ } split /\./, $ipv4) >> 32 - $w; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
sub thconv | |
{ | |
my $n = shift; | |
my ($offset, $divider, $digits) = (1, 0, 0); | |
do { | |
$offset *= 0x100; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub get_data | |
{ | |
my ($self, $key) = @_; | |
$data = $self->get($key); | |
$flag = $self->get("$key\::flag"); | |
unless ($flag && $data) { | |
$self->set("$key\::flag", 1, $self->expire - $self->delta); | |
...; # do task |
NewerOlder