Skip to content

Instantly share code, notes, and snippets.

View mattkirwan's full-sized avatar

Matt Kirwan mattkirwan

View GitHub Profile
@mattkirwan
mattkirwan / 01.java
Created December 1, 2022 20:08
01.Java
File file = new File("./input.txt");
Scanner sc = new Scanner(file);
Integer currentElf = 0;
ArrayList<Integer> elfCalories = new ArrayList<>();
elfCalories.add(0);
while (sc.hasNextInt()) {
String line = sc.nextLine();
@mattkirwan
mattkirwan / firefox-vim-vixen.cfg
Last active September 22, 2018 08:49
Firefox - Vim Vixen Config
{
"keymaps": {
"0": { "type": "scroll.home" },
":": { "type": "command.show" },
"o": { "type": "command.show.open", "alter": false },
"O": { "type": "command.show.open", "alter": true },
"t": { "type": "command.show.tabopen", "alter": false },
"T": { "type": "command.show.tabopen", "alter": true },
"w": { "type": "command.show.winopen", "alter": false },
"W": { "type": "command.show.winopen", "alter": true },
@mattkirwan
mattkirwan / RDAD_Twitch_Status
Created June 1, 2015 10:33
A quick bash script to get the latest RDAD twitchers and show there current streaming status.
#!/bin/bash
twitch_accounts=()
while read line
do
twitch_accounts+=("$line")
done < <(curl http://www.reddit.com/r/RedditDads/wiki/twitch_and_youtube | grep "* http://www.twitch.tv/" | sed 's/* http\:\/\/www\.twitch\.tv\//\ /;s//\n/')
for twitch_account in "${twitch_accounts[@]}"
do
Matts-MacBook-Air:cleveland-land-services.co.uk mattkirwan$ grunt --env=production
Running "replace:modxSettings" (replace) task
Replace web/z64ml/config.core.php → web/z64ml/config.core.php
Replace web/n3yu9/config.core.php → web/n3yu9/config.core.php
Replace web/config.core.php → web/config.core.php
Replace core_tY670_uW/config/No3r4kXHBbNdLJdw9ryZJrfrP52Jvy1q.inc.php → core_tY670_uW/config/No3r4kXHBbNdLJdw9ryZJrfrP52Jvy1q.inc.php
Running "copy:build" (copy) task
Created 17 directories, copied 120 files
@mattkirwan
mattkirwan / gist:2588935da356fe81cad1
Last active August 29, 2015 14:13
Problems you know you've solved but can't remember the solution....
Q: Having problems with [usemin, grunt, useminprepare] not correctly renaming hook blocks in a [html, twig] template?
A: Check the motherfucking line endings of that file and ensure they are 'Unix'.
Q: Running a cron job and the script isn't firing?
A: Don't forget to check the PATH variable is imported at the top of the .sh file
Q: Having problems updating ModX directories (eg: core) and the /setup/ upgrade not working?
A: Make sure you replace the files/directories with the cp -R command and not Finder. Because Finder merge is weird and shit.
@mattkirwan
mattkirwan / generateChoice.php
Last active December 29, 2015 03:09
Nice little snippet to generate a customisable 'choice' array (up to 5 elements can be displayed) from an array of items - perfect for drop downs/checkboxes and such.
<?php
/***********************************************
Raw Data:
@$raw_data
Array
(
[0] => Array
@mattkirwan
mattkirwan / Quick Project
Created November 16, 2013 00:13
A nice simple shell script for create a quick framework based project. Currently only supports Laravel, but will adapt with Silex another time
#!/bin/bash
function install_laravel() {
echo "Installing Laravel into '$project_name'..."
wget https://github.com/laravel/laravel/archive/master.zip ./
unzip ./master.zip
Starting php-fpm:
[06-Jun-2013 18:38:32] NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/memcached.so' - /usr/lib64/php/modules/memcached.so: cannot open shared object file: No such file or directory in Unknown on line 0
[ OK ]
@mattkirwan
mattkirwan / bootstrap.sh
Created June 6, 2013 18:43
Vagrant bootstrap
#!/bin/bash
# Update packages
yum update
# Add some repos
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# Install MySQL
@mattkirwan
mattkirwan / create-a-slug.php
Last active December 16, 2015 09:38
A quick function to create a url 'slug' from a given string.
<?php
function convertToSlug($input)
{
$text = preg_replace('~[^\\pL\d]+~u', '-', $input);
$text = trim($text, '-');
$text = strtolower($text);
$text = preg_replace('~[^-\w]+~', '', $text);
return $text;
}