Skip to content

Instantly share code, notes, and snippets.

View qichunren's full-sized avatar
🌈
Focusing contribute

Qichunren qichunren

🌈
Focusing contribute
View GitHub Profile
@qichunren
qichunren / ca.sh
Last active June 11, 2020 10:25
常用 Linux 命令行
# 统计代码行数,不包括空行
find /src -name "*.cpp" |xargs cat|grep -v ^$|wc -l
# 查看进程内存使用情况
cat /proc/409/status | grep VmRSS | awk '{print $2}'
# 获取网卡设备对应的IP地址
ifconfig eth0 | grep "inet " | awk '{print $2}'
# 获取网卡设备对应的MAC地址
@qichunren
qichunren / readme.txt
Last active March 30, 2020 11:26
Install xubuntu 18.04
1. vscode from https://code.visualstudio.com/
2. ruby 2.6.5 from https://www.ruby-lang.org/zh_cn/, add bin path to /etc/environment
3. nodejs from https://nodejs.org/zh-cn/, sudo tar xf xx.tar.gz -C /usr/local, and add bin path to /etc/environment
4. sudo visudo, Add ruby and node path to secret path.
5. sudo npm install -g yarn
6. curl, git, gitg
$ git config --global user.name "qichunren"
$ git config --global user.email whyruby@gmail.com
7. openssh-server
8. Set up ssh key with right permisson flag.
@qichunren
qichunren / app.js
Created March 6, 2020 13:38
Replace Rails Turbolinks with pjax
function pajx_request(url) {
Rails.ajax({
url: url,
type: "get",
success: function (data) {
console.log(data);
$("#pajx_container").html(data.documentElement.innerHTML);
window.history.pushState(null, null, url);
},
beforeSend: (xhr, options) => {
@qichunren
qichunren / rsync-daemon.sh
Last active March 1, 2020 06:22
Auto sync source dir to target host.
#!/bin/bash
echo "Start rsync daemon ..."
for (( ; ; ))
do
echo "rsync checking ... [ hit CTRL+C to stop]"
rsync -az --exclude 'log/' --exclude 'tmp/' --exclude 'public/' --exclude 'node_modules/' --exclude '.git/' --exclude 'Gemfile.lock' --exclude 'yarn.lock' backend_www xxxxxx@192.168.43.175:/home/xxxxxxx/code/ --delete
sleep 3
done
@qichunren
qichunren / generate-ssh-key.sh
Created February 9, 2020 05:26 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# This sample code is a port of
# gstreamer/tests/examples/launch/mp3parselaunch.c. It is licensed
# under the terms of the GNU Library General Public License, version
# 2 or (at your option) later.
#
# Copyright (C) 2013 Ruby-GNOME2 Project Team
#
q = Queue.new
producer = Thread.new {
c = 0
while true do
q << c
c += 1
end
}
printer1 = Thread.new {
while true
require 'open-uri'
require 'json'
require 'time'
orders = {}
ROUTE_TYPE_CROSS = 7
ROUTE_TYPE_INNER = 3
@qichunren
qichunren / ruby.mk
Created May 9, 2019 12:30
Build root on arm with buildroot
#############################################################
#
# ruby
#
#############################################################
RUBY_VERSION = 1.9.2-p0
RUBY_SITE = ftp://ftp.ruby-lang.org/pub/ruby/1.9
RUBY_AUTORECONF = YES
HOST_RUBY_AUTORECONF = YES
@qichunren
qichunren / log.txt
Created May 6, 2015 07:58
temp set net configuration.
sudo ifconfig eth0 192.168.11.187 netmask 255.255.0.0
sudo route add default gw 192.168.8.5
add nameserver 192.168.8.5 to file /etc/resolv.conf
cd /media/xubuntu/WD2TB
sudo dd if=/dev/sda of=T420HDD-20150506.img