Skip to content

Instantly share code, notes, and snippets.

View ego008's full-sized avatar
🏠
Working from home

Ybb ego008

🏠
Working from home
View GitHub Profile
@ego008
ego008 / shorturl.go
Created June 28, 2017 09:32 — forked from eahydra/shorturl.go
make a long url to short. It just allocate a ID for a URL, then convert the id to 62-base ID. Then format new id to string with kBase62CharMap.
package shorturl
import (
"math"
)
const kMinShortUrlLength = 6
var kBase62CharMap = []rune{
'0', '1', '2', '3', '4', '5', '6',
@ego008
ego008 / _tree
Created July 12, 2017 12:13 — forked from alexedwards/_tree
.
├── books
│   ├── handlers.go
│   └── models.go
├── config
│   └── db.go
└── main.go
@ego008
ego008 / gist:759af4dcb1e67f745f82b91d9ce2ad02
Created July 30, 2017 10:39 — forked from ismasan/gist:3804361
async fetching of urls using goroutines and channels
package main
import (
"fmt"
"net/http"
"time"
)
var urls = []string{
"http://pulsoconf.co/",
package wincommands
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
@ego008
ego008 / docx2pdf.py
Created August 17, 2017 02:25 — forked from MichalZalecki/docx2pdf.py
Converting DOCX to PDF using Python
import sys
import subprocess
import re
def convert_to(folder, source, timeout=None):
args = [libreoffice_exec(), '--headless', '--convert-to', 'pdf', '--outdir', folder, source]
process = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=timeout)
filename = re.search('-> (.*?) using filter', process.stdout.decode())
@ego008
ego008 / golang_download_file_from_url.go
Created August 19, 2017 02:08
Golang download big file from url
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
@ego008
ego008 / reverseProxy.go
Created September 5, 2017 05:40 — forked from rolaveric/reverseProxy.go
Example of a reverse proxy written in Go
import (
"net/http"
"net/http/httputil"
"net/url"
"fmt"
)
func main() {
// New functionality written in Go
http.HandleFunc("/new", func(w http.ResponseWriter, r *http.Request) {
@ego008
ego008 / proxy.go
Created September 6, 2017 06:58 — forked from jcelliott/proxy.go
Reverse proxy using Go
package main
import (
"log"
"net/http"
"net/http/httputil"
"net/url"
)
func main() {
@ego008
ego008 / multipart_upload.go
Created October 18, 2017 15:42 — forked from mattetti/multipart_upload.go
Example of doing a multipart upload in Go (golang)
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
@ego008
ego008 / main.go
Created December 1, 2017 03:57 — forked from dmitshur/main.go
Server for HTTPS protocol. Redirects to canonical hosts, reverse proxies requests to internal backing servers.
// Server for HTTPS protocol. Redirects to canonical hosts, reverse proxies requests to internal backing servers.
package main
import (
"crypto/tls"
"flag"
"log"
"net/http"
"net/http/httputil"
"time"