Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@DazWorrall
DazWorrall / Output
Created February 9, 2012 13:06
Testing file upload handling in Flask
in upload handler
in file close
..
----------------------------------------------------------------------
Ran 2 tests in 0.021s
OK
@geoffalday
geoffalday / secretkey.py
Created March 12, 2012 12:28
How to generate a secret key with Python
# How to generate a secret key with Python
# via http://flask.pocoo.org/docs/quickstart/
import os
os.urandom(24)
@howlingblast
howlingblast / gist:5814547
Created June 19, 2013 14:00
CoffeeScript: getter/setter example
Function::property = (prop, desc) ->
Object.defineProperty @prototype, prop, desc
class Person
constructor: (@firstName, @lastName) ->
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
p = new Person 'Leroy', 'Jenkins'
@chrisn
chrisn / popen3_test
Last active March 2, 2023 08:48
Ruby example of using Open3.popen3 with a select loop to read a child process's standard output and standard error streams.
#!/usr/bin/env ruby
require 'open3'
# Returns true if all files are EOF
#
def all_eof(files)
files.find { |f| !f.eof }.nil?
end
@mechanical-snail
mechanical-snail / iterable_to_stream.py
Created November 28, 2013 07:19
Use an iterable of bytestrings as a read-only input stream
#!/usr/bin/python3
# coding: utf8
# Should work in both Python 2 and Python 3
from __future__ import unicode_literals
from __future__ import print_function
import io
def iterable_to_stream(iterable, buffer_size=io.DEFAULT_BUFFER_SIZE):
"""
@hzopak
hzopak / gist:9573928
Last active May 27, 2018 09:43
nginx config for scrapyd deployment to implement basic auth protection
# Scrapyd local proxy for basic authentication.
# Don't forget iptables rule.
# iptables -A INPUT -p tcp --destination-port 6800 -s ! 127.0.0.1 -j DROP
server {
listen 6801;
location ~ /\.ht {
deny all;
}
@Globegitter
Globegitter / es.sh
Last active November 18, 2020 12:52
Easy install for elasticsearch on Ubuntu 14.04
cd ~
##If you want to install OpenJDK
#sudo apt-get update
#sudo apt-get install openjdk-8-jre-headless -y
###Or if you want to install Oracle JDK, which seems to have slightly better performance
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
@martinrusev
martinrusev / cron_supervisord.ini
Last active July 12, 2023 19:17
Cron supervisord
[supervisord]
nodaemon=true
loglevel=debug
[program:amon]
command=gunicorn -c gunicorn.conf.py wsgi
directory=/amon
autostart=true
autorestart=true
redirect_stderr=true
@revett
revett / README.md
Last active November 7, 2016 11:36
Tutum Zero Downtime Re-deploy

Tutum Zero Downtime Re-deploy

cats.jpg

I tweeted Tutum last night asking if they're looking at implementing zero downtime re-deploys for a given service. Slightly surprised by their response as it seems like a critical feature if you want to use the service for a production environment.

"not a top priority, but by Spring :)"

As Tutum currently doesn't support graceful termination of containers within a service, I was experiencing a 5-10 second window of 503 errors, so decided to use the following hack (code below) until the feature is officially implemented.