Skip to content

Instantly share code, notes, and snippets.

View kilfu0701's full-sized avatar

kilfu0701 kilfu0701

  • Trend Micro
  • Japan & Taiwan
View GitHub Profile
@kilfu0701
kilfu0701 / balanced_string.py
Last active July 16, 2020 03:10
balanced string
def solution(s):
n = len(s)
ans = 999
for i in range(n - 1):
q = set([s[i]])
for j in range(i + 1, n):
q.add(s[j])
#print(i, j , q, len(q))
@kilfu0701
kilfu0701 / 1.sh
Last active July 10, 2020 02:08
Execute in a date range & each day.
#!/bin/bash
d="2020-01-01"
until [[ $d > 2020-05-01 ]]; do
p=`echo $d | sed -e 's/-//g'`
/home/work/php7.3.2/bin/php /path/to/project/artisan generate:report Log1 "$p"
/home/work/php7.3.2/bin/php /path/to/project/artisan generate:report Log2 "$p"
/home/work/php7.3.2/bin/php /path/to/project/artisan generate:report Log3 "$p"
d=$(date -I -d "$d + 1 day")
done
@kilfu0701
kilfu0701 / convert.cpp
Created October 24, 2019 02:48
C++ UTF8 to Shift-jis (with ICU)
//
// @reference https://faithandbrave.hateblo.jp/entry/20100318/1268896477
// @memo
// on CentOS:
// yum install libicu libicu-devel
// g++ -std=c++14 -o cvt convert.cpp `pkg-config --libs --cflags icu-uc icu-io`
//
#include <iostream>
#include <vector>
yum update
yum install epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install --enablerepo=remi,remi-php72 php php-devel php-mbstring php-pdo php-gd php-xml php-mcrypt php-zip
yum install wget vim
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
compopt
ln -s /usr/local/bin/composer /usr/bin/
@kilfu0701
kilfu0701 / adb_cmd.sh
Created June 14, 2019 06:52
some adb commands
# list all apps
adb shell pm list packages -f
# install apk
adb install -r -t XXX.apk
# uninstall apk
adb uninstall com.thk.test_app
// find in a date range, which column is Number() Type.
db.collection.find({
created_at: {
$gte: (new Date(2019, 5, 1)).getTime()/1000, // from 2019-06-01
$lte: (new Date(2019, 5, 2)).getTime()/1000 // to 2019-06-02
}
})
// find by some field and count to result
DBQuery.shellBatchSize = 10000
from struct import *
import os
for subdir, dirs, files in os.walk('./'):
for file in files:
filepath = subdir + os.sep + file
if file == '_1.py':
continue
@kilfu0701
kilfu0701 / str.go
Created March 27, 2019 04:15
golang mongodb ObjectID base64 encode & decode. https://play.golang.org/p/IACE8_AE-CT
package main
import (
"encoding/base64"
"encoding/hex"
"fmt"
"strings"
)
func Hex2bin(s string) []byte {
@kilfu0701
kilfu0701 / install.sh
Last active February 14, 2019 10:16
(fluentd) some memo
cd /tmp
wget https://toolbelt.treasuredata.com/sh/install-redhat-td-agent3.sh
chmod +x install-redhat-td-agent3.sh
./install-redhat-td-agent3.sh
chkconfig td-agent on
service td-agent start
## install plugin
### install td-agent
wget https://toolbelt.treasuredata.com/sh/install-redhat-td-agent3.sh
chmod +x install-redhat-td-agent3.sh
./install-redhat-td-agent3.sh
chkconfig td-agent on
/usr/sbin/td-agent-gem install fluent-plugin-ua-parser
service td-agent start