Skip to content

Instantly share code, notes, and snippets.

View lengerfulluse's full-sized avatar
🏠
Working from home

Wei Heng lengerfulluse

🏠
Working from home
View GitHub Profile
#!/usr/bin/python
from __future__ import print_function
import re
def url_mapping():
'''Mapping jekyll like http://t.hengwei.me/post/title/ ---> http://t.hengwei.me/post/title.html'''
with open("lengerfulluse-old.csv", 'r') as fo, open("lengerfulluse-url-mapping.csv", 'w') as fw:
for line in fo:
@lengerfulluse
lengerfulluse / aws_command_collection.py
Created September 1, 2016 13:35
common used aws commands collection
# change pem file mode
chmod 400 /path/my-key-pair.pem
# use ssh to login ec2 instance.
ssh -i /path/my-key-pair.pem ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com
@lengerfulluse
lengerfulluse / revert_file_in_commit.sh
Created September 6, 2016 09:17
git revert a specific file in a commit script
#!/bin/bash
function output_help {
echo "usage: git-revert-single-file <sha1> <file>"
}
sha1=$1
file=$2
if [[ $sha1 ]]; then
@lengerfulluse
lengerfulluse / bash_common_used.md
Last active July 18, 2018 05:58
common used awk command
#/bin/bash
loop=0
sum=0
str=`ls`
arr=($str)
while [ $loop -lt 100 ]; do
res=`wc -l ${arr[$loop]}`
line=`echo $res | cut -d' ' -f1`
echo $line
sum=$(($sum+$line))
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cn.mynux.data.statistics</groupId>
<artifactId>feed-data-analysis</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
@lengerfulluse
lengerfulluse / common_used_perl_command.sh
Last active February 16, 2017 02:57
common perl command for shell
# remove end ^M character
perl -pe 's{\d+\.\d+%}{$&/100}eg'
# parse csv file, convert to tsv file.
perl -MText::ParseWords -lne'
print join "\t", map "$_",
parse_line(",",0, $_); # if you want to keep the double-quotes of the field, just use put '1' instead of 0 as the second parameter.
' infile.csv >infile.tsv
@lengerfulluse
lengerfulluse / tensorflow_install_steps
Created March 31, 2017 08:45
tensorflow install tutorial
http://www.liuxiao.org/2017/02/tensorflow-mac-os-%E4%B8%8A-tensorflow-%E5%AE%89%E8%A3%85%EF%BC%88%E6%94%AF%E6%8C%81-cuda%EF%BC%89/
https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps
1. set remote git repo
2. set local git branch: git remote add tech ssh://hengwei@hengwei.me:~/repos/t.hengwei.me.git
3. git push: git push live master
@lengerfulluse
lengerfulluse / install_pygments_on_mac
Last active November 30, 2017 09:02
install pygments for jekyll on MacOs
command `sudo easy_install pygments` seems not work for me, use the following command got successfully.
sudo gem install pygments.rb