Skip to content

Instantly share code, notes, and snippets.

@dgtlmoon
dgtlmoon / RedisPythonPubSub1.py
Created October 8, 2016 19:26 — forked from jobliz/RedisPythonPubSub1.py
A short script exploring Redis pubsub functions in Python
import redis
import threading
class Listener(threading.Thread):
def __init__(self, r, channels):
threading.Thread.__init__(self)
self.redis = r
self.pubsub = self.redis.pubsub()
self.pubsub.subscribe(channels)
@dgtlmoon
dgtlmoon / lsh-benchmark-test.py
Created November 14, 2016 21:37
Rough LSH python benchmark of potential ORB descriptors
from lshash import LSHash
import numpy
import time
lsh = LSHash(100, 200, 1, None, "hamming.npz")
# Very modest
# lets assume 5000 images, with 200 features and 200 binary descriptors each
for y in range(0, 5000):
for x in range(0, 200):
@dgtlmoon
dgtlmoon / gsmarena_finder.py
Created February 22, 2017 09:41
Python BeutifulSoup4 quick hack to find me a phone released in 2016 with an Infrared port
#!/usr/bin/python
# Add your regex to find your phone
# Horrible lazy fast script
from bs4 import BeautifulSoup
import urllib2
import re
response = urllib2.urlopen('http://www.gsmarena.com/battery-test.php3')
@dgtlmoon
dgtlmoon / gist:05581ae337eb38bb015ee2e0ae6a0672
Last active December 14, 2017 00:06
paperspace && tensorbox recipe
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update && apt-get remove docker docker-engine docker.io -y
@dgtlmoon
dgtlmoon / index.php
Last active October 19, 2017 05:44
blueimp gallery simple lister
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title>Gallery</title>
<link rel="stylesheet" href="../css/blueimp-gallery.css">
<link rel="stylesheet" href="../css/blueimp-gallery-indicator.css">
@dgtlmoon
dgtlmoon / blueimp-gallery.sh
Last active October 19, 2017 05:52
build a full blueimp based file image based on files in current directory
<!DOCTYPE HTML>
<html lang="en">
<head>
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta charset="utf-8">
<title>Gallery</title>
<link rel="stylesheet" href="css/blueimp-gallery.css">
<link rel="stylesheet" href="css/blueimp-gallery-indicator.css">
#!/bin/bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update && apt-get remove docker docker-engine docker.io -y
server {
server_name example.com;
root /var/www/drupal8; ## <-- Your only path reference.
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
@dgtlmoon
dgtlmoon / example.py
Created March 16, 2020 09:49
Snippet convert JPEG/etc to WEBP
#!/usr/bin/python3
def image_to_webp(src, dest):
import webp
import io
from PIL import Image
# @todo Maybe there's a better way to load this as a stream instead of into RAM, tho my images are all small.
with open(src, "rb") as r:
rb = r.read()