This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
String.prototype.pad = function( len, c, left ) { | |
var s = '', | |
c = ( c || ' ' ), | |
len = Math.max( len, 0 ) - this.length, | |
left = ( left || false ); | |
while( s.length < len ) { s += c }; | |
return ( left ? ( s + this ) : ( this + s ) ); | |
} | |
Number.prototype.pad = function( len, c, left ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Root Check | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
# Get rid of Wolfram | |
sudo apt-get purge wolfram-engine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install NodeJS via NVM | |
sudo apt-get install -y git-core curl | |
curl https://raw.githubusercontent.com/creationix/nvm/v0.3.0/install.sh | bash | |
echo "source /home/vagrant/.nvm/nvm.sh" >> /home/vagrant/.profile | |
source /home/vagrant/.profile | |
nvm install 0.12 | |
nvm alias default 0.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "debian/jessie64" | |
config.vm.network "private_network", ip: "10.0.0.48" | |
config.vm.hostname = "drupal8.local" | |
config.vm.provider "virtualbox" do |vb| | |
# Display the VirtualBox GUI when booting the machine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Drop this directly into the console | |
jQuery('.sortable-image img, .sortable-image').css({width:'auto',height:'auto'}) | |
jQuery('.sortable-image img').each( function(e,elem) { | |
var fixedImg = jQuery(this).attr('src').replace('s.png','.png'); | |
jQuery(this).attr( 'src', fixedImg ); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* so I decided to check out freecodecamp today, just to see how it was | |
* | |
* It's okay, but I have to question the value of learning to write a palindrome checker, that to my mind is not much use... | |
* Here was my punt at it (it passed, I just don't love the look of it) | |
*/ | |
function palindrome(str) { | |
// Good luck! | |
str = str.toLowerCase().replace(/[^a-z0-9]/g, ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace lewiscowles\utils\cms; | |
class ReadingTime { | |
protected static function _read_time( $text, $wordsPerPage = 200.00, $decimalPlaces = 2 ) | |
{ | |
$words = str_word_count( strip_tags( $text ) ); | |
$min = floatval( $words ) / $wordsPerPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function offsetsIn(string $haystack, string $needle, $cs=true) : array { | |
$offset = false; | |
$pos = 0; | |
$out = []; | |
$func = $cs ? '\strpos' : '\stripos'; | |
while (strlen($haystack) > 0 && ($pos === 0 || $offset !== false)) { | |
if($offset !== false) { | |
$out[] = $offset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get remove --purge ruby -y | |
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | |
curl -sSL https://get.rvm.io | bash -s stable | |
export PATH="$PATH:$HOME/.rvm/bin" | |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash | |
export NVM_DIR="/home/vagrant/.nvm" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.network "private_network", ip: "192.168.31.17" | |
config.vm.hostname = "rails.demo" | |
config.vm.provider "virtualbox" do |vb| |