Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Alex Richards ajtrichards

🏠
Working from home
Block or report user

Report or block ajtrichards

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View example-log-entry.sh
Feb 3 19:27:50 user-api-*-* user-api WARNING [03-Feb-2018 19:27:50] WARNING: [pool www] child 958 said into stderr: "[2018-02-03 19:27:50] lumen.DEBUG: user.api.view.user.error.user-details {"action":"user.api.view.user.error.user-details","userData":{"forename":"Alex","surname":"Richards","fullname":"Alex Richards","email":"emailaddress@hidden.com","username":"emailaddress@hidden.com","enabled":true,"earn":"earn:user/users:A-UUID-4"}} []"
@ajtrichards
ajtrichards / byte_to_str.go
Last active Jan 22, 2018 — forked from is73/byte_to_str.go
Convert []byte to string in Golang
View byte_to_str.go
func BytesToString(data []byte) string {
return string(data[:])
}
@ajtrichards
ajtrichards / clean-deleted-branches.sh
Created Dec 25, 2017
A command to delete merged branches in GIT
View clean-deleted-branches.sh
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
View sample-nginx.conf
daemon off;
pid /tmp/nginx.pid;
error_log /dev/stderr info;
worker_processes auto;
events {
worker_connections 1024;
}
http {
@ajtrichards
ajtrichards / dates-between-two-date-ranges.php
Created Nov 28, 2016
Prints all of days, weeks, months, etc between two date ranges.
View dates-between-two-date-ranges.php
<?php
$start = (new DateTime('2010-12-02'))->modify('first day of this month');
$end = (new DateTime('2012-05-06'))->modify('first day of next month');
$interval = DateInterval::createFromDateString('1 month');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $dt) {
echo $dt->format("Y-m") . "<br>\n";
}
@ajtrichards
ajtrichards / tail-grep-steam.sh
Created Aug 19, 2015
Tail a streaming file with GREP
View tail-grep-steam.sh
tail -f access.log | grep --line-buffered my_pattern
@ajtrichards
ajtrichards / lumen-query-log.php
Last active Mar 4, 2019
Laravel Lumen - Display Query Log
View lumen-query-log.php
/**
* You must enable to Query Log when using Lumen.
*/
DB::connection()->enableQueryLog();
$queries = DB::getQueryLog();
$last_query = end($queries);
View laravel-s3-upload.php
$s3 = \App::make('aws')->get('s3');
$result = $s3 -> putObject(array(
'Bucket' => 'name-of-your-bucket',
'Key' => 'name-of-your-file.extension',
'SourceFile' => $source_file,
'Metadata' => array(
'foo' => 'bar',
'etc' => 'etc'
)
View sql-date-query.sql
SELECT * FROM tablename WHERE date <= UNIX_TIMESTAMP(STR_TO_DATE('Apr 07 2015 09:00AM', '%M %e %Y %h:%i%p'))
@ajtrichards
ajtrichards / ez_setup.py
Created May 1, 2014
Bootstrap setuptools installation If you want to use setuptools in your package's setup.py, just include this file in the same directory with it, and add this to the top of your setup.py:: from ez_setup import use_setuptools use_setuptools() If you want to require a specific version of setuptools, set a download mirror, or use an alternate downl…
View ez_setup.py
#!python
"""Bootstrap setuptools installation
If you want to use setuptools in your package's setup.py, just include this
file in the same directory with it, and add this to the top of your setup.py::
from ez_setup import use_setuptools
use_setuptools()
If you want to require a specific version of setuptools, set a download
You can’t perform that action at this time.