Skip to content

Instantly share code, notes, and snippets.

View u01jmg3's full-sized avatar
🔷
Coding Hard

Jonathan Goode u01jmg3

🔷
Coding Hard
View GitHub Profile
@u01jmg3
u01jmg3 / shadows.scss
Last active April 14, 2019 11:52
Box Shadows
// https://next.tailwindcss.com/docs/box-shadow/
.shadow { box-shadow: 0 1px 3px 0 rgba(0, 0, 0, .1), 0 1px 2px 0 rgba(0, 0, 0, .06) }
.shadow-md { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06) }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -2px rgba(0, 0, 0, .05) }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 10px 10px -5px rgba(0, 0, 0, .04) }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .25) }
@u01jmg3
u01jmg3 / image.bat
Last active March 27, 2019 15:33
Image conversion
for %I in (*.svg) do convert -density 1536 -background none "%I" ( -clone 0 -background #989898 -shadow 80x3+5+5 ) -reverse -background none -resize 120x120 -gravity center -extent 192x192 -layers merge +repage "%~nI.png"
for %I in (*.svg) do outline-stroke "%I" -o "%I"
for %I in (*.svg) do svgo "%I"
@u01jmg3
u01jmg3 / unique-identifiers.php
Created December 29, 2018 15:30
Firebase push algorithm in PHP (firebase.com/blog/2015-02-11-firebase-unique-identifiers.html)
<?php
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
@u01jmg3
u01jmg3 / fix-dictionaries.bat
Last active March 16, 2018 09:33
Fix dictionaries (SourceTree bug)
@echo off
set regPath="HKEY_CURRENT_USER\Software\Microsoft\Spelling\Dictionaries"
set regName="_Global_"
set truncate=true
if "%truncate%"=="true" (
reg ADD %regPath% /t REG_MULTI_SZ /v %regName% /d "C:\Users\%USERNAME%\AppData\Roaming\Microsoft\Office\16.0\be70806f\Proofing\RoamingCustom.dic" /f
) else (
for /f "tokens=2*" %%a in ('REG QUERY %regPath% /v %regName%') do set "regData=%%~b"
@u01jmg3
u01jmg3 / create-app-icons.bat
Last active June 1, 2019 09:19
ImageMagick + Pingo
@echo off
cls
echo Creating 51 app icons, please wait.
im-convert ../../src/assets/images/app-logo-no-gradient.png ^
( -clone 0 -resize 2048x1536 -background #1f3165 -gravity center -extent 2048x1536 -write ../../platforms/ios/Assess/Images.xcassets/LaunchImage.launchimage/Default-Landscape@2x~ipad.png ) ^
( -clone 0 -resize 2048x1536 -background #1f3165 -gravity center -extent 2048x1536 -write ../screen/ios/screen-ipad-landscape@2x.png ) ^
( -clone 0 -resize 1536x2048 -background #1f3165 -gravity center -extent 1536x2048 -write ../../platforms/ios/Assess/Images.xcassets/LaunchImage.launchimage/Default-Portrait@2x~ipad.png ) ^
@u01jmg3
u01jmg3 / .gitconfig
Last active August 19, 2019 17:07
Sourcetree Custom Actions
[alias]
cordova = "!f(){ MESSAGE=\"Build assets for deployment\"; [ \"$(git log -1 HEAD --pretty=format:%s)\" != \"$MESSAGE\" ] && git allclean && cordova prepare --release && git add -A && git commit -m \"$MESSAGE\" && git push || echo \"Commit already present\"; }; f"
fetch-pr = "!f(){ git fetch origin refs/pull/$1/head:pr/$1; }; f"
cleanup = !git clean -df
quick-clean = !git checkout . & git cleanup
all-clean = !git reset --hard && git cleanup
swap-last = !git tag _invert && git reset --hard HEAD~2 && git cherry-pick _invert _invert~1 && git tag -d _invert
invert-index = !git commit -m tmp1 && git add -A && git commit -m tmp2 && git swap-last && git reset HEAD~1 && git reset HEAD~1 --soft
@u01jmg3
u01jmg3 / stripe.md
Created February 27, 2018 22:14
Modify style of 'Pay with Card' Stripe button using Bootstrap Sass
  • Original Stripe button

stripe

  • With Bootstrap 3 styles applied

bootstrap

@u01jmg3
u01jmg3 / merge.js
Created June 26, 2017 20:28
Recursively merge properties and return a new object
/**
* Recursively merge properties
* and return a new object
* `merge(a, b[, ...])`
*
* @return object
*/
function merge() {
var dst = {},
src,
@u01jmg3
u01jmg3 / path.php
Created June 10, 2017 11:20
Generate an absolute or relative path based on the location of the current file
<?php
// Absolute
$path = current(preg_split('@(?<=public)@', getcwd()));
require_once "{$path}\includes\config.inc.php";
// Relative
$path = preg_split('/public/', getcwd());
$path = explode(DIRECTORY_SEPARATOR, trim(end($path), DIRECTORY_SEPARATOR));
require_once str_repeat('../', count($path)) . 'includes/config.inc.php';
  • Exclude dirs: .git|node_modules|vendor|storage|framework7|laravel-framework|cache|database|third_party|wedding
  • File Names match: *.ahk|*env*|*.js|*.md|*.php*|*css|*.xml|*.html|*.json|artisan|*.vue|*config|*access|*.bat|*.yml|*.ics|*.csv|*.xml|*.log|-*lock.*|*.svg|*.yaml|*.ini|*.tpl