Skip to content

Instantly share code, notes, and snippets.

@manuelep
manuelep / map_service.py
Last active June 24, 2017 06:22
A web service that draw a map to be called using LOAD web2py helper
@service.run
def getmap(conn, tablename, the_geom="geom", bbox=''):
""" """
session.forget(response)
js = """
var url = "%(url)s";
var gargs = "%(bbox)s" && '?bbox='+"%(bbox)s";
var dynSource = new ol.source.Vector({
url: url + gargs,
format: new ol.format.GeoJSON(),
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active January 9, 2025 12:22
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

#!/bin/bash
echo 'Requires Ubuntu = 16.04 and installs Nginx + uWSGI + Web2py'
# Check if user has root privileges
if [[ $EUID -ne 0 ]]; then
echo "You must run the script as root or using sudo"
exit 1
fi
# parse env vars
WEB2PY_PASS="${WEB2PY_PASS:-0}"
NOPASSWORD="${NOPASSWORD:-0}"
import pygame
from pygame import locals
import socket
import atexit
pygame.init()
pygame.joystick.init() # main joystick device system
try:
@roboflank
roboflank / clickapp.js
Last active January 5, 2018 13:33
ClickSend Arduino
var SerialPort = require("serialport").SerialPort,
express = require('express'),
bodyParser = require('body-parser');
// initialize a sample request function
//This request will be posted once the server is started
var request = require('request');
request({
method: 'POST',
@ph1ee
ph1ee / mserv.py
Created September 25, 2015 11:33
Simple Bottle MJPEG Streamer
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Inspired by:
* http://weeklybuild.com/2014/07/07/mjpeg-bottle-gstreamer/
* http://www.ridgesolutions.ie/index.php/2014/11/24/streaming-mjpeg-video-with-web2py-and-python/
* https://gist.github.com/n3wtron/4624820
'''
@manuelep
manuelep / w2p-bb-install.sh
Last active June 23, 2017 14:45
get a brand new minimalist version of web2py
#!/bin/bash
git clone --recursive https://github.com/web2py/web2py.git web2py_temp
cd web2py_temp
git checkout tags/R-2.11.2
git submodule update --init --recursive
python scripts/make_min_web2py.py ../web2py
mv applications/admin ../web2py/applications/
cd ../
rm -rf web2py_temp
@ScottEvil
ScottEvil / install-eden-apache-mysql.sh
Last active December 9, 2015 19:11
Pre-Install steps for Sahana Eden for Ubuntu 14.04
#!/bin/sh
# Script to turn a generic Debian Squeeze box into an Eden server
# with Apache & MySQL
# Update system
apt-get update
#apt-get upgrade -y
# Install Admin Tools
apt-get install -y unzip
# Install Git
apt-get install -y git-core
@ladyada
ladyada / ar1100cal.py
Last active March 19, 2018 23:01
ar1100.py auto-calibrator
#!/usr/bin/python
import sys
import usb.core
import usb.util
import time
import os
import pygame
from pygame.locals import*
def mapnum(x, in_min, in_max, out_min, out_max):
@kirsn
kirsn / cache_test_script.py
Created April 3, 2015 17:24
Web2py cache usage / test script
import time
def print_rows(rows):
print time.ctime()
for row in rows:
print row
db = DAL('sqlite://cache_test.db', pool_size=0)
db.define_table('t1', Field('name',type='string'))