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 / gist:420d65af2b584945ee2e5cc5e0c56fed
Created June 3, 2018 11:27
ffmpeg rotate+crop+scale command
ffmpeg -i MAH01360.MP4 -filter_complex "[0:v]rotate=15*PI/180[v1]; [v1]crop=1440:810:240:135[v2]; [v2]scale=1920:1080" out.mp4
COPY (
SELECT
A2.id AS "記事ID",
A2.title AS "タイトル",
A2.sub_title AS "サブタイトル",
CONCAT('https://XXX.com/', IMG.width, '/', IMG.height, '/', IMG.filename) AS "画像URL",
A2.content AS "本文",
A2.html_content AS "HTML本文",
A2.meta_description AS "META ディスクリプション",
A2.author_id AS "投稿者ID",
@kilfu0701
kilfu0701 / convert.pl
Created February 7, 2018 15:22
Convert CSV into SQL import format
# lists.csv
# ID,Email,Name
# 1,user001@examplemail,Name001
# 2,user002@examplemail,Name002
# 3,user003@examplemail,Name003
cat lists.csv | perl -ne 'if(@r=split(m/\r/,$_)){
foreach(@r) {
if(@x=split(/,/,$_)) {
$token=join('\'''\'', map +(0..9,'\''a'\''..'\''z'\'','\''A'\''..'\''Z'\'')[rand(62)], 1..32);
@kilfu0701
kilfu0701 / cmd.sh
Created September 28, 2017 02:33
some useful command
[DELETE]
# delete files with numbers
for i in {101..151}; do rm -f "file_$i.json"; done
[FILE]
# check file infomations
file -I test.png
# sort by modified time
@kilfu0701
kilfu0701 / parse_json.java
Created September 15, 2017 02:48
parse json in JAVA
import java.io.BufferedReader;
import java.io.FileReader;
import org.json.*;
public class t {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new FileReader("1.json"));
try {
StringBuilder sb = new StringBuilder();
@kilfu0701
kilfu0701 / awk.sh
Created May 10, 2017 01:42
My AWK commands
### Calculate total sum for prices in a file
# file content sample:
#I, [2017-05-09T23:50:19.364803 #19144] INFO -- : 32:userA の売上集計をしました(2880円)
#I, [2017-05-09T23:50:20.212623 #19144] INFO -- : 33:userB は売上がないので飛ばしました
#I, [2017-05-09T23:50:27.657490 #19144] INFO -- : 51:userC の売上集計をしました(175738円)
grep -r "円" sales.log-20170510 | gawk 'match($0, /.*\((.*)円\)$/, a) {print a[1]}' | awk '{ sum += $1 } END { print sum }'
@kilfu0701
kilfu0701 / myDockerMemo.sh
Last active May 5, 2017 07:10
[Docker] Quick start with docker. (For Ubuntu 16.04 above)
### Docker MEMO
# install
sudo apt-get update
sudo apt-get install -y docker.io
sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker
# download image
docker pull ubuntu:17.04
@kilfu0701
kilfu0701 / install.sh
Created April 20, 2017 07:15
Install ruby and rails ( CentOS 7 )
yum install -y git git-core zlib zlib-devel gcc-c++ patch readline readline-devel \
libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake \
libtool bison curl sqlite-devel ImageMagick ImageMagick-devel mysql-devel
cd ~
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
var f = function(i) {
$.ajax({
url: 'https://api-native-jizen.kamihimeproject.net/csrf',
dataType: 'json',
type: 'GET',
xhrFields: {
withCredentials: true
}
}).done(function(data) {
$.ajax({
@kilfu0701
kilfu0701 / rails_c.rb
Created March 8, 2017 03:21
Output JSON format in Rails Console (including query log)
ActiveRecord::Base.logger = Logger.new(STDOUT)
post = Post.find(3936)
ActiveModel::ArraySerializer.new([post], serializer: PostSerializer).to_json