Skip to content

Instantly share code, notes, and snippets.

View niksteff's full-sized avatar
⌨️
Just hacking away ...

Nik niksteff

⌨️
Just hacking away ...
View GitHub Profile

Creating a Happy Git Environment on OS X (or other unix like systems).

(soon for windows, too.)

Step 1: Install Git

Configure things:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

git config --global alias.co checkout

@niksteff
niksteff / BinTree.cs
Created July 6, 2014 10:48
SimpleBINTree
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BinTree
{
public class Node
{
# Description: Sets up a windows developer machine with all needed application to start Microsoft developing right away
#
# Edited for private and company use by:
# Editor 1: Dominik Steffen <[email protected]>
# Last Updated: 2017-09-30
#
# Original Author: Jess Frazelle <[email protected]>, special thanks to Jess!
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
import sys
import math
# Test primality for 2 to sqrt(n) and check for rest
def testPrimality(n):
if(n == 1):
return;
m = 2
while m < math.sqrt(n):
if(n == 1):
# Description: Sets up a windows developer machine with all needed application to start Microsoft developing right away
#
# Edited for private and company use by:
# Editor 1: Dominik Steffen <[email protected]>
# Last Updated: 2017-09-30
#
# Original Author: Jess Frazelle <[email protected]>, special thanks to Jess!
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
@niksteff
niksteff / buffer_test.go
Last active April 4, 2023 14:37
Just a basic golang flusher implementation using bytes buffer
package buffer_test
import (
"bytes"
"log"
"sync"
"testing"
"time"
)
@niksteff
niksteff / main.go
Created September 29, 2023 11:32
Go semaphore worker pattern
// this is a simple example of a semaphore in go.
//
// it replaces the typical waitgroup pattern. The benefit of a semaphore is that
// no workers will be left abandoned and no unneeded workers are started in
// contrast to a typical waitgroup based worker pool pattern. We also can only
// start a limited amount of workers at once. In a waitgroup we coul start more
// workers than we have tasks, which is not always optimal.
package main
@niksteff
niksteff / example.go
Created November 15, 2023 12:25
Example http handler with api client dep
type APIClient struct {
baseUrl url.URL
}
type Something struct {
Id string // the response data
}
// NewAPIClient is a constructor and instantiating our api
@niksteff
niksteff / wordByteReader.go
Created November 30, 2023 14:05
This is some go example code of two readers reading words/bytes from input data before passing a limited size buffer on to a server.
func GetExampleData() []byte {
return []byte(`"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."`)
}
var ErrWordTooLong = errors.New("word too long")
var ErrBufferEmpty = errors.New("buffer empty")
var ErrEndOfWord = errors.New("end of word")
func TestWordBuffer(t *testing.T) {
b := bytes.NewBuffer(GetExampleData())
@niksteff
niksteff / resty_test.go
Last active December 8, 2023 10:29
rest v2.10.0 lab
package resty_test
import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"net/http"
"net/http/httptest"