Skip to content

Instantly share code, notes, and snippets.

View waawal's full-sized avatar

Daniel Waardal waawal

View GitHub Profile
@beanieboi
beanieboi / gist:ad526faf063181f336a2
Last active May 11, 2023 15:59
Codeship Nginx Config for Heroku
daemon off;
# Heroku dynos have at least 4 cores.
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
events {
use epoll;
accept_mutex on;
worker_connections 1024;
}
@danilop
danilop / gist:d4ff43835e469043e95e
Last active August 7, 2020 09:29
Amazon S3 redirection rule to send every "miss" (HTTP 404) to the domain root
<RoutingRules>
<RoutingRule>
<Condition>
<HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
</Condition>
<Redirect>
<HostName>danilop.net</HostName>
<ReplaceKeyWith/>
</Redirect>
</RoutingRule>
@iximiuz
iximiuz / flask_static_files_cache_invalidator.py
Last active October 28, 2019 18:56
Flask: add static file's cache invalidator param to URLs generated by url_for(). Blueprints aware.
""" Inspired by http://flask.pocoo.org/snippets/40/ """
app = Flask(__name__)
@app.url_defaults
def hashed_url_for_static_file(endpoint, values):
if 'static' == endpoint or endpoint.endswith('.static'):
filename = values.get('filename')
if filename:
if '.' in endpoint: # has higher priority
@josephmosby
josephmosby / stripe_test.py
Created October 16, 2014 14:03
Walk through a default JS-powered Stripe Checkout using Python and Selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import unittest as ut
import time
class NewPaymentTest(ut.TestCase):
def setUp(self):
self.browser = webdriver.Firefox()
self.browser.implicitly_wait(3)
@typehorror
typehorror / crawler.md
Last active February 19, 2024 03:06
Simple Website Crawler (in python)

Simple Website Crawler

The following gist is an extract of the article Building a simple crawler. It allows crawling from a URL and for a given number of bounce.

Basic Usage

from crawler import Crawler
crawler = Crawler()
crawler.crawl('http://techcrunch.com/')

displays the urls

@medikoo
medikoo / es6-shims.md
Last active March 24, 2021 22:29
List of ECMAScript 6 shims

List of ECMAScript 6 shims

Implemented on top of ECMAScript 5

Provided as distinct CJS modules, installable via npm


ECMAScript 5 Built-in Objects extensions

Individual modules of es5-ext package. See ES6 features for usage information.

Array

@obeleh
obeleh / gist:10820635
Created April 16, 2014 07:00
Python simple deepcopy

A while ago I needed a deepcopy function in python. I found out however that for my usecase I could better build my own. I want to share it so that others might benefit as well.

If the data you're copying is simple data, deepcopy might be overkill. With simple I mean if your data is representable as Json. Let me illustrate with code:

I've used [json-generator](http://www.json-generator.com/ to get some sample json data.)

def deepCopyList(inp):
    for vl in inp:
        if isinstance(vl, list):
@brusic
brusic / Mapping with no explicit boost field
Created February 16, 2014 00:38
Document boosting with Elasticsearch
curl -XPOST localhost:9200/boosts -d '
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"doc": {
"properties": {
"text": {
@kartoch
kartoch / hubic_credentials.py
Last active April 12, 2018 12:22
Python script to obtain Hubic credentials (access and renew tokens)
"""
As Hubic web services are deprecated, this is a small script to request
access and refresh token. It starts a flask server at http://localhost:5000/, the
users fill the hubic authentication form with its navigator and obtain the
credentials returned by the application.
You need requests-oauthlib and flask:
pip install flask
pip install requests-oauthlib
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active May 13, 2025 09:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results