Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

shemul shemul

🏠
Working from home
View GitHub Profile
@shemul
shemul / go_generic.go
Created Sep 25, 2020
golang generic example
View go_generic.go
package main
import "fmt"
func reverse(arr []interface{}) interface{} {
var i = 0
var j = len(arr) - 1
for i < j {
tmp := arr[i]
View mips.go
package main
import (
"fmt"
)
func main() {
fmt.Println("hello from the router")
}
@shemul
shemul / CArea.h
Created Sep 7, 2020
simple c program with external header file
View CArea.h
struct CArea
{
int x;
int y;
} CArea;
double area(struct CArea area_samp)
{
return 0.5 * area_samp.x * area_samp.y;
}
@shemul
shemul / gcp_gke.tf
Created Aug 8, 2020
Google Cloud Platform - kubernetes engine using terraform
View gcp_gke.tf
module "gke" {
source = "terraform-google-modules/kubernetes-engine/google"
project_id = "<PROJECT ID>"
name = "gke-test-1"
region = "us-central1"
zones = ["us-central1-a", "us-central1-b", "us-central1-f"]
network = "vpc-01"
subnetwork = "us-central1-01"
ip_range_pods = "us-central1-01-gke-01-pods"
ip_range_services = "us-central1-01-gke-01-services"
View mutex.go
package main
import (
"fmt"
"sync"
)
var (
mutex = sync.Mutex{}
balance int
@shemul
shemul / .gitlab-ci.yml
Created Jul 12, 2020
gitlab-ci docker in docker host alias
View .gitlab-ci.yml
image: shemul/gitlab-ci
variables:
DOCKER_TLS_CERTDIR: ""
stages:
- test
services:
- name: docker:dind
alias: dlocal
test:
stage: test
@shemul
shemul / Dockerfile
Created Jul 9, 2020
simple docker for gitlab CI. includes ssh, git, docker, docker-compose and go
View Dockerfile
FROM ubuntu:18.04
MAINTAINER Kief H. Shemul <theshemul@gmail.com>
# Update and upgrade repo
RUN apt-get update -y -q && apt-get upgrade -y -q
# Install tools we might need
RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -q curl build-essential ca-certificates git docker.io
RUN curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
RUN chmod +x /usr/local/bin/docker-compose
@shemul
shemul / tasks.go
Created Jun 13, 2020
go-machinery-task.go
View tasks.go
package tasks
import (
"encoding/base64"
"encoding/json"
"log"
"net/smtp"
)
type Payload struct {
View go-machinery-worker.go
package worker
import (
"github.com/RichardKnop/machinery/v1"
)
func StartWorker(taskserver *machinery.Server) error {
worker := taskserver.NewWorker("machinery_worker", 10)
if err := worker.Launch(); err != nil {
View go-machinery-medium-5.go
package server
import (
base64 "encoding/base64"
"encoding/json"
"github.com/RichardKnop/machinery/v1"
"github.com/RichardKnop/machinery/v1/tasks"
"github.com/gofiber/fiber"
"github.com/shemul/go-machinery/utils"
task "github.com/shemul/go-machinery/tasks"