Skip to content

Instantly share code, notes, and snippets.

View ericvanjohnson's full-sized avatar
🐘
Probably doing PHP Stuff.

Eric Van Johnson ericvanjohnson

🐘
Probably doing PHP Stuff.
View GitHub Profile
@ericvanjohnson
ericvanjohnson / AppServiceProvider.php
Created August 28, 2020 16:32 — forked from simonhamp/AppServiceProvider.php
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
"""
1. Setup a Twitter Developer account and create new App, get its consumer key and consumer secret and replace them below
2. Replace TWEETS_DB, QUERY, and LANGUAGE values
3. Install required packages: `pip install tweepy schedule`
4. Run process using `python tweets_to_db.py`
"""
import tweepy
import sqlite3
import datetime
<?php
/**
* Content from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
**/
return array(
100 => 'Continue',
101 => 'Switching Protocols',
102 => 'Processing', // WebDAV; RFC 2518
200 => 'OK',
@ericvanjohnson
ericvanjohnson / replace_php_short_tags.sh
Created September 21, 2017 16:09 — forked from ma2thieu/replace_php_short_tags.sh
replace php short tags (<?) with long one (<?php)
#!/bin/bash
# first short tags with something that is not a letter after
find . -iname "*.php" -print0 | xargs -0 -I{} sed -i -r 's/(<\?)([^a-zA-Z])/\1php\2/g' '{}'
# then short tags at end of line
find . -iname "*.php" -print0 | xargs -0 -I{} sed -i -r 's/<\?$/<\?php/g' '{}'
@ericvanjohnson
ericvanjohnson / nginx.conf
Created March 24, 2017 23:57 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@ericvanjohnson
ericvanjohnson / php pre-commit hook with linting
Last active February 14, 2016 01:26 — forked from johncongdon/php
php linting pre-commit hook
#!/usr/local/bin/php
<?php
# PHP LINTING
$output = array();
$return = 0;
exec('git rev-parse --verify HEAD 2> /dev/null', $output, $return);
$against = $return == 0 ? 'HEAD' : '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
exec("git diff-index --diff-filter=ACMRTUXB --cached --name-only {$against}", $output);
@ericvanjohnson
ericvanjohnson / pre-commit
Last active February 14, 2016 01:06 — forked from ronanguilloux/pre-commit
phplint + phpcs + php-cs-fixer PHP-related pre-commit git hook (needs to add squizlabs/php_codesniffer & fabpot/php-cs-fixer to your composer.json)
#!/bin/sh
# @source: https://gist.github.com/ronanguilloux/11f6a788358577474ab4
# @link http://tech.zumba.com/2014/04/14/control-code-quality/
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
@ericvanjohnson
ericvanjohnson / .bashrc
Created January 13, 2016 21:31 — forked from Kindari/.bashrc
Forward Prompt to remote servers
SSH_FORWARD_PROMPT=true
export PS1="\n[\[\e[32m\]\t\[\e[m\] \[\e[31m\]\u\[\e[m\]@\[\e[36m\]\H\[\e[m\]][\[\e[32m\]\$?\[\e[m\]]\[\e[33m\]\`/usr/sbin/getenforce\`\[\e[m\]\n\w:\!> "
function ssh_forward_prompt()
{
env ssh -A "$@" -t "PS1='$PS1' bash -l"
}
if [ "$SSH_FORWARD_PROMPT" = true ] ; then
@ericvanjohnson
ericvanjohnson / tmux-cheatsheet.markdown
Last active December 20, 2015 18:39 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@ericvanjohnson
ericvanjohnson / vagrant.org
Created June 30, 2013 12:17 — forked from zellyn/vagrant.org
Vagrant Ruby Spin Up