Skip to content

Instantly share code, notes, and snippets.

View gitsrc's full-sized avatar
🦄
welcome

GITSRC gitsrc

🦄
welcome
View GitHub Profile
@kotakanbe
kotakanbe / ipcalc.go
Created September 17, 2015 02:59
get all IP address from CIDR in golang
package main
import (
"net"
"os/exec"
"github.com/k0kubun/pp"
)
func Hosts(cidr string) ([]string, error) {
@denji
denji / golang-tls.md
Last active April 29, 2024 03:39 — forked from spikebike/client.go
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@yowu
yowu / HttpProxy.go
Last active April 27, 2024 20:17
A simple HTTP proxy by Golang
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"strings"
)
@paulmach
paulmach / serve.go
Last active March 28, 2024 15:31
Simple Static File Server in Go
/*
Serve is a very simple static file server in go
Usage:
-p="8100": port to serve on
-d=".": the directory of static files to host
Navigating to http://localhost:8100 will display the index.html or directory
listing file.
*/
package main
@teknoraver
teknoraver / unixhttpc.go
Last active March 21, 2024 11:48
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@fffaraz
fffaraz / dns.c
Created May 29, 2016 05:58
DNS Query Code in C with linux sockets
//DNS Query Program on Linux
//Author : Silver Moon (m00n.silv3r@gmail.com)
//Dated : 29/4/2009
//Header Files
#include<stdio.h> //printf
#include<string.h> //strlen
#include<stdlib.h> //malloc
#include<sys/socket.h> //you know what this is for
#include<arpa/inet.h> //inet_addr , inet_ntoa , ntohs etc
@graninas
graninas / What_killed_Haskell_could_kill_Rust.md
Last active March 18, 2024 14:57
What killed Haskell, could kill Rust, too

At the beginning of 2030, I found this essay in my archives. From what I know today, I think it was very insightful at the moment of writing. And I feel it should be published because it can teach us, Rust developers, how to prevent that sad story from happening again.


What killed Haskell, could kill Rust, too

What killed Haskell, could kill Rust, too. Why would I even mention Haskell in this context? Well, Haskell and Rust are deeply related. Not because Rust is Haskell without HKTs. (Some of you know what that means, and the rest of you will wonder for a very long time). Much of the style of Rust is similar in many ways to the style of Haskell. In some sense Rust is a reincarnation of Haskell, with a little bit of C-ish like syntax, a very small amount.

Is Haskell dead?

@billryan
billryan / google_scholar
Last active February 7, 2024 10:33
unbound configurations for google scholar
# file: /etc/unbound/google_scholar
local-data: "scholar.google.cn AAAA 2607:f8b0:4005:80a::200e"
local-data: "scholar.google.com.hk AAAA 2607:f8b0:4005:80a::200e"
local-data: "scholar.google.com.sg AAAA 2607:f8b0:4005:80a::200e"
local-data: "scholar.google.com.tw AAAA 2607:f8b0:4005:80a::200e"
local-data: "scholar.google.com.uk AAAA 2607:f8b0:4005:80a::200e"
local-data: "scholar.google.com AAAA 2607:f8b0:4005:80a::200e"
local-data: "scholar.l.google.com AAAA 2607:f8b0:4005:80a::200e"
@bradfitz
bradfitz / ws.go
Created November 5, 2018 17:06
pre-Go1.12 websocket hijack+proxy
httpsServer := &http.Server{
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
hj, isHJ := w.(http.Hijacker)
if r.Header.Get("Upgrade") == "websocket" && isHJ {
c, br, err := hj.Hijack()
if err != nil {
log.Printf("websocket websocket hijack: %v", err)
http.Error(w, err.Error(), 500)
return
}
@nikhita
nikhita / install-firacode.sh
Created April 24, 2017 17:32
How to install FiraCode font on Linux
mkdir -p ~/.local/share/fonts
for type in Bold Light Medium Regular Retina; do wget -O ~/.local/share/fonts/FiraCode-$type.ttf "https://github.com/tonsky/FiraCode/blob/master/distr/ttf/FiraCode-$type.ttf?raw=true"; done
fc-cache -f