Skip to content

Instantly share code, notes, and snippets.

@lemenkov
lemenkov / avahi.go
Last active January 30, 2022 01:18
How to register service with Avahi using golang and dbus
package main
import (
"github.com/guelfey/go.dbus"
"log"
"bufio"
"os"
)
func main() {
@llaumgui
llaumgui / build_repository.sh
Last active July 26, 2016 18:38
Create an YUM reporistory from RPM with createrepo & repoview.
#!/bin/bash
#
# Create an YUM reporistory from RPM with createrepo & repoview
#
# Repository options
REPO_PATH=/home/toto/public_html/rpms.toto.com/www
REPO_LIST="toto toto-testing"
DISTRO_LIST="el fedora"
@bemasher
bemasher / rewrite.js
Created January 13, 2014 11:50
Relatively painless magnet uri generation for torrentz.eu. There's some extra scaffolding for extension related stuff but this is the main guts.
// Relatively painless magnet uri generation for torrentz.eu. Digging reveals
// that the torrent hash and id (torrentz.eu specific) are stored as hidden
// inputs for the comment system. All that's required is some Ajax and string
// parsing for the announce list and some html injection to add the link to
// the page.
// Get the torrent name, hash and id (for announce list lookup)
var name = $(".download>h2>span").first().text();
var hash = $(':input[name="hash"]').first().val()
var torrent = $(':input[name="torrent"]').first().val()
@hvoecking
hvoecking / translate.go
Last active March 28, 2024 13:52
Golang reflection: traversing arbitrary structures
// Traverses an arbitrary struct and translates all stings it encounters
//
// I haven't seen an example for reflection traversing an arbitrary struct, so
// I want to share this with you. If you encounter any bugs or want to see
// another example please comment.
//
// The MIT License (MIT)
//
// Copyright (c) 2014 Heye Vöcking
//
@bradleypeabody
bradleypeabody / gist:185b1d7ed6c0c2ab6cec
Last active November 29, 2023 22:08
golang, convert UTF-16 to UTF-8 string
package main
// http://play.golang.org/p/fVf7duRtdH
import "fmt"
import "unicode/utf16"
import "unicode/utf8"
import "bytes"
func main() {
@hyg
hyg / gist:9c4afcd91fe24316cbf0
Created June 19, 2014 09:36
open browser in golang
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@staltz
staltz / introrx.md
Last active May 17, 2024 07:59
The introduction to Reactive Programming you've been missing
@willprice
willprice / .travis.yml
Last active August 15, 2023 17:12
How to set up TravisCI for projects that push back to github
# Ruby is our language as asciidoctor is a ruby gem.
lang: ruby
before_install:
- sudo apt-get install pandoc
- gem install asciidoctor
script:
- make
after_success:
- .travis/push.sh
env:
@glamrock
glamrock / torrc_options
Created August 25, 2014 02:17
All valid torrc options
yahtzee@fagballs:~# tor --list-torrc-options
Aug 24 22:16:31.701 [notice] Tor v0.2.4.20 (git-0d50b03673670de6) running on Linux with Libevent 2.0.21-stable and OpenSSL 1.0.1f.
Aug 24 22:16:31.701 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
AccountingMax
AccountingStart
Address
AllowDotExit
AllowInvalidNodes
AllowNonRFC953Hostnames
AllowSingleHopCircuits
@stuart-warren
stuart-warren / simple-gpg-enc.go
Last active October 11, 2023 01:21
golang gpg/openpgp encryption/decryption example
package main
import (
"bytes"
"code.google.com/p/go.crypto/openpgp"
"encoding/base64"
"io/ioutil"
"log"
"os"
)