Skip to content

Instantly share code, notes, and snippets.

@eyesee1
eyesee1 / wagtail_remote_image.py
Created October 17, 2016 20:23
Grabbing image data from a URL and saving into Wagtail CMS - example code
from io import BytesIO
import requests
from django.core.files.images import ImageFile
from wagtail.wagtailimages.models import Image
# event is a model object, substitute your model
# filename and title are up to you
# in my model, event.event_image is a ForeignKey to wagtailimages.Image
response = requests.get(url)
@seamusleahy
seamusleahy / fetch-response.js
Last active May 4, 2019 19:17
Using the Fetch HTML5 API to POST a form and get back JSON data.
// 3. Use the response
// ================================
responsePromise
// 3.1 Convert the response into JSON-JS object.
.then(function(response) {
return response.json();
})
// 3.2 Do something with the JSON data
.then(function(jsonData) {
console.log(jsonData);
@dooglus
dooglus / public.py
Created August 13, 2016 20:45
create Bitcoin public key from private key
#! /usr/bin/env python
class Point(object):
def __init__(self, _x, _y, _order = None): self.x, self.y, self.order = _x, _y, _order
def calc(self, top, bottom, other_x):
l = (top * inverse_mod(bottom)) % p
x3 = (l * l - self.x - other_x) % p
return Point(x3, (l * (self.x - x3) - self.y) % p)
@kuznero
kuznero / docker-clean.md
Last active April 1, 2023 12:28
Cleanup docker images and containers after failed builds

Cleanup docker images and containers after failed builds

Sometimes, there are some untagged images left behind after failed builds. In order to get rid of those, this script can be used.

#!/bin/bash
docker rm $(docker ps -aq)
docker rmi $(docker images | grep "^<none>" | awk '{print $3}')
@mattgorecki
mattgorecki / RaspberryPi-RFID
Created July 26, 2013 01:34
Python script to read RFID card from serial RFID reader attached to a Raspberry Pi. Also has a Exit button. The card swipe releases the maglock on the door.
#!/usr/bin/python2
import serial
import re, sys, signal, os, time, datetime
import RPi.GPIO as GPIO
BITRATE = 9600
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
@chitchcock
chitchcock / 20111011_SteveYeggeGooglePlatformRant.md
Created October 12, 2011 15:53
Stevey's Google Platforms Rant

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

@abyx
abyx / list_filter_collapse.js
Created June 9, 2011 20:09
java script trick to hide the "filter" in a django admin view
(function($){
ListFilterCollapsePrototype = {
bindToggle: function(){
var that = this;
this.$filterTitle.click(function(){
that.$filterContent.slideToggle();
that.$list.toggleClass('filtered');
});
},
init: function(filterEl) {
@gvangool
gvangool / daemonextension.py
Created July 13, 2009 13:51 — forked from screeley/daemonextension.py
Django Management Command for starting a daemon.
"""
Copyright (c) 2009, Sean Creeley
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,