Skip to content

Instantly share code, notes, and snippets.

@nightire
nightire / Rails 4 - Active Record Associations.md
Last active March 27, 2016 12:40
Rails 4 - Active Record Associations

Rails 4 - Active Record Associations

has_one

一对一关系:有 A 和 B,A 拥有且仅拥有一个 B

has_one

belongs_to

@noahhendrix
noahhendrix / api.rb
Created December 22, 2011 09:38
Authenticating with Grape
module Todo
class API < Grape::API
use Rack::Session::Cookie
version 'v1', :format => :json
helpers do
def current_user
return nil if env['rack.session'][:user_id].nil?
@current_user ||= User.get(env['rack.session'][:user_id])
end
@germanviscuso
germanviscuso / alljoyn_pi
Last active July 25, 2017 13:03
Compile AllJoyn on the Raspberry Pi
INDEX
-----
- BUILD IT YOURSELF
- BUILD THE AUDIO SERVICE
- BUILDING FOR ANDROID
- INSTALL WITHOUT BUILDING
BUILD IT YOURSELF
-----------------
@xream
xream / dnsmasq.conf
Created December 30, 2011 00:47
dnsmasq conf of apple services
#apple
#nslookup -vc a1.phobos.apple.com 168.95.1.1
#203.78.36.42 203.69.138.18
#jp 120.29.145.9 124.40.51.32 61.213.183.25
address=/a1.mzstatic.com/203.69.138.18
address=/a2.mzstatic.com/203.69.138.18
address=/a3.mzstatic.com/203.69.138.18
address=/a4.mzstatic.com/203.69.138.18
address=/a5.mzstatic.com/203.69.138.18
address=/a6.mzstatic.com/203.69.138.18
@tony612
tony612 / Dockerfile
Last active November 22, 2017 12:12
The right way to use Elixir+Docker in China
# git clone https://github.com/hexpm/hex.git
# cd hex
# git checkout v0.15.0
# # Add this Dockerfile in the dir
# docker build .
# # Then you can use the image as your base image to speedup your usage
FROM elixir:1.5.2
RUN HEX_MIRROR=https://hexpm.upyun.com mix local.rebar --force \
# rebar3 update should be rerun if you add a new rebar dependence
.random-color {
border-top-color: "LightCoral";
border-right-color: #a44b58;
border-bottom-color: rgb(108, 188, 134);
border-left-color: rgb(24%, 88%, 5%);
outline-top-color: hsl(88, 69%, 69%);
outline-right-color: rgba(220, 71, 132, 0.69);
outline-bottom-color: rgba(79%, 47%, 14%, 0.37);
outline-left-color: hsla(111, 31%, 38%, 0.86);
}
@pithyless
pithyless / gist:1208841
Created September 10, 2011 21:49
Install Python 2.7 (homebrew + pip + virtualenv) on Mac OS X Lion

Install Python

$ brew install readline sqlite gdbm
$ brew install python --universal --framework
$ python --version
Python 2.7

Symlinks...

@airicbear
airicbear / .bashrc
Last active January 19, 2021 17:28
ubuntu 20.04 2020-05-01
export MPD_HOST="localhost"
export MPD_PORT="6601"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import struct
from mutagen.easyid3 import EasyID3
def decode_gbk_from_unicode(s):
l, f = [], []