Skip to content

Instantly share code, notes, and snippets.

View robbinhan's full-sized avatar
🏠
Working from home

robbin han robbinhan

🏠
Working from home
View GitHub Profile
@milancermak
milancermak / gist:3451509
Created August 24, 2012 14:47
Example of validating a recurring payment from Google Play using the Web server application OAuth 2.0 flow
import datetime
import httplib2
# to see in detail what's going on, uncomment
# httplib2.debuglevel = 4
from apiclient.discovery import build
from oauth2client.client import OAuth2Credentials, OAuth2WebServerFlow
if __name__ == "__main__":
@markbates
markbates / gist:4240848
Created December 8, 2012 16:06
Getting Started with Rack

If you're writing web applications with Ruby there comes a time when you might need something a lot simpler, or even faster, than Ruby on Rails or the Sinatra micro-framework. Enter Rack.

Rack describes itself as follows:

Rack provides a minimal interface between webservers supporting Ruby and Ruby frameworks.

Before Rack came along Ruby web frameworks all implemented their own interfaces, which made it incredibly difficult to write web servers for them, or to share code between two different frameworks. Now almost all Ruby web frameworks implement Rack, including Rails and Sinatra, meaning that these applications can now behave in a similar fashion to one another.

At it's core Rack provides a great set of tools to allow you to build the most simple web application or interface you can. Rack applications can be written in a single line of code. But we're getting ahead of ourselves a bit.

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active June 9, 2025 07:27
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@happypeter
happypeter / get_linode_ready_for_rails.sh
Last active June 16, 2020 07:42
everything needed to install a rails project on linode ubuntu1204, happycasts as an example
#################################
#
# 本清单基于 ubuntu 12.04,
#
# 只是一个清单,不是一个可以安全执行的脚本
#
#################################
# create a linode,login as root, and create a common user for all the tasks
ssh root@the_ip_of_this_linode
@nightire
nightire / Changes in Rails 4_1.md
Last active April 21, 2025 07:25
拥抱 Rails 4 —— 详述 Rails 4 的新变化

Routes

小心地使用 Match(Rails 3 已实现)

Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:

注:(r3 代表 Rails 3,r4 代表 Rails 4)

# routes.rb
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 22, 2025 08:10
A badass list of frontend development resources I collected over time.
@hgfischer
hgfischer / benchmark+go+nginx.md
Last active January 6, 2025 09:05
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
  • TUN和TAP是virutal-network kernel devices.
  • TUN(network TUNnel) 模拟layer 3(network layer)设备, IP packets, 用于routing.
  • TAP(network tap) 模拟layer 2(link layer)设备, Ethernet frames, 用于创建 network bridge.
  • tun/tap驱动程序是Linux平台虚拟网卡驱动程序, 驱动加载后会建立网络接口tun0, 与其他网卡驱动不同的是, tun驱动并不会把到达的数据包发送出去, 而是会暂时存储于队列之中, 用户态进程可以通过read, write读写网络数据包, 实质上此驱动是一种把网络数据包直接定向至用户态进程的一种方式. 用户态进程充当网络的角色, 通过read接受网卡数据包, write发送数据包给网卡.

tun/tap驱动程序实现了虚拟网卡的功能, tun表示虚拟的是点对点设备, tap表示虚拟的是以太网设备, 这两种设备针对网络包实施不同的封装.

经过操作系统通过TUN/TAP device发出去的包, 被deliver到一个用户空间程序, 这个用户空间程序把他自己附属于到这个device上. 一个用户空间程序也可以发送包给一个TUN/TAP device. 在这种情况, TUN/TAP device deliver(或inject)这些包到操作系统的network stack, 因此, 仿真他们的接收来自一个外部源.

利用tun/tap驱动, 可以将tcp/ip协议栈处理好的网络分包传给任何一个使用tun/tap驱动的进程, 由进程重新处理后再发到物理链路中.