Skip to content

Instantly share code, notes, and snippets.

View automaticalldramatic's full-sized avatar
🦊
this is a useless feature

riz automaticalldramatic

🦊
this is a useless feature
View GitHub Profile
@automaticalldramatic
automaticalldramatic / golang-nuts.go
Last active September 3, 2019 11:39 — forked from ryanfitz/golang-nuts.go
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@automaticalldramatic
automaticalldramatic / list-struct.go
Last active August 21, 2019 22:55
List out all the values in a struct
// testing output
reflectedStruct := reflect.ValueOf(event)
// in case you want to list all values stored at the location of this pointer to a struct
if reflectedStruct.Kind() == reflect.Ptr {
reflectedStruct = reflectedStruct.Elem()
}
@automaticalldramatic
automaticalldramatic / channel_demo.go
Last active August 18, 2019 01:44 — forked from JensRantil/channel_demo.go
Simplification of sample code at https://blog.gopheracademy.com/advent-2015/automi-stream-processing-over-go-channels/ Best practise is 1) to inject channels and 2) avoid concurrency in APIs.
func ingest(out <-chan []string) {
out <- []string{"aaaa", "bbb"}
out <- []string{"cccccc", "dddddd"}
out <- []string{"e", "fffff", "g"}
close(out)
}
func process(in <-chan []string, out <-chan int) {
for data := range in {
for _, word := range data {
@automaticalldramatic
automaticalldramatic / k8s-cronjob-trigger-manually.md
Created August 8, 2019 08:06
How to trigger a Kubernetes cronjob manually
kubectl create job --from=cronjob/<name of cronjob> <name of job>
@automaticalldramatic
automaticalldramatic / 20140316-205912.go
Created July 19, 2019 08:54 — forked from ryochack/20140316-205912.go
golang reflection: interface of array
package main
import (
"fmt"
"reflect"
)
func dump_interface_array(args interface{}) {
val := reflect.ValueOf(args)
fmt.Println(val.Kind())
@automaticalldramatic
automaticalldramatic / dump.go
Created July 19, 2019 08:54 — forked from ahmdrz/dump.go
Golang Reflection Example of an array.
package main
import (
"fmt"
"reflect"
)
type Test struct {
Name string
}
@automaticalldramatic
automaticalldramatic / class_decorator.ts
Created April 8, 2019 07:08 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
@automaticalldramatic
automaticalldramatic / create-self-signed-crt.sh
Created November 26, 2018 22:44
Generating self signed certificates
!/bin/bash
# Inspired from: https://github.com/grpc/grpc-java/tree/master/examples#generating-self-signed-certificates-for-use-with-grpc
# Output files
# ca.key: Certificate Authority private key file (this shouldn't be shared in real-life)
# ca.crt: Certificate Authority trust certificate (this should be shared with users in real-life)
# server.key: Server private key, password protected (this shouldn't be shared)
# server.csr: Server certificate signing request (this should be shared with the CA owner)
# server.crt: Server certificate signed by the CA (this would be sent back by the CA owner) - keep on server
# server.pem: Conversion of server.key into a format gRPC likes (this shouldn't be shared)
@automaticalldramatic
automaticalldramatic / Exercises.md
Last active April 9, 2018 10:04
All those interviews, gave me a good list of interview questions that people generally ask.

Front end coding challenge

Building a simple Web-Application for Analyzing Web-Sites

The objective is to build a web-application that does some analysis of a web-page/URL.

  • The application should show a form with a text-field thus the user can type in the URL of the webpage being analyzed.
  • Additionally to form should contain a button for sending the input to the server as well as to trigger the server-side analysis process.
  • After processing the results should be shown to the user in terms of a simple table below to the form. The result comprises the following information:
@automaticalldramatic
automaticalldramatic / post-update
Created November 10, 2016 11:37 — forked from six0h/post-update
Git Post-Update hook that checks for changes to composer.lock, and fires a composer install if required.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""A post-update Git hook to execute `composer install` when composer.json changes
:Author: Cody Halovich
:Company: HootSuite Media Inc.
"""
import subprocess