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 / prompt.sh
Last active January 9, 2022 23:05
Working Linux Terminal Prompt
# Example Prompt using this gist:
# 2022-01-09 23:00:50 user@host: ~/my-folder $
# Sets the scheme for the terminal prompt. Note that '##m' constitutes a colour code.
# Avoids several bugs, including the terminal input line-wrapping over the prompt.
# Includes the full date and time.
# In Ubuntu, add this to '~/.bashrc', then run 'source ~/.bashrc' and start a new terminal
# to apply the new prompt.
PS1='\D{%F %T} \[\033[01;32m\]\u\[\033[00m\]@\[\033[01;36m\]\h\[\033[00m\]: \[\033[01;34m\]\w\[\033[00m\] $ '
@Lemmings19
Lemmings19 / readme.md
Last active June 20, 2019 09:03
Set up Laravel 5.4 in an Ubuntu VM on Windows

To setup Laravel inside an Ubuntu virtual machine on Windows

Tested on Windows 10. Probably works in 7 and 8. I wrote this after I went through all of it, so let me know if I forgot a step.

In this guide:

  • VirtualBox (allows you to run a Linux operating system such as Ubuntu while you are running Windows)
  • Ubuntu 16.04 64 (a user friendly Linux installation that will be supported for many years)
  • LAMP stack (Linux, Apache, MySQL, PHP - all of the things that you will run your web application on)
  • Composer (this just manages your PHP dependencies, such as Laravel)
@Lemmings19
Lemmings19 / readme.md
Created February 12, 2017 06:36
How to share a folder between Ubuntu inside VirtualBox (the guest) and Windows (the host)

For example:

I have a folder on my Windows installation named C:/shared_stuff.

I have Ubuntu running inside VirtualBox on my Windows installation.

I want to access that folder inside Ubuntu under the path /mnt/shared_stuff (this could be anything you like; it doesn't have to match the name of the folder in Windows).

  • Inside settings for the VM, go to Shared Folders.
  • Add a Machine Folder (or check Make Permanent).
@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 / LaravelRecursiveBlade.php
Last active October 15, 2022 09:59
How to create a recursive list in a Blade. (Laravel)
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class TestController extends Controller
{
/**
* This is just a quick example of how to create a recursive list of items
@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 / blackfire-osx-mamp-readme.md
Created April 13, 2017 22:41
Blackfire OSX MAMP setup:
@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 / 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");
});