Skip to content

Instantly share code, notes, and snippets.

View lukaswhite's full-sized avatar

Lukas White lukaswhite

View GitHub Profile
@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]
}
})
### 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 / 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)
@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 / FoundationPresenter.php
Created December 13, 2013 09:52
Foundation-friendly pagination for Laravel 4
<?php namespace Lukaswhite\Pagination;
use Illuminate\Pagination\Paginator;
class FoundationPresenter {
/**
* The paginator instance being rendered.
*
* @var \Illuminate\Pagination\Paginator
@lukaswhite
lukaswhite / Tipsum.php
Created January 23, 2014 20:07
T'Ipsum - a Yorkshire Lorum Ipsum alternative, inspired by http://tlipsum.appspot.com/ by @tonyblundell
/**
* T'ipsum, a dead simple class for generating Yorkshire t'ipsum.
*
* Based on http://tlipsum.appspot.com/ by @tonyblundell.
*/
class Tipsum {
/**
* The actual text
*/
@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 / 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 / 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 / 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);
})