Skip to content

Instantly share code, notes, and snippets.

View Strangemother's full-sized avatar

Jay Strangemother

View GitHub Profile
@Strangemother
Strangemother / gist:2300999
Created April 4, 2012 13:16
Nicely implemented log() for python scripts
# optional dependancies:
# termcolor
# log("content", color='red')
import sys
from termcolor import colored
def log(*args, **kargs):
colors = (
(bool, 'cyan'),
Virtualenv allows you to sandbox a python app. It’s easy on ubuntu.
# install virtualenv app
Sudo apt-get install virtualenv
# make a new env to use. ‘env’ is the usual folder name I use. Brian uses somat different (“environ”?)
virtualenv env
# Use the env
source env/bin/activate
@Strangemother
Strangemother / AssetLoader.js
Last active December 30, 2017 13:53
A JS Live asset loader. Similar to a standard require() or importScript() - the Assets.load([]) allows unified live js downloads
let _assetLoader;
class Assets {
static loader(){
if(_assetLoader == undefined) {
_assetLoader = assetLoader(this.document())
}
@Strangemother
Strangemother / css-border-transitions.markdown
Created December 26, 2018 20:42
CSS Border transitions

CSS Border transitions

UPDATE:

Here are some useful mixins to help you create & customize your own buttons:

  1. Draw
  2. Draw meet
@Strangemother
Strangemother / django_example_view.py
Created April 21, 2019 16:30
An example of HTTP Authorisation with Django 2+. When a user accesses GET or POST, they must authenticate using the standard username/password browser prompt. This example is not DB bound
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse
from django.views.generic import TemplateView
import base64
class ReceiptView(TemplateView):
""""""
from Crypto.Cipher import AES
from Crypto.Random import get_random_bytes
def on_str():
key = get_random_bytes(32) # Use a stored / generated key
data_to_encrypt = 'This is plain text!' # This is your data
print(key)
print(data_to_encrypt)
# === Encrypt ===
reobj = re.compile(r"\b(((?#protocol)https?|ftp):?//|go/|(?#www)www[.]+)((?#domain)[-A-Z0-9.]+)((?#file)/[-A-Z0-9+&@#/%=~_|!:,.;]*)?((?#parameters)\?[A-Z0-9+&@#/%=~_|!:,.;]*)?", re.IGNORECASE)
for match in reobj.finditer(subject):
# match start: match.start()
# match end (exclusive): match.end()
# matched text: match.group()
@Strangemother
Strangemother / books.md
Created December 16, 2019 19:17
book list
  • Code Craft: The Practice Of Writing Excellent Code
  • Gray Hat Python: Python Programming For Hackers And Reverse Engineers
  • Python For Kids: A Playful Introduction To Programming
  • Black Hat Python: Python Programming For Hackers And Pentesters
  • Automate The Boring Stuff With Python: Practical Programming For Total Beginners
  • Python Playground: Geeky Projects For The Curious Programmer
  • Teach Your Kids To Code: A Parent-friendly Guide To Python Programming
  • Doing Math With Python: Use Programming To Explore Algebra, Statistics, Calculus, And More!
  • Invent Your Own Computer Games With Python, 4e
  • Cracking Codes With Python: An Introduction To Building And Breaking Ciphers
"""Create complex functional or class-based decorators without effort.
+ Capture the class of a method: `owner_class`
+ Accept arguments at create, decorate or execution
+ functional based drop-in replacement for `functools.wraps`
+ Alternative work with a class-based setup
+ no dependecies
+
A class-based decorator provides methods to override the given function.
@Strangemother
Strangemother / dynamic_module.py
Created January 3, 2021 09:02
A module level getter/setter
"""A module level getter/setter
>>> import vmod
>>> vmod.Woof
Getting Woof...
<class 'vmod.Woof'>
>>> vmod.Woof
Getting Woof...
<class 'vmod.Woof'>