Skip to content

Instantly share code, notes, and snippets.

View simlegate's full-sized avatar
🎯
Focusing

Devin Zhang simlegate

🎯
Focusing
View GitHub Profile
@simlegate
simlegate / custom-error-page
Created October 31, 2014 05:35
Nginx return custom json
error_page 400 404 405 =200 @40*_json;
location @40*_json {
default_type application/json;
return 200 '{"code":"1", "message": "Not Found"}';
}
error_page 500 502 503 504 =200 @50*_json;
location @50*_json {
@simlegate
simlegate / install.md
Last active January 20, 2022 03:41
搭建私有的gems仓库

分为步:

  • 同步gems mirror
    安装rubygems-mirror 原来的rubygems-mirror好像有问题,所以使用@huacnlee改过的gem
    按照README.md说明配置.mirrorrc

    # 国内最好用taobao的源,rubygems经常被墙
    ---
    - from: http://ruby.taobao.org
    to: /data/rubygems
@simlegate
simlegate / MainActivity.java
Last active April 14, 2021 02:44
something should android do when screen on and screen off .
package com.simlegate.saveresource;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
@simlegate
simlegate / linux-command
Last active July 16, 2017 10:01
Linux常用命令
# 查看网络端口占用情况
netstat -an | grep 9000
# 通过list open file命令可以查看到当前打开文件,在linux中所有事物都是以文件形式存在,包括网络连接及硬件设备。
lsof -i:9000
# 查看php.ini文件的位置
php --ini
@simlegate
simlegate / fetch.js
Created March 14, 2017 08:14
Fetch Api Wrapper
function http(method, url, request) {
let init = { method: 'GET' }
if(method != 'GET') {
init.body = request.body
}
return fetch(url, init).
then(function(response){
if(response.ok){
response.json().then(function(json){
@simlegate
simlegate / node-module-require
Created March 18, 2016 11:14
The require of Node Module
From https://nodejs.org/api/modules.html
require(X) from module at path Y
1. If X is a core module,
a. return the core module
b. STOP
2. If X begins with './' or '/' or '../'
a. LOAD_AS_FILE(Y + X)
b. LOAD_AS_DIRECTORY(Y + X)
3. LOAD_NODE_MODULES(X, dirname(Y))
@simlegate
simlegate / rubycas_test.md
Last active January 27, 2016 16:52
describe how to spec rubycas with rspec.

rubycas client configuration options in config/envirement.rb
[more details] (https://github.com/rubycas/rubycas-client)

# enable detailed CAS logging
cas_logger = CASClient::Logger.new(::Rails.root+'/log/cas.log')
cas_logger.level = Logger::DEBUG

CASClient::Frameworks::Rails::Filter.configure(
  :cas_base_url  => "https://cas.example.foo/",
  :login_url     => "https://cas.example.foo/login",
@simlegate
simlegate / _service.md
Created January 16, 2016 11:54 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@simlegate
simlegate / after_linux.sh
Created January 23, 2014 09:31
安装Linux后自动安装常用的软件
#!/bin/bash
PKG_MANGER="sudo apt-get install"
HOME="/home/simlegate"
echo $PKG_MANGER
echo "正在安装Git......."
nohup $PKG_MANGER git
@simlegate
simlegate / logger.clj
Last active December 28, 2015 13:49
利用可组合的高阶函数构建的一个日志系统
(ns logger.core)
(defn print-logger
[writer]
#(binding [*out* writer]
(println %)))
;; 将消息打印到一个内存buffer
(def writer (java.io.StringWriter.))