Skip to content

Instantly share code, notes, and snippets.

View tsyber1an's full-sized avatar
🎯
Focusing

Tsyren O. tsyber1an

🎯
Focusing
View GitHub Profile
@trekdemo
trekdemo / windfinder.1h.rb
Created September 14, 2018 22:36
Show the 3 day forecast from Windfinder
#!/usr/bin/env ruby
# <bitbar.title>Windfinder </bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Gergő Sulymosi</bitbar.author>
# <bitbar.author.github>trekdemo</bitbar.author.github>
# <bitbar.desc>Show the 3 day forecast from Windfinder</bitbar.desc>
# <bitbar.image></bitbar.image>
# <bitbar.dependencies>ruby</bitbar.dependencies>
# <bitbar.abouturl></bitbar.abouturl>
@alexellis
alexellis / README.md
Last active July 29, 2021 18:09
Provision a Raspberry Pi SD card

You'll need

  • Raspberry Pi 3, 3+ or 2 (only)
  • A Linux PC, laptop or Raspberry with SD card reader/slot
  • A number of Raspberry Pis configured with Ethernet

You must have an SSH key, if you don't know what this is then type in ssh-keygen and follow the instructions.

Prepare to provision RPis:

@arsham
arsham / go_cpu_memory_profiling_benchmarks.sh
Last active November 20, 2023 03:42
Go cpu and memory profiling benchmarks. #golang #benchmark
go test -run=. -bench=. -benchtime=5s -count 5 -benchmem -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out ./package | tee bench.txt
go tool pprof -http :8080 cpu.out
go tool pprof -http :8081 mem.out
go tool trace trace.out
go tool pprof $FILENAME.test cpu.out
# (pprof) list <func name>
# go get -u golang.org/x/perf/cmd/benchstat
benchstat bench.txt
@madhums
madhums / Makefile
Created August 5, 2015 20:09
Makefile for golang projects
.PHONY: build doc fmt lint dev test vet godep install bench
PKG_NAME=$(shell basename `pwd`)
install:
go get -t -v ./...
build: vet \
test \
go build -v -o ./bin/$(PKG_NAME)
require 'Benchmark'
def balanced_delimiters?(text)
openers = []
matchers = {
')' => '(',
']' => '[',
'}' => '{'
}
text.chars.each do |char|
@d11wtq
d11wtq / docker-ssh-forward.bash
Created January 29, 2014 23:32
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@kendellfab
kendellfab / read_line.go
Created November 11, 2013 17:41
Golang --> Read file line by line.
func readLine(path string) {
inFile, _ := os.Open(path)
defer inFile.Close()
scanner := bufio.NewScanner(inFile)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
}
@kujohn
kujohn / portforwarding.md
Last active April 27, 2024 20:16
Port forwarding in Mavericks

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like:

tables = [] # or ActiveRecord::Base.connection.tables
collation = "utf8_unicode_ci"
char_set = "utf8"
db = "your_database_name"
# write out
puts "USE #{db};"
puts "ALTER DATABASE #{db} CHARACTER SET #{char_set} COLLATE #{collation};"
tables.each do |t|
puts "ALTER TABLE #{t} CHARACTER SET #{char_set} COLLATE #{collation};" # changes for new records
puts "ALTER TABLE #{t} CONVERT TO CHARACTER SET #{char_set} COLLATE #{collation};" # migrates old records