Skip to content

Instantly share code, notes, and snippets.

View dmitshur's full-sized avatar

Dmitri Shuralyov dmitshur

View GitHub Profile
@ityonemo
ityonemo / test.md
Last active May 8, 2024 20:17
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

package main
import (
"github.com/goxjs/gl"
"github.com/goxjs/glfw"
)
func main() {
if err := glfw.Init(gl.ContextWatcher); err != nil {
panic(err)
package main
import (
"bytes"
"html/template"
"log"
"time"
)
func b1() {
@fiorix
fiorix / sse.go
Last active October 19, 2023 08:05
Go and Server Sent Events for HTTP/1.1 and HTTP/2.0
// Go and Server Sent Events for HTTP/1.1 and HTTP/2.0
//go:generate go run $GOROOT/src/crypto/tls/generate_cert.go -host localhost
package main
import (
"fmt"
"io"
"log"
"net/http"

Experimental Generation of Interpersonal Closeness

Instructions to Subjects Included With Task Slips Packet

This is a study of interpersonal closeness, and your task, which we think will be quite enjoyable, is simply to get close to your partner. We believe that the best way for you to get close to your partner is for you to share with them and for them to share with you. Of course, when we advise you about getting close to your partner, we are giving advice regarding your behavior in this demonstration only, we are not advising you about your behavior outside of this demonstration.

In order to help you get close we've arranged for the two of you to engage in a kind of sharing game. You're sharing time will be for about one hour, after which time we ask you to fill out a questionnaire concerning your experience of getting close to your partner.

You have been given three sets of slips. Each slip has a question or a task written on it. As soon as you both finish reading these instructions, you should

@jpillora
jpillora / sshd.go
Last active December 17, 2023 16:27
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
@mholt
mholt / everything.go
Last active April 14, 2020 13:53
Implements 103 of the 114 Go 1.3 standard library interfaces
package interfaces
import (
"bufio"
"crypto/elliptic"
"crypto/tls"
"database/sql/driver"
"debug/dwarf"
"encoding/xml"
"fmt"
@wancw
wancw / y-combinator.go
Last active September 19, 2023 20:22
Y combinator in Go, runable example: http://play.golang.org/p/xVHw0zoaWX
package main
import "fmt"
type (
tF func(int) int
tRF func(tF) tF
tX func(tX) tF
)
@DisposaBoy
DisposaBoy / openclipboard.py
Created January 22, 2014 08:26
a sublime text plugin example to open the file path that's in the clipboard
# this plugin creates a command `open_from_clipboard` that opens the path that's currently in the clipboard
# save this file at Packages/User/openclipboard.py
# then add the follow key binding if you like via the menu Preferences > Key Bindings - User
# { "keys": ["ctrl+shift+o"], "command": "open_from_clipboard" }
import sublime
import sublime_plugin
class OpenFromClipboardCommand(sublime_plugin.WindowCommand):
def run(self):
@kjk
kjk / show_caller_name.go
Last active December 31, 2015 19:39
Shows that we can get the caller's function name without access to source code. go build -o test show_caller_name.go; rm show_caller_name.go; ./test
package main
import (
"bytes"
"fmt"
"runtime"
)
var (
dunno = []byte("???")