Skip to content

Instantly share code, notes, and snippets.

View lukaswhite's full-sized avatar

Lukas White lukaswhite

View GitHub Profile
@lukaswhite
lukaswhite / nationalities.php
Created May 17, 2021 06:35
Nationalities in PHP
(new \PragmaRX\Countries\Package\Countries())
->all()
->keyBy('iso_3166_1_alpha2')
->filter(function ($value, $key) {
return (bool)strlen($key);
})
->pluck('demonyms.eng.m')
->filter(function($name){
return !empty($name);
})
@lukaswhite
lukaswhite / increase_swap.sh
Created March 22, 2017 16:28 — forked from shovon/increase_swap.sh
Increasing swap size. Only tested on the ubuntu/trusty64 Vagrant box. CREDIT GOES TO ---> http://jeqo.github.io/blog/devops/vagrant-quickstart/
#!/bin/sh
# size of swapfile in megabytes
swapsize=8000
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
@lukaswhite
lukaswhite / gist:67e625d47b0a7f662238
Created March 21, 2016 12:20
Display numeric file permissions on 'Nix systems
ls -l | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/) \
*2^(8-i));if(k)printf("%0o ",k);print}'
@lukaswhite
lukaswhite / flush.php
Created February 17, 2015 18:06
Flush Drupal 7's cache, when all you have is FTP (!) access.
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
print 'All caches cleared';
@lukaswhite
lukaswhite / ordinalized_date.rb
Created November 19, 2014 16:33
Ordinalized Dates in Jekyll
require 'date'
module Jekyll
module OrdinalizedDate
def ordinalized_date(input)
d = input.strftime("%e")
input.strftime("%A ") + self.ordinalize(d.to_i) + input.strftime(" %B, %Y")
end
def ordinalize(number)
if (11..13).include?(number % 100)
### Keybase proof
I hereby claim:
* I am lukaswhite on github.
* I am lukaswhite (https://keybase.io/lukaswhite) on keybase.
* I have a public key whose fingerprint is 71E9 57B9 7336 A635 0B44 E769 5136 FCD6 881C 9CDA
To claim this, I am signing this object:
@lukaswhite
lukaswhite / gist:467a91d62b5d66d82341
Created October 3, 2014 13:14
Getting a list of routes from an Express 4 application
var _ = require('lodash')
var routes = _.map(_.filter(app._router.stack, function(item){
return (item.route != undefined)
}), function(route){
return {
path: route.route.path,
method: Object.keys(route.route.methods)[0]
}
})
@lukaswhite
lukaswhite / elasticsearch-on-homestead.txt
Created August 3, 2014 08:58
Installing Elasticsearch on Laravel Homestead
# Install Java
sudo apt-get install openjdk-7-jre-headless -y
# Download & install the Public Signing Key
wget -qO - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | sudo apt-key add -
# Add the following to /etc/apt/sources.list
deb http://packages.elasticsearch.org/elasticsearch/1.3/debian stable main
# Update Aptitude
@lukaswhite
lukaswhite / create-project.sh
Created March 2, 2014 18:33
A Bash Script for New projects
# CONFIGURATION
#MYSQL credentials
MYSQL_USER="root"
MYSQL_PASS=""
# The user Apache runs as - e.g. _www, www-data
APACHE_RUNAS="_www"
#Bitbucket credentials
@lukaswhite
lukaswhite / ClearBeanstalkdQueueCommand.php
Last active March 20, 2023 08:11
Clear a Beanstalkd Queue in Laravel
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class ClearBeanstalkdQueueCommand extends Command {
/**