Skip to content

Instantly share code, notes, and snippets.

View cimarron-pistoncloud's full-sized avatar

Cimarron Taylor cimarron-pistoncloud

View GitHub Profile
#!/usr/bin/env python
'''
Mocking Httpclient and AsyncHttpclient in Tornado Server
'''
import unittest
import urllib
import tornado.gen
import tornado.ioloop
import tornado.web
#!/usr/bin/env python
"""
How to use it:
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID` , The Tornado Web Server Will shutdown after process all the request.
2. When you run it behind Nginx, it can graceful reboot your production server.
3. Nice Print in http://weibo.com/1682780325/zgkb7g8k7
"""
defmodule Tcprpc.Server do
use GenServer.Behaviour
defrecord State, port: nil, lsock: nil, request_count: 0
def start_link(port) do
:gen_server.start_link({ :local, :tcprcp }, __MODULE__, port, [])
end
def start_link() do
@cimarron-pistoncloud
cimarron-pistoncloud / README.md
Created April 10, 2016 16:33 — forked from dergachev/README.md
Vagrant tutorial

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

There are three easy to make mistakes in go. I present them here in the way they are often found in the wild, not in the way that is easiest to understand.

All three of these mistakes have been made in Kubernetes code, getting past code review at least once each that I know of.

  1. Loop variables are scoped outside the loop.

What do these lines do? Make predictions and then scroll down.

func print(pi *int) { fmt.Println(*pi) }
@cimarron-pistoncloud
cimarron-pistoncloud / example.md
Created October 25, 2016 19:09 — forked from ericclemmons/example.md
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 <summary>Summary Goes Here</summary>
@cimarron-pistoncloud
cimarron-pistoncloud / kubernetes_on_macOS.md
Created February 3, 2017 21:37 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

@cimarron-pistoncloud
cimarron-pistoncloud / main.go
Created March 19, 2017 19:31 — forked from nmerouze/main.go
JSON-API with Go and MongoDB: Final Part
package main
import (
"encoding/json"
"log"
"net/http"
"reflect"
"time"
"github.com/gorilla/context"
@cimarron-pistoncloud
cimarron-pistoncloud / roles_invesitgation.md
Created March 28, 2017 19:44 — forked from facultymatt/roles_invesitgation.md
Roles and permissions system for Nodejs
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "JSON API Schema",
"description": "This is a schema for responses in the JSON API format. For more, see http://jsonapi.org",
"x-oneOf": [
{
"$ref": "#/definitions/success"
},
{
"$ref": "#/definitions/failure"