Skip to content

Instantly share code, notes, and snippets.

@aladine
aladine / server_start.bat
Created September 28, 2015 01:51
Start to run localhost from any folder
@echo off
TITLE Open a folder and start localhost
D:
cd "D:\Source codes"
python -m SimpleHTTPServer
::python -m SimpleHTTPServer -p 8000
@aladine
aladine / ifconfig.bat
Created September 28, 2015 01:54
Get IP config and then ping to google.com to check internet
ECHO OFF
TITLE Ifconfig
::CMD will no longer show us what command it’s executing(cleaner)
ECHO As a network admin, I m getting tired of having to type these commands in! Hopefully, this saves me some time in the long run.
:: Print some text
IPCONFIG /ALL
:: Outputs tons of network information into the command prompt
PAUSE
:: Lets the user read the important network information
PING www.google.com
@aladine
aladine / cat.bat
Created September 28, 2015 01:55
Run a program with parameter
ECHO OFF
::CMD will no longer show us what command it’s executing(cleaner)
"C:\Users\Desktop\cat" developerparams
@aladine
aladine / git_update.bat
Created September 29, 2015 10:13
git_update
@echo off
TITLE Git Update
D:
cd D:\trunk\test
git pull origin master
pause
@aladine
aladine / gist:7fc263a44975112ac4a05441117f6104
Created May 25, 2016 16:39 — forked from momer/grpc_with_reconnect.go
A pattern I created to maintain connections to an RPC server in Go. Since net/rpc does not provide any methods for automatically reconnecting to an RPC server, I needed a work-around. Additionally, rpc.Client does not export any state variables (rpc.Client.shutdown and rpc.Client.closing) nor does it export the Client's Mutex. So, we wrap the rp…
package main
import (
"myapp/webserver/app/common"
"github.com/golang/glog"
"github.com/gorilla/mux"
"encoding/json"
"strconv"
"flag"
"fmt"
@aladine
aladine / main.go
Created April 8, 2018 15:13
Golang program where time.After didn'trigger
package main
import (
"fmt"
"time"
)
func main() {
ticker := time.NewTicker(5 * time.Second)
for {
@aladine
aladine / main.go
Created August 25, 2018 08:17
Hystrix Circuit Breaker example
package main
import (
"errors"
"fmt"
"log"
"net/http"
"os"
"github.com/afex/hystrix-go/hystrix"
@aladine
aladine / command.go
Created August 25, 2018 15:36
Circuit Setting struct
// CommandConfig is used to tune circuit settings at runtime
type CommandConfig struct {
Timeout int `json:"timeout"`
MaxConcurrentRequests int `json:"max_concurrent_requests"`
RequestVolumeThreshold int `json:"request_volume_threshold"`
SleepWindow int `json:"sleep_window"`
ErrorPercentThreshold int `json:"error_percent_threshold"`
}
@aladine
aladine / command.go
Created August 25, 2018 16:16
Main errors from hystrix circuit breaker
// ErrMaxConcurrency occurs when too many of the same named command are executed at the same time.
ErrMaxConcurrency = CircuitError{Message: "max concurrency"}
// ErrCircuitOpen returns when an execution attempt "short circuits". This happens due to the circuit being measured as unhealthy.
ErrCircuitOpen = CircuitError{Message: "circuit open"}
// ErrTimeout occurs when the provided function takes too long to execute.
ErrTimeout = CircuitError{Message: "timeout"}
@aladine
aladine / org-mode-reference-in.org
Created September 23, 2018 14:22 — forked from drj42/org-mode-reference-in.org
This is a cheat sheet for Emacs org-mode... in org-mode format!