Skip to content

Instantly share code, notes, and snippets.

View titanjer's full-sized avatar
🏠

Titan Lin titanjer

🏠
  • Taiwan
View GitHub Profile
@lavalamp
lavalamp / The Three Go Landmines.markdown
Last active February 28, 2025 12:54
Golang landmines

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) }
##
# Creates an alias called "git hist" that outputs a nicely formatted git log.
# Usage is just like "git log"
# Examples:
# git hist
# git hist -5
# git hist <branch_name>
# git hist <tag_name> -10
##
git config --global alias.hist "log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){{%an}}%C(reset) %C(blue)%d%C(reset)' --graph --date=short"
@voluntas
voluntas / django_gevent.rst
Last active December 23, 2015 16:29
Django + 非同期ワーカー コトハジメ

Django + 非同期ワーカー コトハジメ

更新:2013-10-23
バージョン:0.1.2
作者:@voluntas
URL:http://voluntas.github.io/

環境

@tony1223
tony1223 / sample.html
Created April 20, 2013 06:29
prototype practice sample
<html>
<head>
<title></title>
</head>
<body>
<input type="button" id="test" value="clickme" />
<div id="output" ></div>
<table id="test_table">
<tr><td>test1</td></tr>
<tr><td>test2</td></tr>
from django import http
try:
from django.conf import settings
XS_SHARING_ALLOWED_ORIGINS = settings.XS_SHARING_ALLOWED_ORIGINS
XS_SHARING_ALLOWED_METHODS = settings.XS_SHARING_ALLOWED_METHODS
XS_SHARING_ALLOWED_HEADERS = settings.XS_SHARING_ALLOWED_HEADERS
XS_SHARING_ALLOWED_CREDENTIALS = settings.XS_SHARING_ALLOWED_CREDENTIALS
except AttributeError:
XS_SHARING_ALLOWED_ORIGINS = '*'
@yomybaby
yomybaby / example.js
Created June 15, 2012 05:57 — forked from salbito/gist:1165174
Backbone.sync for Titanium HttpClient and Titanium ACS API
// http://cloud.appcelerator.com/docs/api/v1/acls/create
var Backbone = require('/lib/backbone'),
_ = require('/lib/underscore');
var ReviewModel = Backbone.Model.extend({
modelNameForACS : 'Reviews' //just add Model Name of ACS
});
var ReviewCollection = Backbone.Collection.extend({
#!/bin/sh
#
# init.d script with LSB support.
#
# Copyright (c) 2007 Javier Fernandez-Sanguino <[email protected]>
#
# This is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2,
# or (at your option) any later version.