Skip to content

Instantly share code, notes, and snippets.

View technocake's full-sized avatar

Robin Garen Aaberg technocake

View GitHub Profile
@technocake
technocake / mac_adduser.sh
Created November 24, 2012 21:09
A script to add a user from cli on mac osx.
#!/bin/sh
#
# Adds a user to a mac.
#
# based on this article: http://osxdaily.com/2007/10/29/how-to-add-a-user-from-the-os-x-command-line-works-with-leopard/
#
# Usage: ./mac_adduser.sh <username> <uid> <gid>
#
username=$1
@technocake
technocake / webcam-in-browser.html
Created December 31, 2015 08:59
HTML5 webcam from getUserMedia()
<!DOCTYPE html>
<html>
<head>
<title>Webcam test</title>
<script type="text/javascript">
function loadstream(stream) {
console.log(stream);
video = document.getElementById("webcam");
video.src = window.URL.createObjectURL(stream);
@technocake
technocake / budsjett.py
Last active March 11, 2016 18:22
kompilert budsjett
#!/usr/bin/env python
#coding: utf-8
inntekter = {
'kontigent': 50.00 * 10
}
utgifter = {
'domeneavgift': 110,
@technocake
technocake / ssl-check.py
Created February 7, 2018 13:53 — forked from gdamjan/ssl-check.py
Python script to check on SSL certificates
# -*- encoding: utf-8 -*-
# requires a recent enough python with idna support in socket
# pyopenssl, cryptography and idna
from OpenSSL import SSL
from cryptography import x509
from cryptography.x509.oid import NameOID
import idna
from socket import socket
@technocake
technocake / copyignoredfiles.sh
Last active October 16, 2018 11:13
Copy all ignored files from a git repo
#!/bin/bash
# Copy all ignored files from a git repo to $FOLDER
FOLDER= "/path/to/folder"
for file in $(git ls-files --others -i --exclude-standard); do
cp --parents "$file" "$FOLDER"
done
@technocake
technocake / pyclean.sh
Last active May 9, 2025 09:45
Clear all python cache in directory
# pyclean command to clear all python cache in a directory
# source: https://stackoverflow.com/questions/28991015/python3-project-remove-pycache-folders-and-pyc-files
# in .bash_profile / .bash_rc etc put:
pyclean () {
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
}
@technocake
technocake / backupgoto.sh
Last active July 16, 2019 22:25
backup all goto projects
# add to .bash_profile / .bashrc / .zshrc
function backupgoto {
foldername=$(date +%d%m%y)
target="${HOME}/gotobackup/${foldername}"
mkdir -p "$target"
cp -r ${HOME}/.goto "$target" \
&& echo "Backuped goto to $target" \
|| echo "Failed to backup goto"
}
@technocake
technocake / encoding.py
Created July 14, 2019 19:54
python encoding info
import sys
default = sys.getdefaultencoding()
e_in = sys.stdin.encoding
e_out = sys.stdout.encoding
print('''
python system default encoding: {}
stdin: {}
stdout: {}
'''.format(default, e_in, e_out)
@technocake
technocake / goto promptline
Last active October 21, 2021 11:51
goto_prompt.sh
# add this to your bash rc file
# It will display the current goto project that is active.
# zsh: add this line:
# setopt PROMPT_SUBST
prompt_goto() {
# Check if project command exist
if [ -z "$(command -v project)" ]; then
return 0
@technocake
technocake / settings.py
Created August 12, 2019 20:17 — forked from andreagrandi/settings.py
Sending emails from Django during development without using a real SMTP server. Python comes with a very basic and integrated SMTP server. To start it just open a terminal and type: python -m smtpd -n -c DebuggingServer localhost:1025 Then configure your settings.py using the following parameters. You will see the email directly in the terminal …
if DEBUG:
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = '[email protected]'