Skip to content

Instantly share code, notes, and snippets.

View leopku's full-sized avatar

Song Liu leopku

View GitHub Profile
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@kerimdzhanov
kerimdzhanov / random.js
Last active June 3, 2025 16:04
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}
@elidupuis
elidupuis / README.md
Created November 27, 2013 22:49
Simple filtering example using Stapes.js and Rivets.js

Dependencies managed with Bower:

npm install -g bower
bower install

...Then open up index.html in a browser.

@leopku
leopku / nginx.conf
Created December 8, 2013 11:59 — forked from leon/nginx.conf
server {
listen 80;
server_name localhost;
root /home/website/web;
rewrite ^/app\.php/?(.*)$ /$1 permanent;
try_files $uri @rewriteapp;
location @rewriteapp {
@thoop
thoop / nginx.conf
Last active May 27, 2025 07:08
Official prerender.io nginx.conf for nginx
# Change YOUR_TOKEN to your prerender token
# Change example.com (server_name) to your website url
# Change /path/to/your/root to the correct value
server {
listen 80;
server_name example.com;
root /path/to/your/root;
index index.html;
@morlay
morlay / stackEdit.transMode.preview.js
Last active January 2, 2016 02:28
stackEdit.transMode.preview.js
(function(userCustom, document, localStorage) {
userCustom.onReady = function() {
var styles = [];
styles.push('.trans-mode{width:50%!important;margin:0!important;}');
styles.push('p,h1,h2,h3,h4,h5,h6,li{position:relative;}');
styles.push('.trans-mode .zh{display:block;position:absolute;top:0;right:0;width:98%;margin-right: -100%;font-size:0.8em;font-family:"微软雅黑"}');
styles.push('.trans-mode pre,.trans-mode blockquote{width: 200%;}');
styles.push('.trans-mode blockquote p{width: 46%;}');
@pyk
pyk / active-record-migration-expert.md
Last active August 2, 2021 09:20
become active record migration expert (Rails 4.0.2)

become active record migration expert (Rails 4.0.2)

workflow:

create model

$ rails g model NameOfModel
    invoke  active_record
    create    db/migrate/YYYYMMDDHHMMSS_create_name_of_models.rb
@felix021
felix021 / PortForwarder.py
Last active August 1, 2016 15:22
Bind a local tcp port, and forward requests to a remote port directly.绑定本地tcp端口,并把请求直接转发到远程端口。
#!/usr/bin/python
# simplified from msocks5.py @ https://github.com/felix021/ssocks5
import sys
import signal
try:
import gevent
@LibertysYarn
LibertysYarn / timeline.css
Created January 30, 2014 23:04
Responsive Timeline - Bootstrap 3
.timeline {
list-style: none;
padding: 20px 0 20px;
position: relative;
}
.timeline:before {
top: 0;
bottom: 0;
position: absolute;
@RicardoWEBSiTE
RicardoWEBSiTE / vagrantstrap.sh
Created February 5, 2014 21:47
Vagrant Bootstrapping Ubuntu Precise 32bit for Laravel 4, Apache 2.2.22, PHP 5.4, MySQL 5.5 , Vim, cURL, Git, Composer, pip, HTTPie
#!/usr/bin/env bash
# Configurable variables
database='vagrant'
username='vagrant'
password='vagrant'
echo ''
echo ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
echo ' Bootstrapping Ubuntu Precise 32bit for Laravel 4'