Skip to content

Instantly share code, notes, and snippets.

@kvn1234
kvn1234 / state_names.txt
Last active November 2, 2021 18:58 — forked from norcal82/state_names.txt
plain text of US state names
// https://gist.github.com/dblandin/2991970
Alabama
Alaska
American Samoa
Arizona
Arkansas
California
Colorado
Connecticut
@kvn1234
kvn1234 / Validator.php
Created July 28, 2019 02:06 — forked from waleedrehmankhan/Validator.php
Custom Laravel Alphanumeric Validator that allow spaces
Paste this Code in Validator.php
public function validateAlphaSpaces($attribute, $value, $params)
{
return preg_match('/^[\pL\s]+$/u', $value);
}
Create Custom Message some where at bottom in Validation.php
/*
the reported geolocation info of a domain URL fast with this quick #oneliner:
curl -s ipinfo​.io/`dig +short example​.com` | tr -d '",{}'
@kvn1234
kvn1234 / Form regex
Created January 25, 2019 01:59
Regex I seem to need a lot
(\ autocomplete\=\")([a-z\-0-9\_\"]+)
@kvn1234
kvn1234 / gist:b58aebe6ec3e6b66f84cec426667fe03
Created January 23, 2019 03:43
Summernote Bootstrap 4 placeholder not working
Add custom s/css like:
.note-placeholder {
display: block; //somehow it's display:none in the summernot bs4.css
}
because in the summernote bs4 css it's set to `display: none` for some f@cking reason
@kvn1234
kvn1234 / gist:fe76665ce6aa6b31563f6233287b6d2e
Created January 22, 2019 12:01
Show/hide password field with Jquery simplified
$('.reveal').on('click', function() {
var reveal = '.' + $(this).attr('id'), // reveal's id *should* be to-be-revealed's class
type = $(reveal).attr('type') === 'password' ? 'text' : 'password';
$(reveal).attr('type', type);
});
@kvn1234
kvn1234 / gist:16c31778d473e705cb8fb9b43851622b
Last active January 22, 2019 02:47
Laravel RegEx for updating a form to show both old values while editing a form
(value\=\"\{\{\ old\(\')([a-z\-\_]+)(\')(\)\ \}\}\")
usage: $1$2$3\,\ \$variableObject\->$2$4
works as long as:
$2 is the same key as the column name (or whatever is in the object coming back)
see https://regex101.com/r/DfQngW/1
@kvn1234
kvn1234 / timezones_array.php
Created December 22, 2018 14:37 — forked from pavellauko/timezones_array.php
Time zones as arrays (PHP)
<?php
$timezones = array(
'America/Adak' => '(GMT-10:00) America/Adak (Hawaii-Aleutian Standard Time)',
'America/Atka' => '(GMT-10:00) America/Atka (Hawaii-Aleutian Standard Time)',
'America/Anchorage' => '(GMT-9:00) America/Anchorage (Alaska Standard Time)',
'America/Juneau' => '(GMT-9:00) America/Juneau (Alaska Standard Time)',
'America/Nome' => '(GMT-9:00) America/Nome (Alaska Standard Time)',
'America/Yakutat' => '(GMT-9:00) America/Yakutat (Alaska Standard Time)',
'America/Dawson' => '(GMT-8:00) America/Dawson (Pacific Standard Time)',
@kvn1234
kvn1234 / swapassignment regex
Created December 22, 2018 00:34
The swap assignment function PHPStorm should have but doesn't
(\s*)([^=^\s]*)\s*=\s*(.*);
$1$3 = $2;
@kvn1234
kvn1234 / foreign_keys
Created August 10, 2018 17:15
Find foreign keys from information_schema
SELECT * FROM KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME = 'table_name' AND REFERENCED_COLUMN_NAME = 'id'