Skip to content

Instantly share code, notes, and snippets.

@roylee0704
roylee0704 / dockergrep.sh
Created December 9, 2016 08:24
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
@redgeoff
redgeoff / index.html
Last active April 9, 2025 21:08
Image Paste Textarea
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Paste Image Example</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.4.6/bluebird.min.js"></script>
</head>
<body>
@Azlirn
Azlirn / uptimeChecker.py
Last active June 26, 2019 17:56
A simple domain uptime checker
from threading import Thread
import requests
import time
with open('domains.txt') as f:
domainList = f.readlines()
domainList = [x.strip() for x in domainList]
#TODO: Check list for .onion domains and ignore said entries
@jpillora
jpillora / xero-api.go
Created April 27, 2016 02:02
Xero API for Private applications in Go (golang)
package main
import (
"crypto/x509"
"encoding/pem"
"fmt"
"io/ioutil"
"log"
"net/http"
@fcamblor
fcamblor / DataLoader.js
Last active May 25, 2021 19:14
Resolving promise multiple times
/**
* Utility class allowing to load data from 3 levels :
* - Remote server
* - Browser's Local storage
* - In memory cache
*
* It provides a loadEventsThen(dataAvailableCallback) method which will trigger
* dataAvailableCallback once data will be retrieved at some point
* The first time it is called, in-memory cache will be empty (thus, callback will never be called on it)
*/
@joepie91
joepie91 / .md
Last active July 8, 2021 18:07
Batch-migrating Gitolite repositories to Gogs

NOTE: This will only work if you are an administrator on your Gogs instance, or if an administrator has enabled local repository importing for all users.

First, save the following as migrate.sh somewhere, and make it executable (chmod +x migrate.sh):

HOSTNAME="git.cryto.net"
BASEPATH="/home/git/old-repositories/projects/joepie91"

OWNER_ID="$1"
CSRF=`cat ./cookies.txt | grep _csrf | cut -f 7`
@smcoll
smcoll / django_migration_pk_to_uuid.py
Last active August 6, 2024 20:14
Django migration converting integer pk table to UUID pk table
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import uuid
from django.db import migrations, models
def fill_mymodel_uuid(apps, schema_editor):
db_alias = schema_editor.connection.alias
MyModel = apps.get_model('myapp', 'MyModel')
@Boerworz
Boerworz / main.go
Last active April 1, 2025 11:54
Capturing the HTTP status code from http.ResponseWriter
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
// We need to cast handleRoot to a http.HandlerFunc since wrapHandlerWithLogging
@williballenthin
williballenthin / gist:ee0335a6826ce55ece2d
Last active August 29, 2022 22:14
Methods for fetching structure fields in Go (golang)
package main
import "log"
import "time"
import "reflect"
// suggested via http://stackoverflow.com/a/8363629/87207
func trace(s string) (string, time.Time) {
log.Println("START:", s)
return s, time.Now()
@sandervm
sandervm / commandline.txt
Last active March 5, 2025 14:49
Generate Django secret key commandline
$ python -c 'import random; print "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])'