Skip to content

Instantly share code, notes, and snippets.

View ephbaum's full-sized avatar

Eph Baum ephbaum

View GitHub Profile
@ephbaum
ephbaum / find-duplicate-lines-and-delete-vim.md
Last active June 23, 2023 05:32
A vim command that will take a list in a buffer and find & remove 1 (or more) duplicate lines (instead of using `:sort u`
:g/^\(.*\)\n\1$/d
  • :g: The global (g) command in Vim, performs a certain action on lines that match a given pattern.
  • /^: This symbol denotes the start of a line.
  • \( and \): These parentheses are used for grouping in regex. Everything between \( and \) is treated as a single group. This group can be referenced later.
  • .*: The dot (.) stands for any character except a newline. The asterisk (*) is a quantifier, meaning "zero or more of the preceding element". So, .* matches any string, including an empty string.
  • \n: This represents a newline character.
  • \1: This is a backreference to the first (and only) group that we defined earlier. In this case, it refers to the exact string that was matched inside the \( and \).
  • $: This symbol denotes the end of a line.
@ephbaum
ephbaum / Animals.txt
Created April 17, 2023 05:03
A large list of animals
Aardvark
Abyssinian
Adelie Penguin
Affenpinscher
Afghan Hound
African Bush Elephant
African Civet
African Clawed Frog
African Forest Elephant
African Palm Civet
@ephbaum
ephbaum / laravelsail.md
Created July 16, 2022 03:52
Laravel Sail - Install Existing Project

So you have you a little Laravel Repo and you want to use Sail. It was probably so easy to set up in the first place, but how in the hell are you planning to get this thing installed now?

You could use the composer/composer container to install composer dependencies, or you can use the laravelsail/php81-composer

docker run --rm -u "$(id -u):$(id -g)" -v $(pwd):/opt -w /opt laravelsail/php81-composer:latest composer install --ignore-platform-reqs

docker run --rm
-u "$(id -u):$(id -g)"
-v $(pwd):/opt
-w /opt \

@ephbaum
ephbaum / nationalities.php
Created September 27, 2016 00:25 — forked from zspine/nationalities.php
PHP Nationalities Array
$nationals = array(
'Afghan',
'Albanian',
'Algerian',
'American',
'Andorran',
'Angolan',
'Antiguans',
'Argentinean',
'Armenian',
@ephbaum
ephbaum / PHP Countries Array
Created September 27, 2016 00:25 — forked from DHS/PHP Countries Array
PHP array of all country names
<?php
$countries = array("Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Island
/**
* Resursively flattens an Array of depth n
*
* @param aSrc Array to be flattened
* @returns Array Single depth array
*/
var flatten = function(aSrc) {
if (Array.isArray(aSrc) && aSrc.length > 0) { // Test that paramater is both array and non-zero length
var head = aSrc[0], // Get first element from paramater
@ephbaum
ephbaum / click-click-click.js
Created May 5, 2015 19:49
click click click
// test a
var $testContainer = $('.test-container'), elem = $( '<p class="test_jquery_click">Test Elem</p>' ), counterArray = [];
$testContainer.text('');
for (var i = 50; i >= 0; i--) { $testContainer.append( elem ); }
$('p.test').click( function(e) { counterArray.push($(this)); });
$('.test-container > p.test_jquery_click').each(function() {$(this).click();});
console.dir( $testContainer );
//test b
var $testContainer = $('.test-container'), elem = $( '<p class="test_jquery_trigger" onclick="$(this).trigger(\'test-click\');">Test Elem</p>' ), counterArray = [];
@ephbaum
ephbaum / complexRFX2822EmailRegExp.js
Last active August 29, 2015 14:16
complexRFX2822EmailRegExp.js
var complexRFX2822EmailRegExp = /(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/;
if ( ____placeholder____.match( complexRFX2822EmailRegExp ) === null ) { return false; }
// see data @link https://regex101.com/r/oJ8nO1/1
@ephbaum
ephbaum / simpleRFC2822EmailRegExp.js
Last active August 29, 2015 14:16
simpleRFC2822EmailRegExp
var simpleRFC2822EmailRegExp = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
if ( ____placeholder____.match( complexRFX2822EmailRegExp ) === null ) { return false; }
// see data @link https://regex101.com/r/uU1fI9/1
@ephbaum
ephbaum / typicalValidEmailFormatRegExp.js
Last active August 29, 2015 14:16
typicalValidEmailFormatRegExp
var typicalValidEmailFormatRegExp = /(^[\S]+@[\S]+\.[\S]{2,63}$)/; // @fskirschbaum || My RegExp could beat up your RegExp. Fight Me. || Says, essentialy, a bunch of characters, an @ symbol, a bunch more characters, a single dot, ends with a group of characters between 2 and 63 (the allowed min/max size of valid .tld ). Allows a hefty chunk of expected valid email addresses, disallows most typical user error type input of invalid email address. boom.
if ( ___VAR___.match( typicalValidEmailFormatRegExp ) === null ) { return false; }
// see example here: @link https://regex101.com/r/vD9zK7/4