Skip to content

Instantly share code, notes, and snippets.

View huobazi's full-sized avatar
🎯
Focusing

Marble Wu huobazi

🎯
Focusing
View GitHub Profile
@huobazi
huobazi / install-node.sh
Created November 5, 2017 02:11 — forked from ttonyh/install-node.sh
Install Node
#!/bin/bash
# *** RUN AS ROOT ***
# Define help function
function help(){
echo "Node JS Install Script - Install Node JS";
echo "Usage example:";
echo "install-node (-v|--version) string [(-f|--force)] [(-p|--platform) string] [(-a|--arch) string]";
echo "Options:";
@huobazi
huobazi / installvagrant
Last active October 30, 2017 03:27 — forked from rrgrs/installvagrant
installs brew, virtualbox, and vagrant in osx
if ! type "brew" > /dev/null; then
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)";
fi
brew tap phinze/homebrew-cask && brew install brew-cask;
brew cask install virtualbox;
brew cask install vagrant;
brew cask install vagrant-manager;
@huobazi
huobazi / description.markdown
Created February 15, 2017 04:37 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

@huobazi
huobazi / README.md
Created June 29, 2016 09:43 — forked from mimosa/README.md
微信扫码登录。
  1. 判定是否在微信中打开
def wechat?
    request.user_agent =~ /MicroMessenger/i 
end
  1. 分别调用 微信网页扫码公众号授权
@huobazi
huobazi / HtmlHelperExtensions.cs
Created May 23, 2016 08:05 — forked from mariusschulz/HtmlHelperExtensions.cs
Two C# extension methods for inlining script and style bundles into the HTML response using ASP.NET MVC and the System.Web.Optimization framework.
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
public static class HtmlHelperExtensions
{
public static IHtmlString InlineScripts(this HtmlHelper htmlHelper, string bundleVirtualPath)
{
return htmlHelper.InlineBundle(bundleVirtualPath, htmlTagName: "script");
@huobazi
huobazi / eav.sql
Created April 24, 2016 07:56 — forked from vwood/eav.sql
EAV in postgres
-- Entity Attribute Value Model in Postgres
CREATE TABLE public.entity (
id serial NOT NULL,
type varchar(25) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE public.defined_attributes (
key varchar(25) NOT NULL,
-- clean up database from previous test
DROP SCHEMA public CASCADE;
CREATE SCHEMA public;
-- create EAV tables
CREATE TABLE entity (
id SERIAL PRIMARY KEY,
name TEXT,
description TEXT
);
@huobazi
huobazi / js-get-fn-name.js
Created April 20, 2016 08:31 — forked from dfkaye/js-get-fn-name.js
get a javascript function name
function getFnName(fn) {
var f = typeof fn == 'function';
var s = f && ((fn.name && ['', fn.name]) || fn.toString().match(/function ([^\(]+)/));
return (!f && 'not a function') || (s && s[1] || 'anonymous');
}
console.log(getFnName(String)); // 'String'
console.log(getFnName(function test(){})); // 'test'
console.log(getFnName(function (){})); // 'anonymous'
@huobazi
huobazi / ubuntu apt-get aliyun镜像源.md
Created April 15, 2016 09:38 — forked from nibocn/ubuntu apt-get aliyun镜像源.md
ubuntu apt-get aliyun镜像源

trusty(14.04)

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
@huobazi
huobazi / readme.txt
Created January 6, 2016 06:32 — forked from fqrouter/readme.txt
shadowsocks 公共代理的必要设置
good, 你已经有了一个自己的shadowsocks代理了,现在想要把这个代理公布出去给所有人分享。
但是没有两个小时,代理就没法使用了,为什么?因为你需要额外注意以下事项(以下步骤需要比较高的linux技能)
本文只关注于确保shadowsocks服务还“活着”,如果你希望让其跑得更快,请参考
https://github.com/clowwindy/shadowsocks/wiki/Optimizing-Shadowsocks
1、 shadowsocks的timeout设置
超时时间越长,连接被保持得也就越长,导致并发的tcp的连接数也就越多。对于公共代理,这个值应该调整得小一些。推荐60秒。
2、 检查操作系统的各种限制
对于openvz的vps,特别需要检查一下