Skip to content

Instantly share code, notes, and snippets.

View derrekbertrand's full-sized avatar

Derrek Bertrand derrekbertrand

View GitHub Profile
<?php
/*
* Copyright 2017-2018 Derrek Bertrand <[email protected]>
* Copyright 2018 CollabCorp Group
*
* License: MIT
*/
use Exception;
<?php
/*
* Copyright 2017-2018 Derrek Bertrand <[email protected]>
* Copyright 2018 CollabCorp Group
*
* License: MIT
*/
use Exception;
#!/usr/bin/env python
import json
import sys
import os
from collections import OrderedDict
"""
QJson
@derrekbertrand
derrekbertrand / lemp.sh
Created October 23, 2017 15:13
LEMP on Ubuntu 16.04
#!/usr/bin/env bash
# This installs a multi tenant Nginx setup with PHP FPM 7.1 and MariaDB
# it is suitable for Laravel 5.5
# THIS IS NOT A SCRIPT PER SE!
# THE COMMENTS MAY HAVE INSTRUCTIONS TOO!
# USING: Digital Ocean's vanilla Ubuntu 16.04 droplet
#----------------------------------------------------------
# SECURITY CONCERNS
#----------------------------------------------------------
<?php
/*
The methods are in the order worked on:
First, what is a palindrome? How can tell if something `is_palindromic`?
Generate numbers with N `digits`. Abuse the fact that
intval('non numeric string') == 0
@derrekbertrand
derrekbertrand / show-me-a-cat.js
Created October 18, 2017 19:09
Show me a cat Webtask!
'use latest';
import parser from 'rss-parser';
module.exports = function(context, req, res) {
// we could probably easily allow the user to supply their subreddit of choice
// but kitties are wholesome, so lets leave it at that
parser.parseURL('https://www.reddit.com/r/cats/.rss', function(err, parsed) {
// the messages aren't helpful, IMHO but at least you'll know if it breaks
if(err) { res.writeHead(500, {}); res.end(err.message); return; }
@derrekbertrand
derrekbertrand / daemon.py
Created September 26, 2017 13:29 — forked from josephernest/daemon.py
Daemon for Python
# From "A simple unix/linux daemon in Python" by Sander Marechal
# See http://stackoverflow.com/a/473702/1422096
#
# Modified to add quit() that allows to run some code before closing the daemon
# See http://stackoverflow.com/a/40423758/1422096
#
# Joseph Ernest, 2016/11/12
import sys, os, time, atexit
from signal import signal, SIGTERM
@derrekbertrand
derrekbertrand / gitlab.sh
Last active July 1, 2018 23:38
Gitlab notes
# this makes sure every user has these files, so we can easily add keys
mkdir /etc/skel/.ssh
touch /etc/skel/.ssh/authorized_keys
chmod 700 /etc/skel/.ssh
chmod 600 /etc/skel/.ssh/authorized_keys
# edit /etc/adduser.conf: set DIR_MODE to 0751
# disable password login for ssh now
# if you used keys instead of a password on digital ocean, this is already done

Install build packages from repos. You will probably need EPEL.

 ~ # yum install git gcc gcc-c++ libxml2-devel pkgconfig openssl-devel bzip2-devel curl-devel libpng-devel libjpeg-devel libXpm-devel freetype-devel gmp-devel libmcrypt-devel mariadb-devel aspell-devel recode-devel autoconf bison re2c libicu-devel postgresql-devel

For Ubuntu this looks something like:

~ # apt install autoconf bison libpq-dev libxml2-dev apache2-dev systemtap-sdt-dev openssl pkg-config libssl-dev libcurl4-openssl-dev libbz2-dev libgdbm-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev libfreetype6-dev libicu-dev libiodbc2-dev libxslt1-dev
@derrekbertrand
derrekbertrand / CentOS7WebDev.md
Last active February 10, 2017 21:15
A CentOS 7 web dev checklist.

To Set Up PostgreSQL:

  • Run yum install postgresql-server postgresql-contrib; installs PostgreSQL and some utilities
  • Run postgresql-setup initdb; sets up the default config
  • Near line ~82 in /var/lib/pgsql/data/pg_hba.conf, change the method from ident to md5 on the host lines
  • Run systemctl start postgresql to start the SQL server
  • Run systemctl enable postgresql to enable it as a service
  • Setup created a postgres "root" user called postgres you can become that user with sudo -i -u postgres
  • You can get a SQL prompt with psql; exit SQL prompt by typing \q
  • Postgres user also has the createuser and createdb commands available; by default, it matches user accounts and database names by the user account that is accessing it. So you will likely need to add a user and a db named after an existing UNIX account.