Skip to content

Instantly share code, notes, and snippets.

View ocomsoft's full-sized avatar

ocomsoft

  • Ocom Software
  • Geelong, Australia
  • 14:59 (UTC +11:00)
View GitHub Profile
@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@garystafford
garystafford / helpful-docker-commands.sh
Last active April 20, 2025 11:08
My list of helpful docker commands
###############################################################################
# Helpful Docker commands and code snippets
###############################################################################
### CONTAINERS ###
docker stop $(docker ps -a -q) #stop ALL containers
docker rm -f $(docker ps -a -q) # remove ALL containers
docker rm -f $(sudo docker ps --before="container_id_here" -q) # can also filter
# exec into container
@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)])'
@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()
@Boerworz
Boerworz / main.go
Last active December 6, 2025 10:27
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
@smcoll
smcoll / django_migration_pk_to_uuid.py
Last active December 20, 2025 09:20
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')
@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`
@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)
*/
@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"
@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