Skip to content

Instantly share code, notes, and snippets.

@toolness
toolness / gencert.py
Last active June 22, 2023 11:52
Python script to create server SSL certs and sign them with a custom CA.
#! /usr/bin/python
"""
This simple script makes it easy to create server certificates
that are signed by your own Certificate Authority.
Mostly, this script just automates the workflow explained
in http://www.tc.umn.edu/~brams006/selfsign.html.
Before using this script, you'll need to create a private
@chanmix51
chanmix51 / create_table.sql
Created August 1, 2012 09:12
Recursive tree browsing in Postgres SQL
CREATE TABLE node (name varchar PRIMARY KEY, is_child_of varchar REFERENCES node (name), some_int integer NOT NULL);
CREATE INDEX node_is_child_of_idx ON node (is_child_of);
-- Fill the table with nice big random tree
WITH RECURSIVE
path_node AS (
SELECT
md5(chr(CAST(floor(random() * 223) AS integer) + 32) || random()) AS name,
NULL AS is_child_of,
0 AS some_int,
@divanvisagie
divanvisagie / system.js
Last active December 10, 2015 05:48
The system function attempts to bring the C system() function to node.js with extended functionality. system() executes a command and fires an event when done that will return the command output. system has 2 events: 'data' - returns the output data of the command 'exit' - returns command exit code dependancies npm install colors Examples of the…
/* License MIT */
var spawn = require( 'child_process' ).spawn,
colors = require( 'colors' );
/*
Executes a command and fires event when done that
will return the command output
*/
function system( cmd ){
@ninjascribble
ninjascribble / node-user-agent.js
Last active September 30, 2024 22:28
Fetching the user-agent string from a request using either NodeJS or NodeJS + Express
/** Native NodeJS */
var http = require('http')
, server = http.createServer(function(req) {
console.log(req.headers['user-agent']);
});
server.listen(3000, 'localhost');
/** NodeJS with Express */
var express = require('express')
@techniq
techniq / audit_mixin.py
Created March 16, 2013 01:05
Useful SQLAlchemy Mixins
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declared_attr
from flask_security import current_user
class AuditMixin(object):
created_at = Column(DateTime, default=datetime.now)
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
@barryvdh
barryvdh / _ide_helper.php
Last active October 24, 2024 17:13
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.5.13 on 2017-09-28.
*
* @author Barry vd. Heuvel <[email protected]>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
exit("This file should not be included, only analyzed by your IDE");
@fideloper
fideloper / install.sh
Last active October 30, 2023 20:03
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@mrryanjohnston
mrryanjohnston / Dockerfile
Created March 9, 2014 01:38
Golang development environment using Docker
FROM ubuntu:13.10
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install golang
RUN mkdir /go
RUN export GOPATH=/go
ENV GOPATH /go
RUN export PATH=$PATH:$GOPATH/bin
@scoutman57
scoutman57 / .gitconfig
Created April 24, 2014 20:28
Use PHPStorm as your git diff tool
# Run `git difftool <directory/file>...` or `git mergetool <directory/file>...`
[merge]
tool = phpstorm
[diff]
tool = phpstorm
[difftool]
prompt = false
[difftool "phpstorm"]
cmd = /Applications/PhpStorm\\ EAP.app/Contents/MacOS/phpstorm diff $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")
trustExitCode = true