Skip to content

Instantly share code, notes, and snippets.

View msoap's full-sized avatar
🇺🇦

Serhii Mudryk msoap

🇺🇦
  • Kyiv, Ukraine
  • 13:53 (UTC +03:00)
View GitHub Profile
#!/usr/bin/perl
#################################################
#
# Summarize all numbers
#
# cat file_with_numbers | sum-all-num.pl
#
#################################################
#!/usr/bin/perl
use strict;
use warnings;
sub aa {
my $aa = 123 if not 1;
if (defined $aa) {
@ctrlok
ctrlok / ghcrypt.sh
Last active November 2, 2016 19:54
# Simple script which decode and encode messages based on user github key
#!/bin/bash
# Simple script which decode and encode messages based on user github key.
# Usage:
# Encrypt:
# echo "My secret is" | ./ghcrypt.sh -u ctrlok
# Decrypt:
# echo "BASE64SCRET" | ./ghcrypt.sh -k ~/.ssh/id_rsa
while getopts "u:k:" opt
@maxk42
maxk42 / README.md
Last active May 19, 2018 06:11
Simple demonstration of generics-like features in Go.

POLYMORPHISM AND GENERICS IN GO

Lately, Go has been getting a lot of flack for its lack of generics and parametric polymorphism. Whereas it doesn't have a specific language feature called "generics", generic type operations are very simple to implement. Here is a simple implementation of a generic collection type in Go demonstrating how it's done. Essentially, the type interface{} acts as a placeholder for any type. By making use of the empty interface, you can pass any type to a function much like you can in dynamically-typed languages.

Edit: Thanks to https://gist.github.com/mfenniak and https://gist.github.com/dominikh for pointing out that the add() function was equivalent to go's built-in append()

@lukehefson
lukehefson / uninstall-GHfM.sh
Created November 27, 2013 13:48
Completely uninstall GitHub for Mac
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}
@davecheney
davecheney / go1.0-vs-go1.11.txt
Created October 7, 2018 11:13
test/bench/go1 benchmark results
name old time/op new time/op delta
BinaryTree17 5.44s ± 2% 3.27s ± 2% -39.90% (p=0.000 n=20+19)
Fannkuch11 4.95s ± 2% 2.68s ± 2% -45.87% (p=0.000 n=20+20)
FmtFprintfEmpty 142ns ± 2% 49ns ± 3% -65.39% (p=0.000 n=20+18)
FmtFprintfFloat 765ns ± 2% 260ns ± 2% -66.02% (p=0.000 n=20+20)
FmtFprintfInt 341ns ± 2% 95ns ± 2% -72.08% (p=0.000 n=19+20)
FmtFprintfIntInt 554ns ± 2% 150ns ± 1% -72.95% (p=0.000 n=20+19)
FmtFprintfPrefixedInt 497ns ± 3% 178ns ± 3% -64.12% (p=0.000 n=20+20)
FmtFprintfString 466ns ± 2% 86ns ± 3% -81.54% (p=0.000 n=20+20)
FmtManyArgs 2.23µs ± 2% 0.59µs ± 1% -73.46% (p=0.000 n=20+17)
@grahamking
grahamking / slicemap_test.go
Created June 30, 2015 04:11
Benchmark comparing map access vs slice search
package main
import (
"math/rand"
"testing"
"time"
)
const (
numItems = 100 // change this to see how number of items affects speed
@region23
region23 / golang_books_sites.md
Last active July 18, 2022 08:58
Полезные ресурсы для изучающих Go

На русском языке

Русскоязычные сайты и сообщества

English resources

@kavu
kavu / example.go
Created September 28, 2013 10:01
Minimal Golang + Cocoa application using CGO. Build with `CC=clang go build`
package main
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Cocoa
#import <Cocoa/Cocoa.h>
int
StartApp(void) {
[NSAutoreleasePool new];
@rkibria
rkibria / gospinningcube.go
Last active May 3, 2023 09:40
Generate a .gif showing a spinning 3d wireframe cube with hidden lines in Golang
package main
import (
"fmt"
"image"
"image/color"
"image/gif"
"math"
"os"
)