Skip to content

Instantly share code, notes, and snippets.

View v9n's full-sized avatar
🛫
forward email at mailwip.com

Vinh v9n

🛫
forward email at mailwip.com
View GitHub Profile

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) }
@v9n
v9n / PhpJava.java
Created September 1, 2016 09:45 — forked from avafloww/PhpJava.java
This snippet of code is syntactically valid in both PHP and Java, and produces the same output in both.
/*<?php
//*/public class PhpJava { public static void main(String[] args) { System.out.printf("/*%s",
//\u000A\u002F\u002A
class PhpJava {
function main() {
echo(//\u000A\u002A\u002F
"Hello World!");
}}
//\u000A\u002F\u002A
PhpJava::main();
@v9n
v9n / es_simple_autocomplete_example_config.sh
Created August 12, 2016 06:31 — forked from justinvw/es_simple_autocomplete_example_config.sh
Simple ElasticSearch autocomplete example configuration. The 'autocomplete' functionality is accomplished by lowercasing, character folding and n-gram tokenization of a specific indexed field (in this case "city").
# Delete the possibly existing autocomplete test index
curl -X DELETE localhost:9200/autocomplete_test
# Put the config of the autocomplete index
curl -X PUT localhost:9200/autocomplete_test -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
@v9n
v9n / .gitignore
Created July 18, 2016 23:12 — forked from aussielunix/.gitignore
jenkins configs to github
*
!/.gitignore
!/*.xml
!/nextBuildNumber
!/jobs
!/jobs/*
!/jobs/*/*.xml
/jobs/*/disk-usage.xml
/jobs/*/builds
@v9n
v9n / keybase.md
Created July 7, 2016 04:52
keybase.md

Keybase proof

I hereby claim:

  • I am kureikain on github.
  • I am vinh (https://keybase.io/vinh) on keybase.
  • I have a public key ASDSGMACn7TYwcFQB_ep9zyCAFqkXx9c3mXkjZZlYcynmAo

To claim this, I am signing this object:

- Generate YAML file to specify SSH host to get JSON and docker image
ow init
Once the ow.yml file is created you can also customize content yourself if you wanted.
---
SSH:
User: vinh
Host: 10.1.3.36
@v9n
v9n / mongodb_ssl_with_letsencrypt.md
Created June 18, 2016 01:24 — forked from leommoore/mongodb_ssl_with_letsencrypt.md
MongoDB 3.2.x SSL with Letsencrypt

#MongoDB 3.2.x SSL with Letsencrypt Letsencrypt is an initative which aims to increase the use of encryption for websites. It basically allows people to apply for free certificates provided that they prove the they control the requested domain. We will look at the what is needed to secure your MongoDB installation. For more details on setting up a MongoDB server see MongoDB 3.2.x.

##Set the hostname We sould to set the hostname to match the name of the certificate we are going to optain.

sudo hostname mongo0.example.com

Then update the hostname file to set the server name permanently.

text: This text will be used if nothing else is specified.
analyzer:
myAnalyzer:
type: custom
tokenizer: whitespace
filter:
- lowercase
- reverse
@v9n
v9n / 20130416-todo.md
Created May 10, 2016 07:08 — forked from mrflip/20130416-todo.md
Elasticsearch Tuning Plan

Next Steps

  • Measure time spend on index, flush, refresh, merge, query, etc. (TD - done)
  • Take hot threads snapshots under read+write, read-only, write-only (TD - done)
  • Adjust refresh time to 10s (from 1s) and see how load changes (TD)
  • Measure time of a rolling restart doing disable_flush and disable_recovery (TD)
  • Specify routing on query -- make it choose same node for each shard each time (MD)
  • GC new generation size (TD)
  • Warmers
  • measure before/after of client query time with and without warmers (MD)
@v9n
v9n / setup.js
Last active May 3, 2016 07:23 — forked from nishitaniyuki/setup.js
import r from 'rethinkdb';
import config from '../config';
const createDatabase = (conn, name) =>
r.dbList().contains(name)
.do(containsDb =>
r.branch(
containsDb,
{ created: 0 },
r.dbCreate(name)