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 / tsession.sh
Created October 18, 2023 18:44
Launch Tmux Project sessions
#!/usr/bin/env bash
# Initialize variables for widescreens
multiPane=false
# Process options
while getopts "w" opt; do
case $opt in
w)
multiPane=true
@ericvanjohnson
ericvanjohnson / Pagination.php
Last active April 21, 2021 02:09
Laravel Paginate Collection or Array
<?php
use Illuminate\Support\Collection;
use Illuminate\Pagination\Paginator;
use Illuminate\Pagination\LengthAwarePaginator;
/**
* Paginator for a Collection
*
* @param Collection $items
* @param int $perPage
@ericvanjohnson
ericvanjohnson / rps.php
Created March 16, 2021 03:46
PHP Puzzle - php[arch] March 2021
<?php
$winner = rpsCompare('rock', 'paper');
// $winner = rpsCompare('rock', 'rock');
// $winner = rpsCompare('rock', 'scissors');
// $winner = rpsCompare('scissors', 'paper');
// $winner = rpsCompare('scissors', 'rock');
// $winner = rpsCompare('paper', 'scissors');
// $winner = rpsCompare('paper', 'rock');
@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()
syntax on
set nowrap
set encoding=utf8
"""" START Vundle Configuration
" Disable file type for vundle
filetype off " required
"
"""
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 / HeyFocus.sh
Created November 22, 2017 00:07
Launch focus using ZSH
#!/bin/bash
# Started using Focus https://heyfocus.com/
# But I wanted to launch it from the command line
# They had bash commands but I use ZSH so I wrote this script
# It lauches with the BASH shell and allows optional times to pass
open focus://focus?minutes=${1:-15}
# Make file executable
@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 / CakePHP-Presentation-Notes.md
Last active June 19, 2017 05:14
Notes from CakePHP Lightning Talk at SDPHP June 14, 2017

Create New Cake Project

composer create-project --prefer-dist cakephp/app bookmarker

Start CakePHP Internal Server

bin/cake server