Skip to content

Instantly share code, notes, and snippets.

#include "pch.h"
#include <iostream>
#include <stdio.h>
#include <Windows.h>
#include <ctime>
#include <cstdlib>
using namespace std;
//Почему ты назвал структуру Branch ??
//Может ты прекратишь копипастить из интеренета и начнешь сам писать ??
@yvasiyarov
yvasiyarov / gist:7dce6a865cb57d8001f7
Created October 26, 2014 10:55
Load symbols from ELF
f, err := elf.Open(filename)
if err != nil {
return err
}
defer f.Close()
symbols, err := f.Symbols()
if err != nil {
return err
}
package main
import (
"github.com/gocraft/web"
"net/http"
)
type Context struct {
HelloCount int
}
@yvasiyarov
yvasiyarov / gist:7e33684f10df8ed8105d
Created May 11, 2014 08:57
Hello world - martini
package main
import "github.com/go-martini/martini"
func main() {
m := martini.Classic()
m.Get("/", func() string {
return "Hello world!"
})
m.Run()
@yvasiyarov
yvasiyarov / gist:8ba8dde41807b4b72cd9
Created May 11, 2014 08:51
Hello world - plain net/http
package main
import (
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello world"))
}
@yvasiyarov
yvasiyarov / gist:9911956
Created April 1, 2014 11:09
rows.Scan() optimal usage
//Prepare buffers for reading: one time before read first chunk
treader.rawBuffer = make([]sql.RawBytes, len(treader.columns))
// rows.Scan wants '[]interface{}' as an argument, so we must copy the
// references into such a slice
// See http://code.google.com/p/go-wiki/wiki/InterfaceSlice for details
treader.scanCallArgs = make([]interface{}, len(treader.rawBuffer))
for i := range treader.rawBuffer {
treader.scanCallArgs[i] = &treader.rawBuffer[i]
}
@yvasiyarov
yvasiyarov / gist:9756346
Created March 25, 2014 06:45
Number of tcp ports in each state
netstat -tan | grep ':63790 ' | awk '{print $6}' | sort | uniq -c
@yvasiyarov
yvasiyarov / gist:9407394
Created March 7, 2014 08:09
R merge csv files
boborders = read.csv("in_data/boborders.csv", TRUE, ",")
gatransactions = read.csv("in_data/Transactions.csv", TRUE, ",")
orderswithgroup <- merge(boborders, gatransactions, by.x = "order_nr", by.y = "Transaction")
write.csv(orderswithgroup, file="out_data/orderswithgroup.csv")
@yvasiyarov
yvasiyarov / gist:9321759
Created March 3, 2014 09:57
Run docker daemon in debug mode
sudo docker -d -D
@yvasiyarov
yvasiyarov / delete all Docker containers
Created February 26, 2014 07:47
delete all Docker containers
for cont in $(sudo docker ps -a | grep "Exit" | cut -d " " -f 1); do sudo docker rm $cont; done