Skip to content

Instantly share code, notes, and snippets.

View shemul's full-sized avatar
🏠
Working from home

Kief H. Shemul shemul

🏠
Working from home
  • TomTom, Delivery Hero
  • Amsterdam, Netherlands
View GitHub Profile
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"
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 {
func Add(args ...int64) (int64, error) {
sum := int64(0)
for _, arg := range args {
sum += arg
}
time.Sleep(time.Second * 5)
return sum, nil
}
package main
import (
"os"
"github.com/RichardKnop/machinery/v1"
"github.com/shemul/go-machinery/server"
"github.com/shemul/go-machinery/utils"
"github.com/shemul/go-machinery/worker"
"github.com/urfave/cli"
├── go.mod
├── go.sum
├── main.go
├── server
│   └── server.go
├── tasks
│   └── tasks.go
├── utils
│   └── utils.go
└── worker
@shemul
shemul / gist:638d0ee92aa09d105a32218a7a31033b
Last active April 27, 2019 18:49 — forked from 7rin0/gist:ea890d2d4bf25a890b86aff01290e7d0
Docker exec root or default user
# Root.
$ docker exec -u 0 -it {container_id/image_name} bash
or
# Default container's user.
$ docker exec -it {container_id/image_name} bash
@shemul
shemul / gist:decc29cebcd994b5aac07d1db26bd293
Created November 20, 2018 20:46
Prometheus , node_exporter , grafana docker
# A scrape configuration scraping a Node Exporter and the Prometheus server
# itself.
scrape_configs:
# Scrape Prometheus itself every 5 seconds.
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['localhost:9090']
<?
// script to update local version of Google analytics script
// Remote file to download
$remoteFile = 'https://www.google-analytics.com/analytics.js';
$localfile = '/home/refinedseo/domain_name_with_tld/files/local-analytics.js';
//$localfile = '/home/refinedseo/public_html/domain_name_with_tld/wp-content/analytics.js';
//For Cpanel it will be /home/USERNAME/public_html/local-ga.js
// Connection time out
@shemul
shemul / infix_to_postfix.cpp
Last active February 23, 2017 19:32
Infix to Postfix
/*
author : Shemul Hossain
Infix to postfix conversion in C++
Input Postfix expression must be in a desired format.
Operands and operator, both must be single character.
Only '+' , '-' , '*', '/' and '$' (for exponentiation) operators are expected.
*/
#include<iostream>
#include<stack>
#include<string>
@shemul
shemul / cgpa_predictor.matlab
Created September 11, 2016 11:00
cgpa predictor analytics using matlab
function [trainedClassifier, validationAccuracy] = trainClassifier(trainingData)
% trainClassifier(trainingData)
% returns a trained classifier and its accuracy.
% This code recreates the classification model trained in
% Classification Learner app.
%
% Input:
% trainingData: the training data of same data type as imported
% in the app (table or matrix).
%