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 / menu-demo.html
Created October 12, 2020 03:39
html纯css实现导航栏下拉菜单(带下拉三级菜单)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>庄稼汉</title>
<style>
* {
margin: 0;
padding: 0;
}
@qichunren
qichunren / file_sync.cpp
Created September 30, 2020 03:32
File sync
/*
# Author: Qichunren
# Email: whyruby@gmail.com
*/
#include "files_sync.h"
#include "nt_config.h"
#include "nt_utils.h"
#include <QDir>
#include <QTimer>
@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