Skip to content

Instantly share code, notes, and snippets.

View skyjia's full-sized avatar
🎯
Focusing

Sky JIA skyjia

🎯
Focusing
View GitHub Profile
@skyjia
skyjia / server.go
Created September 23, 2012 12:32 — forked from wanghailei/server.go
A simple server in Go
package main
import "net/http"
func main() {
panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("/File/Folder/Path"))))
}
@skyjia
skyjia / sinatra_redis.rb
Last active February 4, 2024 21:54
Sinatra with Redis Session
require "sinatra"
require "sinatra/reloader"
require "redis-store"
require 'redis-rack'
class ApplicationController < Sinatra::Base
configure :development do
register Sinatra::Reloader
end
sudo su -
# stuff we need to build from source
apt-get install libpcre3-dev build-essential libssl-dev
# get the nginx source
cd /opt/
wget http://nginx.org/download/nginx-0.8.54.tar.gz
tar -zxvf nginx*
# we'll put the source for nginx modules in here
@skyjia
skyjia / nginx.sh
Created March 30, 2013 13:50 — forked from squarism/nginx.sh
#!/bin/bash
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@skyjia
skyjia / SHA1_MD5.m
Last active December 17, 2015 01:49
SHA1 and MD5 with Objective C
#import <CommonCrypto/CommonDigest.h>
-(NSString*) sha1:(NSString*)input
{
const char *cstr = [input cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:input.length];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, data.length, digest);

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@skyjia
skyjia / hide_desktop_icons.sh
Created August 19, 2014 14:14
Hide/Show OSX Desktop Icons
#!/bin/bash
DIR="$HOME/Desktop"
FILE="$DIR/.hidden_icons"
# hide icons for Windows VM
always_hide() {
chflags hidden $DIR/\$RECYCLE.BIN
chflags hidden $DIR/desktop.ini
}
@skyjia
skyjia / general_interview_questions
Created September 3, 2014 08:19
General interview questions
- What projects are you working on at home?
- What beta toys are you playing with?
- What source control do you use?
- How do you approach your documentation?
- Which tools do you use for keeping track of requirements?
- Give me an example of a project that completely failed?
- How do you design scalable applications?
- What language to you prefer for writing complex algorithms?
- Which tools are needed for testing the quality of your code?
- How to debug a web application from client, frontend, to backend?
@skyjia
skyjia / boot.js
Last active August 29, 2015 14:06 — forked from jdx/boot.js
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@skyjia
skyjia / paging_with_key.sql
Last active March 18, 2016 14:52
使用Key进行分页
SET @start_key=1005069;
SET @paging_size = 20;
SELECT * FROM (
SELECT
(@row_num:=@row_num + 1) AS `@row_num`,
(@row_num_in_page:=CASE
WHEN f.id = @start_key THEN 0
WHEN @row_num_in_page>=0 THEN @row_num_in_page+1
ELSE -1