Skip to content

Instantly share code, notes, and snippets.

View maksadbek's full-sized avatar
💭
Chilling

maksadbek

💭
Chilling
View GitHub Profile
@maksadbek
maksadbek / simple_go_daemon.go
Last active August 29, 2015 14:21
simple go http daemon
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"os"
var FleetTest = struct {
FleetName string
Trackers []string
}{
"202",
[]string{"106206", "107749", "107699"},
}
var testFleet Fleet = Fleet{
Id: "202",
Update: map[string]Pos{
@maksadbek
maksadbek / reminder.txt
Created June 22, 2015 16:32
Golang Mysql: some values will be 0, if previes null fields are not mapped to sql.Null typed variables
some field on the sql rows scan can be always equal to null or 0 or "" if it is string, due to previes fields that are not mapped to sql NULLABLE types.
vector<pair<int, int> > G[N];
int d[N];
bool visited[N];
//read G
for(int i = 1; i <= n; i++){
d[i] = INF;
@maksadbek
maksadbek / 1st.go
Created August 24, 2015 08:10
Golang recycler
package main
import (
"fmt"
"math/rand"
"runtime"
"time"
)
func makeBuffer() []byte {
@maksadbek
maksadbek / dfs.cpp
Last active August 29, 2015 14:28
Strongly connected components
int used[N];
bool cycle;
vector<int> order;
vector<int> comp[N];
vector<int> G[N], G2[N];
void dfs(int v){
used[v] = 1;
for(int i = 0; i < (int) G[v].size(); i++){
int to = G[v][i];
@maksadbek
maksadbek / ws.go
Created September 24, 2015 19:54
Websocket echo server
package main
import (
"flag"
"log"
"net/http"
"time"
"github.com/gorilla/websocket"
)
@maksadbek
maksadbek / index.mithrill.html
Created October 7, 2015 13:12
Learning mithril.js file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
@maksadbek
maksadbek / patternmatcher.go
Created November 10, 2015 13:35
Pattern matching exercise solution that I failed on job interview.
package main
import (
"strings"
)
func match(pattern, text string) bool {
patterns := strings.Split(pattern, "")
words := strings.Split(text, " ")
// if the length of patterns and words does not the same the mapping is wrong
@maksadbek
maksadbek / gist:6283393
Last active December 21, 2015 09:09
int2char'n char2int in C++
//from int to char
while(n>0){
ch[i]=(n%10)+'0';
n=n/10;
i++;
}
while(i>0){
putchar(ch[i-1]);
i--
}