Skip to content

Instantly share code, notes, and snippets.

View liuyanghejerry's full-sized avatar
Focusing

liuyanghejerry liuyanghejerry

Focusing
View GitHub Profile
@liuyanghejerry
liuyanghejerry / redis.sh
Last active December 16, 2015 09:19
Redis-server management script for CentOS 6.3.
#!/bin/bash
# chkconfig: - 80 12
# description: Controller for redis-server
# processname: redis
# useage: redis {start|stop|restart}
# notice, you need to edit these 4 variables bellow to suit your condition
BIN="/usr/local/redis/bin/redis-server"
@liuyanghejerry
liuyanghejerry / PainterTest.pro
Created August 11, 2013 11:11
This is a test case of tablet support for Qt 5.
QT += core gui concurrent
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = PainterTest
TEMPLATE = app
CONFIG += c++11
SOURCES += main.cpp\
@liuyanghejerry
liuyanghejerry / main.cpp
Created October 12, 2013 11:34
Calculate how many different IP in painttyServer's log.
#include <QCoreApplication>
#include <QFile>
#include <QFileInfo>
#include <QTextStream>
#include <QStringList>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
@liuyanghejerry
liuyanghejerry / is_in_dict.cpp
Last active December 25, 2015 14:09
给定字符串,以及一个字典,判断字符串是否能够拆分为字段中的单词。例如,字段为{hello,world},字符串为hellohelloworld,则可以拆分为hello,hello,world,都是字典中的单词。 题目来源:http://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5ODIzNDQ3Mw==&appmsgid=10000306&itemidx=1&sign=45327171923a822ffd8727e6983727c2 原题解是动态规划,本代码是备忘录式的递归法。
#include <iostream>
#include <string>
#include <unordered_map> // need c++11 or c++0x
using namespace std;
unordered_map<string, bool> dict;
unordered_map<string, bool> memo;
inline bool is_in_dict_pri(const string& word)
@liuyanghejerry
liuyanghejerry / 0_reuse_code.js
Created December 28, 2013 12:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@liuyanghejerry
liuyanghejerry / gist:a309ef54580004879b40
Created May 7, 2014 12:50
在小米路由上运行Node.js

相信很多人和我一样,拿到小米路由玩了几天,感觉官方的步伐不够快不够激进。既然如此,何不自己动手丰衣足食呢?

背景知识

首先你得知道Linux的一些基本理论,比如什么是bash啊,cdls这些命令怎么用等等。

其次你还得知道一些编程相关的东西,因为文章专注于Node.js的编译,所以Node.js和C++的一些基本知识是要有的。

热身准备

#!/bin/sh
rpm -Uih https://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
curl -L https://get.rvm.io | bash -s stable
rvm install 2.0.0
rvm use 2.0.0@global --default
# for chinese user, if you have a wonderful speed ignore this part
# to have a faster download speed
# switch gem source to ruby.taobao.org
@liuyanghejerry
liuyanghejerry / update-git.sh
Created October 20, 2014 17:34
How to update git on CentOS
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.2-2.el6.rf.*.rpm
rpm -i rpmforge-release-0.5.2-2.el6.rf.*.rpm
yum --disablerepo=base,updates --enablerepo=rpmforge-extras update git
# http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-2/devtools-2.repo
yum --enablerepo=testing-devtools-2-centos-6 install devtoolset-2-gcc devtoolset-2-gcc-c++
scl enable devtoolset-2 bash
@liuyanghejerry
liuyanghejerry / exepath.go
Created January 30, 2015 15:24
exe path in golang
package main
import (
"fmt"
"log"
"os"
"path/filepath"
)
func main () {