Skip to content

Instantly share code, notes, and snippets.

View Likk's full-sized avatar

Likkradyus Likk

  • MF
  • Tokyo, Japan
  • 04:27 (UTC +09:00)
  • X @likk
View GitHub Profile
@Likk
Likk / datetime2.cfml
Created August 28, 2019 06:09
ColdFusion で日付処理
<cfset localDate = now()>
<cfset utcDate = DateConvert("Local2utc", localDate)>
<cfset epoch = DateDiff("s", "January 1 1970 00:00", utcDate)>
<cfset utime = 1371729285>
<cfoutput>
Local Date: #localDate# <br>
UTC Date: #utcDate# <br>
Epoch: #epoch# <br>
Time :#DateAdd("s", utime ,DateConvert("utc2Local", "January 1 1970 00:00"))# <br>
yymmdd24hmiss: #DateFormat(localDate, "yyyy/MM/dd")# #TimeFormat(localDate, "HH:mm:ss")#
@Likk
Likk / drop_merged_branch
Last active August 22, 2019 10:42
現在作業中のブランチにマージ済みのローカルブランチをローカルからもリモートからも消すワンライナー
git branch --merged | sed 's/\(^ \+\| \+$\)//g' | perl -nlE ' `git push --delete origin $_; git branch -d $_`'
@Likk
Likk / main.go
Last active July 3, 2019 02:08
GoのバイナリをPerl/Ruby/PHPスクリプトとしても扱う (元ネタ https://codehex.hateblo.jp/entry/2019/07/02/090000 https://uzulla.hateblo.jp/entry/2019/07/02/191859)
package main
import (
"fmt"
"io/ioutil"
)
const script = `<?php
file_put_contents("php://stderr", "This is PHP world!!!".PHP_EOL);
__halt_compiler();
@Likk
Likk / slack_rtm_bot_test1.pl
Last active March 30, 2017 12:05
子プロセス無いで死ぬとその後継続しない
use strict;
use warnings;
use utf8;
use Encode;
use Slack::RTM::Bot;
while(1){
my $bot = Slack::RTM::Bot->new(
token => 'XXXX',
options => +{ max_message_size => 20480 }
@Likk
Likk / slack_term.pl
Last active March 24, 2017 12:09
コマンドラインからslackチャット
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Carp;
use Config::Pit;
use DateTime;
use Encode;
@Likk
Likk / slack.pl
Created March 24, 2017 10:15
Slack::RTM::Bot CLI viewer Raw
use strict;
use warnings;
use utf8;
use Encode;
use Slack::RTM::Bot;
use Term::ANSIColor;
my $bot = Slack::RTM::Bot->new(
token => 'YOUR TOKEN',
);
@Likk
Likk / git_clean.pl
Last active December 17, 2015 14:48
対話式 git-clean
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
use feature ':5.10';
use Getopt::Long qw(GetOptions :config posix_default no_ignore_case bundling );
use Params::Validate qw/:all/;
use Pod::Usage 'pod2usage';
@Likk
Likk / WWW::Lingr
Last active December 14, 2015 23:59
Lingr スクレイピングやっつけ
package WWW::Lingr;
use strict;
use warnings;
use utf8;
use Carp;
use Encode;
use Try::Tiny;
use Web::Scraper;
use WWW::Mechanize;
@Likk
Likk / negatibot.rb
Created September 30, 2012 11:54
negatibot on wassr
#!/usr/bin/ruby -Ku
require 'uri';
require 'net/http';
require 'rexml/document';
class Negatibot
def initialize
@message = nil
@dt = Time.now;
@Likk
Likk / gist:2318514
Created April 6, 2012 09:38
croudiaのIDが連番になっているので、最初の登校から順繰りぬきだすワンライナー
perl -MLWP -e 'my $ua = LWP::UserAgent->new; for my $n (1..400){ my $r = $ua->get(q{http://croudia.com/voices/show/}.$n); my $h = Encode::encode_utf8($r->decoded_content); $h =~ s{\n}{}g; my $line = ""; if($h =~ m{<span class="gray">([0-9].*?)</span>}){ $line .= $1. "\t"} if($h =~ m{<span class="gray">(.*?)</span>}){ $line.= $1. "\t" } if($h =~ m{<div style="background-color:#FFF;">(.*?)<br}){ $line.= $1} if($line ne q{}){print "${n}\t${line}\n"}; sleep 1 ; }'