Skip to content

Instantly share code, notes, and snippets.

View gbrits's full-sized avatar
🤘
Working on something, always.

Grant gbrits

🤘
Working on something, always.
View GitHub Profile
@gbrits
gbrits / check-country.liquid
Created December 1, 2021 17:08
Country-specific notice (Shopify)
{% if template == 'index' %}
fetch('https://api.ipregistry.co/?key=tryout')
.then(function (response) {
return response.json();
})
.then(function (payload) {
if('Australia' == payload.location.country.name){
$('#international-notice').show();
}
});
@gbrits
gbrits / maximus_articles_capacitor_2_downgrade.md
Last active February 9, 2022 11:12
Downgrading from Capacitor 3 to Capacitor 2 (for whatever reason)

Step 1.) Delete your iOS, Android & Node modules folder

rm -rf android && rm -rf ios && rm -rf node_modules

Step 2.) Adjust your package.json to include the following:

"@capacitor/android": "^2.4.5",
@gbrits
gbrits / gravityforms_field_labels.php
Last active March 17, 2022 03:34
Replace Entry Keys w/ Admin Labels (GravityForms Webhook Add-on)
<?php
add_filter('gform_webhooks_request_data', function ($request_data, $feed, $entry, $form) {
if (rgars($feed, 'meta/requestBodyType') === 'all_fields') {
foreach ($form['fields'] as $item) {
if ($item->adminLabel != '') {
if (isset($item->inputs) && is_array($item->inputs)) {
if ($item['type'] == 'time') {
foreach ($item->inputs as $key => $input) {
if (isset($entry[floor($input['id'])])) {
if (!is_null($entry[floor($input['id'])])) {
@gbrits
gbrits / laravel-cheat-sheet.php
Last active May 10, 2022 08:21
Laravel Cheat Sheet
// Restricting a model's scope, for tenancy
protected static function boot()
{
parent::boot();
self::addGlobalScope(function(Builder $builder) {
$builder->where('team_id', auth()->user()->current_team_id);
});
}