Skip to content

Instantly share code, notes, and snippets.

//
// Companion code to https://medium.com/statuscode/pipeline-patterns-in-go-a37bb3a7e61d
//
// To run:
// go get github.com/pkg/errors
// go run -race pipeline_demo.go
//
package main
@arkan
arkan / safebuffer.go
Last active May 19, 2021 21:54
Golang: Buffer is a goroutine safe bytes.Buffer
package safebuffer
import (
"bytes"
"sync"
)
// Buffer is a goroutine safe bytes.Buffer
type Buffer struct {
buffer bytes.Buffer
@Bambina-zz
Bambina-zz / IsUniqueAlphabets.java
Last active August 5, 2019 09:17
【解答】1.1 ある文字列が、すべてユニークである(重複する文字がない)かどうかを判定するアルゴリズムを実装してください。また、それを実装するのに新たなデータ構造が使えない場合、どのようにすればよいですか?
// 入力は小文字のアルファベットのみと仮定すると、
// 26種類('a'~'z')の文字の有無を4byteのビットベクトル([0,0,0,0,...])で表現できる。
// 'a' => dec:97 bin:1100001 'a'-'a':0
// 'b' => dec:98 bin:1100010 'b'-'a':1
// 'c' => dec:99 bin:1100011 'c'-'a':2
// 'd' => dec:100 bin:1100100 'd'-'a':3
// ...
public class IsUniqueAlphabets {
public static void main(String[] args) {
@YusukeHosonuma
YusukeHosonuma / string_format.rs
Last active March 15, 2025 13:18
Rust: Format string. (println!)
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Display for Point {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
@haya14busa
haya14busa / main.go
Created November 1, 2016 23:32
サンプル: Golangにおけるinterfaceをつかったテストで mock を書く技法
package main
import (
"context"
"fmt"
)
type GitHub interface {
CreateRelease(ctx context.Context, opt *Option) (string, error)
GetRelease(ctx context.Context, tag string) (string, error)
@kaneshin
kaneshin / main.go
Last active November 8, 2020 15:14
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"runtime"
"sync"
)
@josh-padnick
josh-padnick / download.sh
Last active September 12, 2024 06:36
Download a private binary release file from GitHub in bash
#!/usr/bin/env bash
#
# This is an adaptation of code I wrote to download a private binary from GitHub. Such...pain.
# Why can't GitHub just offer a standardized URL you can download a release binary from and attach
# your Github Personal Access Token as a header?
#
# Since this code is an adaptation it hasn't been directly tested, but the code it was adapted from works
# and hopefully you can get the missing piece you're after by looking here.
#
@josephspurrier
josephspurrier / sshremote.go
Last active May 27, 2021 19:54
Golang Remote Execution
package main
/*
// Example
sci := ServerConnInfo{
"127.0.0.1",
"22",
"ubuntu",
`key.pem`,
}
@iamralch
iamralch / context.go
Created November 20, 2015 13:05
An example that illustrates how to work with https://godoc.org/golang.org/x/net/context
package main
import (
"bufio"
"fmt"
"os"
"strings"
"time"
"golang.org/x/net/context"