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 / 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())
package wincommands
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
@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/",
@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 / 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',
package main
import (
"bufio"
"bytes"
"compress/flate"
"compress/gzip"
"crypto/md5"
"encoding/hex"
package main
import (
"fmt"
"math/rand"
"net/http"
"goji.io"
"goji.io/pat"
"github.com/Sirupsen/logrus"
@ego008
ego008 / sina.go
Created April 12, 2017 06:17 — forked from border/sina.go
goauth2 for sina weibo
// Copyright 2012 Jiang Bian ([email protected]). All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Email: [email protected]
// Blog: http://wifihack.net/
// Sina WeiBo oauth2 Login, Base on goauth2 lib
package main
@ego008
ego008 / iptables_rules.sh
Created April 10, 2017 02:41 — forked from virtualstaticvoid/iptables_rules.sh
25 Most Frequently Used Linux IPTables Rules Examples
# Modify this file accordingly for your specific requirement.
# http://www.thegeekstuff.com
# 1. Delete all existing rules
iptables -F
# 2. Set default chain policies
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
package comp_test
import (
"bytes"
"compress/flate"
"github.com/golang/snappy"
"io"
"sync"
"testing"
)