Skip to content

Instantly share code, notes, and snippets.

View kennx's full-sized avatar
:octocat:
iGlow

张远山 kennx

:octocat:
iGlow
View GitHub Profile
@kennx
kennx / zodiac.swift
Created January 9, 2020 11:01 — forked from mxcl/zodiac.swift
enum Zodiac: String {
case aries, taurus, gemini, cancer, leo, virgo, libra, scorpio, sagittarius, capricorn, aquarius, pisces
}
extension Zodiac {
var dateRangeString: String {
let df = DateFormatter()
df.dateFormat = "MMM d"
let from = df.string(from: dateRange.lowerBound)
let to = df.string(from: dateRange.upperBound)
@kennx
kennx / customer.js
Created April 15, 2019 03:05 — forked from geek0x23/customer.js
A mongoose model that takes advantage of the handy invalidate method to run multiple validations
var mongoose = require('./db-connect'),
Schema = mongoose.Schema,
ObjectId = Schema.ObjectId,
uuid = require('node-uuid'),
Validator = require('validator').Validator,
val = new Validator(),
bcrypt = require('bcrypt');
Validator.prototype.error = function(msg) { return false; };
@kennx
kennx / app.js
Created February 18, 2017 08:23 — forked from guileen/app.js
Express Custom 404
var express = require('express'),
mongoose = require('mongoose'),
app;
app = module.exports = express.createServer();
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
@kennx
kennx / kongwu_pi_tips.md
Last active August 29, 2015 14:27 — forked from kennyz/kongwu_pi_tips.md
kongwu pi tips

折腾Pi,解决疑难杂症最好还是去官网论坛

image http://www.raspberrypi.org/phpBB3/

支持Apple TimeMachine,实现Mac备份

在磁盘中创建备份目录 mkdir /media/usbdisk/mactimebak 推荐使用ext4分区(打开notime)

安装nettalk

#Wrapper {
background-image: none;
background-color: #EEE;
}
a:link, a:visited, a:active {
color: #8e8d93;
}
a.top:link, a.top:visited, a.top:active {
@kennx
kennx / Gemfile
Created August 7, 2013 07:06 — forked from kaichen/Gemfile
source :rubygems
gem "eventmachine", "0.12.10"
gem "rack"
#!/bin/sh
set -e
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/var/www/app
APP_USER=user
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENV=production
if [ -n "$2" ]; then
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
#!/usr/bin/env bash
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install gcc
sudo apt-get install git-core
sudo apt-get install build-essential zlib1g-dev libssl-dev libxml2-dev libxslt-dev libreadline6-dev libyaml-dev
cd ~/downloads
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz
tar -xvzf ruby-1.9.3-p392.tar.gz
cd ruby-1.9.3-p392/
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import re
ntfs_pattern = re.compile(r'File System Personality: NTFS')
ntfs_device_node = re.compile(r'.*Device Node:.*')
device_dict = {}