This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ! -z "$ZSH_NAME" ]; then | |
setopt shwordsplit | |
fi | |
export GOROOT=/opt/go | |
export GOPATH=$HOME/gowork:$HOME/Projects/qchat/utility:$HOME/Projects/qchat:$HOME/Opensource/etcd:$HOME/Opensource/docker | |
PATH=$PATH:$GOROOT/bin | |
for GOP in ${GOPATH//:/ }; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (server *Server) Register(rcvr interface{}) error { | |
s := new(service) | |
s.typ = reflect.TypeOf(rcvr) | |
s.rcvr = reflect.ValueOf(rcvr) | |
sname := reflect.Indirect(s.rcvr).Type().Name() | |
if sname == "" { | |
s := "rpc.Register: no service name for type " + s.typ.String() | |
log.Print(s) | |
return errors.New(s) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Route packets with source addresses from 192.203.80/24 according to routing table inr.ruhep: | |
ip ru add from 192.203.80.0/24 table inr.ruhep prio 220 | |
#Translate packet source address 193.233.7.83 into 192.203.80.144 and route it according to table #1 (actually, it is inr.ruhep): | |
ip ru add from 193.233.7.83 nat 192.203.80.144 table 1 prio 320 | |
#Delete the unused default rule: | |
ip ru del prio 32767 | |
kuznet@amber:~ $ ip ru ls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
quitWriteSignal := make(bool chan) | |
select { | |
case quitWriteSignal <- true: | |
default: | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <tuple> | |
#include <utility> | |
template<typename Func, typename Tup, std::size_t... index> | |
decltype(auto) invoke_helper(Func&& func, Tup&& tup, std::index_sequence<index...>) | |
{ | |
return func(std::get<index>(std::forward<Tup>(tup))...); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void f() | |
{ | |
cout<<"0 args"<<endl; | |
} | |
void f(int a) | |
{ | |
cout<<"1 args"<<endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
awk -v a=$1 'NR==a {print $1}' $2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <algorithm> | |
int main() | |
{ | |
std::vector<int> v{2, 4, 2, 0, 5, 10, 7, 3, 7, 1}; | |
// insertion sort | |
for (auto i = v.begin(); i != v.end(); ++i) { | |
std::rotate(std::upper_bound(v.begin(), i, *i), i, i+1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
typedef unsigned int u32; | |
typedef unsigned long long u64; | |
//------------------------------------------------------------------------- | |
// WorkArea | |
//------------------------------------------------------------------------- |