Skip to content

Instantly share code, notes, and snippets.

@mangalaman93
mangalaman93 / circular_printer.cpp
Created August 25, 2017 23:30
Threads printing string in circular fashion
#include <condition_variable>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <mutex>
#include <thread>
using namespace std;
mutex mut;
condition_variable* cond;
#include <iostream>
#include <cassert>
#include <vector>
using namespace std;
typedef struct qsnap {
int first;
int last;
qsnap(int f, int l) : first(f), last(l) {}
} qsnap;
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <condition_variable>
#include <mutex>
#include <thread>
#include <arpa/inet.h>
#include <sys/socket.h>
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"log"
"sort"
)
# Install docker
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt -y install docker-ce
sudo usermod -aG docker $USER
# logout and login now
@mangalaman93
mangalaman93 / gorm_example.go
Created April 25, 2020 10:59
Use gorm with schema in postgres database
package main
import (
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
type User struct {
ID int
Username string