Skip to content

Instantly share code, notes, and snippets.

View ammario's full-sized avatar
🌐

Ammar Bandukwala ammario

🌐
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ammarpw on github.
  • I am ammar (https://keybase.io/ammar) on keybase.
  • I have a public key whose fingerprint is ADF9 EF5C AF59 5200 DC76 B4FF 1C0F 6A4C 777E 4FE4

To claim this, I am signing this object:

@ammario
ammario / gin_error.go
Created May 2, 2016 18:44
Gin JSON API error
func cError(c *gin.Context, err interface{}) {
switch err.(type) {
case error:
c.JSON(200, gin.H{
"error": err.(error).Error(),
})
case string:
c.JSON(200, gin.H{
"error": err.(string),
})
@ammario
ammario / keybase.md
Created May 12, 2016 20:05
Keybase Proof

Keybase proof

I hereby claim:

  • I am ammario on github.
  • I am ammar (https://keybase.io/ammar) on keybase.
  • I have a public key ASCHuUmMssaRVYYIHqKdvCGN7rrhbz5qlq3vzZJF3ZU0EAo

To claim this, I am signing this object:

@ammario
ammario / temporary.go
Last active July 4, 2016 03:56
Golang Temporary Struct
//Removed in favor of https://github.com/ammario/temp
@ammario
ammario / google_connect.go
Last active August 21, 2016 22:47
Connect to Google Cloud with logging
package main
import (
"github.com/stratexio/gclog"
"golang.org/x/net/context"
"google.golang.org/cloud"
"google.golang.org/cloud/storage"
)
@ammario
ammario / connect_mysql.go
Last active October 15, 2016 19:12
Golang connect to MySQL
package main
import (
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
mysqlConn, err := sql.Open("mysql", os.Getenv("MYSQL_USER")+":"+os.Getenv("MYSQL_PASS")+"@("+os.Getenv("MYSQL_HOST")+")/"+os.Getenv("MYSQL_DB") + "?parseTime=true")
if err != nil {
@ammario
ammario / install_adminer.sh
Last active January 12, 2017 16:58
Install Adminer w/ Apache
#!/bin/bash
yum -y install httpd php php-mysql mariadb mariadb-server wget
sed -i 's/Listen 80/Listen 8080/g' /etc/httpd/conf/httpd.conf
service httpd restart
service mariadb restart
mkdir -p /var/www/html/
wget -O /var/www/html/adminer.php https://www.adminer.org/static/download/4.2.5/adminer-4.2.5-mysql.php
@ammario
ammario / README.md
Last active December 11, 2018 19:23
gometalinter goland instructions

Use this File Watcher configuration for gometalinter errors to appear as squiggles in your IDE.

Arguments

--vendor --fast --enable-gc --tests --aggregate --disable=gotype $FileDir$ --format="{{.Path}}:{{.Line}}: {{.Message}}"

Output filters

$FILE_PATH$:$LINE$:$MESSAGE$

@ammario
ammario / mining-pool-blacklist.txt
Created February 2, 2019 01:22
Mining Pool IP Blacklist
178.63.211.58
198.50.152.135
144.217.94.65
213.32.53.176
145.239.232.114
80.218.217.199
78.24.235.244
213.32.53.176
167.99.229.57
51.38.99.97
@ammario
ammario / install_go.sh
Last active September 17, 2019 21:47
Install golang
#!/bin/bash
set -euf -o pipefail
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
rm -rf /usr/local/go || true
rm /usr/local/bin/go || true