Skip to content

Instantly share code, notes, and snippets.

@mayconbordin
mayconbordin / progress_bar.php
Created June 2, 2012 23:55
PHP CLI progress bar in 5 lines of code
<?php
function progress_bar($done, $total, $info="", $width=50) {
$perc = round(($done * 100) / $total);
$bar = round(($width * $perc) / 100);
return sprintf("%s%%[%s>%s]%s\r", $perc, str_repeat("=", $bar), str_repeat(" ", $width-$bar), $info);
}
@nestoru
nestoru / Solution for mysql Warning: Using a password on the command line interface can be insecure
Last active October 23, 2021 21:20
Solution for mysql Warning: Using a password on the command line interface can be insecure
# Let us consider the following typical mysql backup script:
mysqldump --routines --no-data -h $mysqlHost -P $mysqlPort -u $mysqlUser -p$mysqlPassword $database
# It succeeds but stderr will get:
# Warning: Using a password on the command line interface can be insecure.
# You can fix this with the below hack:
credentialsFile=/mysql-credentials.cnf
echo "[client]" > $credentialsFile
echo "user=$mysqlUser" >> $credentialsFile
echo "password=$mysqlPassword" >> $credentialsFile
@denvaar
denvaar / traversal.go
Created February 12, 2017 21:47
Depth and Breadth-first traversal in a binary tree, implemented in Golang
package main
import "fmt"
type node struct {
value string
left *node
right *node
}
@SoarLin
SoarLin / vue_firebase_main.js
Created June 2, 2018 04:24
Vue Project use firebase cloud messaging
const FCMconfig = {
apiKey: 'YOUR_API_KEY',
authDomain: 'YOUR_DOMAIN',
databaseURL: 'https://<YOUR_PROJECT_ID>.firebaseio.com',
projectId: 'YOUR_PROJECT_ID',
storageBucket: '<YOUR_PROJECT_ID>.appspot.com',
messagingSenderId: 'YOUR_SENDER_ID'
}
firebase.initializeApp(FCMconfig)
@motopig
motopig / tron_address_generate.go
Created December 5, 2019 05:57
tron address generate
package main
import (
"crypto/ecdsa"
"crypto/sha256"
"encoding/hex"
"fmt"
"log"
"github.com/mr-tron/base58"
@StevenACoffman
StevenACoffman / go-swagger-ui.md
Created May 31, 2020 03:06
golang serve Swagger-ui

From https://medium.com/@ribice/serve-swaggerui-within-your-golang-application-5486748a5ed4

SwaggerUI can be downloaded from their GitHub Repo Releases page. Once downloaded, place the contents of dist folder somewhere in your Go project. For example, swaggerui. After that, also move your openapi.json or swagger.json file to swaggerui folder (or whatever you called it), and inside index.html change url to ./swagger.json (e.g. url: "./swagger.json").

Serve using net/http

fs := http.FileServer(http.Dir("./swaggerui"))
http.Handle("/swaggerui/", http.StripPrefix("/swaggerui/", fs))

Serve using Gorilla Mux (commit)