Skip to content

Instantly share code, notes, and snippets.

View samayo's full-sized avatar
💬
drink more water

Samson Daniel samayo

💬
drink more water
View GitHub Profile
@samayo
samayo / daemon_example.py
Created April 21, 2016 11:41 — forked from slor/daemon_example.py
An example of a Linux daemon written in Python. Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python
""" An example of a Linux daemon written in Python.
Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
The changes are:
1 - Uses file open context managers instead of calls to file().
2 - Forces stdin to /dev/null. stdout and stderr go to log files.
3 - Uses print instead of sys.stdout.write prior to pointing stdout to the log file.
4 - Omits try/excepts if they only wrap one error message w/ another.
@samayo
samayo / gistable
Created April 18, 2016 19:33
Created via API
Demo
@samayo
samayo / README.md
Created November 3, 2015 01:07 — forked from scottpnelson/README.md
Automatic MySQL database setup from .env file contents

About

This script will automatically create a new MySQL database for you by reading your MySQL database name, host name, and user credentials from your .env file. This allows you to keep your database details safe, in a single location. Ideal for deployment and security.

Installation

1. Download setup_mysql.sh to your project root directory 2. You can modify setup_mysql.sh to set the following: - ENV_FILE (the relative path to your .env file -- e.g. ENV_FILE="./.env.local") - DEFAULT_MYSQL_HOST (the host name of your MySQL server -- e.g. "localhost") - DEFAULT_MYSQL_ADMIN_USERNAME (the administrator username of your mysql server -- e.g. "root" (note: this is typically NOT the MySQL username of your app). This should be no longer than 16 characters. Some versions of MySQL allow for longer lengths. You can modify the MAX_MYSQL_USERNAME_LENGTH variable to change this length. - DEFAULT_MYSQL_ADMIN_PASSWORD (the administrator password of your mysql admin user -- e.g
@samayo
samayo / php.sh
Last active August 28, 2015 20:13 — forked from kelunik/php.sh
#!/bin/bash
set -e
set -x
if [ $1 == "master" ]
then
wget https://github.com/php/php-src/archive/master.zip -q -O master.zip
rm -rf php-src-master
unzip -q master.zip
<?php
### USAGE
#Require the autoload in your bootstrap, and use the Application to start your app
require __DIR__ . '/../Autoload.php';
$app = new Fastpress\Application;
$app->get('/hello/{:name}', function($name) use ($app){
@samayo
samayo / bootstrap.php
Created August 17, 2015 13:41
sketch
### USAGE
Require the autoload in your bootstrap, and use the Application to start your app
require __DIR__ . '/../Autoload.php';
$app = new Fastpress\Application;
$app->get('/hello/{:name}', function($name) use ($app){
echo 'Hello ' $app->escape($name); // Hello world
});
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;

Magic words:

psql -U postgres

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

  • \q: Quit/Exit
  • \c __database__: Connect to a database
  • \d __table__: Show table definition including triggers
@samayo
samayo / nginx.conf
Created April 11, 2015 23:34
Nginx configuration file
user nginx;
worker_processes 4;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
server {
listen 80;
server_name example.com dev.example.com;
root /var/www/sites/public/dev.example/;
index index.html index.htm index.php;
access_log /var/log/nginx/example.com_access.log;
error_log /var/log/nginx/example.com_error.log;
charset utf-8;