Skip to content

Instantly share code, notes, and snippets.

@farshidtz
farshidtz / watchdog-network.sh
Last active July 18, 2020 09:56
A watchdog script to monitor the network connectivity (ping status) and reboot when there is no connection
# A watchdog script to monitor the ping status and reboot the device
# when there is no connection after a specified number of tries.
#!/bin/sh
echo '\nStarted watchdog script.'
address=8.8.8.8 # or a local gateway address
max=5 # number of retries before reboot
interval=120 # seconds between each retry
{
"id": "https://tools.ietf.org/rfc/rfc7807.txt",
"$schema": "http://json-schema.org/draft-06/schema#",
"description": "schema for a rfc7807",
"definitions": {
"validation": {
"type": "object",
"required": [
"type"
],
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@un1t
un1t / elastic-bulk.go
Last active October 18, 2021 01:49
golang elasticsearch bulk insert
package main
import (
"fmt"
"gopkg.in/olivere/elastic.v2"
"strconv"
)
type Tweet struct {
User string `json:"user"`
@dtjm
dtjm / join_test.go
Last active November 26, 2023 13:18
Benchmarking various ways of concatenating strings in Go
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
package main
import (
"log"
"net"
)
func main() {
var status string
conn, err := net.Dial("tcp", "127.0.0.1:80")
@ciaranarcher
ciaranarcher / example.go
Created July 27, 2014 06:53
Wrapping a ResponseWriter to capture the status code
// Create our own MyResponseWriter to wrap a standard http.ResponseWriter
// so we can store the status code.
type MyResponseWriter struct {
status int
http.ResponseWriter
}
func NewMyResponseWriter(res http.ResponseWriter) *MyResponseWriter {
// Default the status code to 200
return &MyResponseWriter{200, res}
@ancientlore
ancientlore / gist:8855122
Created February 7, 2014 00:10
go-avltree sample code
package main
import (
"os"
"fmt"
"rand"
"github.com/ancientlore/go-avltree"
)
func compareString(a interface{}, b interface{}) int {
@rxaviers
rxaviers / gist:7360908
Last active June 27, 2024 04:33
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@damianavila
damianavila / remove_output.py
Created April 3, 2013 22:05
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write