Skip to content

Instantly share code, notes, and snippets.

# - Find Boost
#
# Based on https://gist.github.com/thiagowfx/970e3931387ed7db9a39709a8a130ee9 Copyright (c) 2016 Thiago Barroso Perrotta
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
@paolostefan
paolostefan / pygame_blank_window.py
Created December 7, 2021 16:34
Open a blank 640x480 pixels window in PyGame, and quit when it gets closed.
#!/usr/bin/env python3
import pygame
from pygame.locals import *
def main():
srf = pygame.display.set_mode((640,480))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
#!/usr/bin/env bash
set -euo pipefail
BASE=/etc/hostenvs/
function usage {
echo "Usage: $0 <environment>"
echo
echo "<environment> is the name of a file in ${BASE} to be symlinked to /etc/hosts."
@paolostefan
paolostefan / web.config
Created October 25, 2018 12:03
Basic web.config file for a Symfony website running on IIS
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value="iisstart.htm" />
<remove value="Default.htm" />
<remove value="Default.asp" />
<add value="index.php" />
</files>
@paolostefan
paolostefan / countries.py
Last active April 23, 2018 13:12
Python list of Countries with the following info: English name, ISO-2 code, ISO-3 code, M49 code, region, sub-region, intermediate region, timezones. Based upon the gist https://gist.github.com/pamelafox/986163
countries = [
{'capital': 'Andorra la Vella',
'code': 'AD',
'continent': 'Europe',
'intermediate_region_code': '',
'intermediate_region_name': '',
'iso3': 'AND',
'm49': '020',
'name': 'Andorra',
'region_code': '150',
@paolostefan
paolostefan / admin.py
Created April 20, 2016 13:34
Custom user model admin
from django import forms
from django.contrib import admin
from django.contrib.auth.models import Group
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import ReadOnlyPasswordHashField
from .models import *
class UserCreationForm(forms.ModelForm):
"""A form for creating new users. Includes all the required
@paolostefan
paolostefan / models.py
Last active April 20, 2016 13:32
Custom user model
# coding=utf-8
from django.db import models
from django.contrib.auth.models import BaseUserManager, AbstractBaseUser
class CustomUserManager(BaseUserManager):
def create_user(self, email, username, date_of_birth, password=None):
"""
Creates and saves a User with the given email, date of
birth and password.
@paolostefan
paolostefan / composer.json
Created August 14, 2013 13:22
composer.json suited for Symfony 2.3 and Gaufrette
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
@paolostefan
paolostefan / composer.json
Last active December 21, 2015 01:38
Override stability level for a single bundle, but not for dependencies
{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",