Skip to content

Instantly share code, notes, and snippets.

View Lemmings19's full-sized avatar

Lemmings19

View GitHub Profile
@Lemmings19
Lemmings19 / endLine.sh
Last active May 26, 2016 22:35
Add newline to end of files without them.
#!/bin/bash
echo "Adding newlines to files that don't have them."
echo "Each dot represents a file that has had a line added."
# Loop through files in the given directory with the given extensions
for f in $(find /var/www/project-name/ -name "*.php" -or -name "*.phtml" -or -name "*.js"); do
# If the file doesn't end in a new line, add one.
if [ "$(tail -c1 "$f"; echo x)" != $'\nx' ]; then
echo "" >>"$f"
@Lemmings19
Lemmings19 / getTimezonesForLocations.php
Last active March 30, 2017 17:25
Get timezones for a bunch of latitudes and longitudes
<?php
/**
* Using Google's Google Maps Time Zone API, get the timezones for a bunch of locations which have latitudes and longitudes.
* Output the timezones to a file.
*
* Note that this WILL NOT APPEND if the file already exists. It WILL OVERWRITE.
*
* The API returns the following output:
*
* {
@Lemmings19
Lemmings19 / readme.md
Last active April 12, 2017 22:46
Generating an updated PHP translation file using gettext

Simple Instructions:

Run the command.

Explanations:

  1. xgettext will parse a file and look for strings which are wrapped in _(). It will output those strings to a .po file for translations (default filename = messages.po).
  2. The find command will cause xgettext to parse all of the files which find returns rather than just parsing a single file.
  3. --join-existing will merge the results to an existing message.po file in the same output directory.
@Lemmings19
Lemmings19 / laravel-docs-fix.js
Last active April 23, 2017 02:18
Auto-expand Laravel's doc lists. Remove the ad.
// Add this to your browser with your favourite script addon/plugin and jQuery.
// They just did this annoying thing where they hide all the doc headings.
// How the hell am I supposed to CTRL+F on them now?
// May as well remove ads while we're at it.
// Auto-expand all doc listings. Haven't tested for negative side-effects.
$("h2").each(function () {
$(this).addClass("is-active");
});
@Lemmings19
Lemmings19 / fetchTags.php
Last active April 24, 2017 06:53
Hit StackOverflow's API and save to a file.
<?php
/**
* This script hits StackOverflow's API and prints the results out to a file in JSON format.
*
* This script is specifically targeted at tags, but you could manipulate it target other things.
*/
$file = fopen('/mnt/projects/tags.txt', 'a');
/**
@Lemmings19
Lemmings19 / behat-mink-together.md
Last active June 15, 2017 17:48
Using Behat and Mink Together

Preface

These are notes from my initial research into what Behat and Mink are as well as how they interact with one another.

The short of it is that these two tools should not go together. They are two different tools for two different purposes.

Behat is for writing BDD and moving that BDD over to testing the domain (via PHPUnit or a similar tool).

Mink is for testing the front-end user interface of web pages. The logic involved here is typically not domain logic; but rather UI logic.

While it is possible to make these two tools work together, it is not a good idea.

@Lemmings19
Lemmings19 / behat-gherkin-laravel.md
Last active June 15, 2017 17:55
Behat & Gherkin Usage in Laravel

Preface

This is a summary of the knowledge I have gained after some research and first tests.

Behat is a tool for writing feature requirement criteria in Gherkin syntax, and integrating this criteria with PHP. In order to work with Behat (a tool) and Gherkin (a syntax or way of writing feature requirements), you will need to understand how to get Behat setup, the role it plays, and how to write using Gherkin.

Behat Setup

The following readme should work: https://github.com/Behat/Behat/blob/master/README.md For Laravel, the following video outlines the process:

@Lemmings19
Lemmings19 / hide-annoying-content.md
Last active October 23, 2017 09:02
Hide annoying content on thesaurus.com and dictionary.com

Looks like someone has spent too much time adding annoying crap to dictionary.com and thesaurus.com.

Remove it by doing the following:

  1. In Chrome install the Custom Javascript (cjs) extension: https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija/related?hl=en
  2. When on dictionary.com or thesaurus.com, click on the extension's icon in the top right of your browser. The icon reads: "cjs"
  3. Make sure the checkbox to enable cjs for this host is enabled.
  4. From the external scripts dropdown, select the newest version of jQuery.
  5. Paste the code in script.js (found on this page) into the textbox hit "save", and reload the page if necessary.
  6. All of that annoying shit should be gone now.
@Lemmings19
Lemmings19 / PasswordBroker.php
Created January 27, 2018 23:06 — forked from jamesfairhurst/PasswordBroker.php
Laravel 5.2 Queue Password Reset Email
<?php
namespace App;
use Illuminate\Auth\Passwords\PasswordBroker as IlluminatePasswordBroker;
class PasswordBroker extends IlluminatePasswordBroker
{
/**
* Send the password reset link via e-mail in a queue
@Lemmings19
Lemmings19 / README.md
Last active March 7, 2018 23:05 — forked from oodavid/README.md
Backup MySQL to Amazon S3

Backup MySQL to Amazon S3

This is a simple way to backup your MySQL tables to Amazon S3 for a nightly backup - this is all to be done on your server :-)

Sister Document - Restore MySQL from Amazon S3 - read that next

1 - Install s3cmd

this is for Centos 5.6, see http://s3tools.org/repositories for other systems like ubuntu etc