Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
Working on something, always.

Grant Brits gbrits

🤘
Working on something, always.
View GitHub Profile
@gbrits
gbrits / toHHMMSS.js
Created Mar 16, 2021
Seconds to hh mm ss
View toHHMMSS.js
toHHMMSS(secs: number) {
var sec_num = parseInt(Math.abs(secs), 10);
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {hours = "0"+hours;}
if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
if(hours > 0) {
return hours+'h '+minutes+'m '+seconds+'s';
@gbrits
gbrits / kelvin_to_celsius.js
Created Oct 15, 2020
Kelvin to Celsius (Javascript)
View kelvin_to_celsius.js
let kelvin = 288; // Or whatever kelvin
let celsius = ((5/9) * ((Math.floor((Number(kelvin)-273) * (9/5) + 32))-32)).toFixed(0)
@gbrits
gbrits / team.liquid
Created Jun 30, 2020
Sorted Iteration by Index
View team.liquid
{% assign first_block = content | split: '[team_portfolios]' | first %}
{% assign last_block = content | split: '[team_portfolios]' | last %}
{{ first_block }}
<div class="main-grid-team">
<h1 id="team">Our Team</h1>
<div class="expose-row">
@gbrits
gbrits / get-vars.liquid
Created Apr 14, 2020
Shopify $_GET variables via Liquid
View get-vars.liquid
<!-- Add this at the top of your page template -->
{%- capture contentForQuerystring -%}{{ content_for_header }}{%- endcapture -%}
{%- assign pageUrl = contentForQuerystring | split:'"pageurl":"' | last | split:'"' | first | split:'.myshopify.com' | last |
replace:'\/','/' |
replace:'%20',' ' |
replace:'\u0026','&'
-%}
{%- unless pageUrl contains "?" -%}{% break %}{%- endunless -%}
{%- assign pageQuerystring = pageUrl | split:'?' | last -%}
@gbrits
gbrits / date-example.php
Created May 16, 2019
PHP Date with Superscript Ordinal Suffix
View date-example.php
<?php
echo date('j<\s\up>S</\s\up> M \'y'); // >= PHP 5.2.2 - 16th Feb '19
@gbrits
gbrits / Wordpress UA code (Analytics)
Created Jan 18, 2019
Using Functions.php to insert Google Analytics into a site's head
View Wordpress UA code (Analytics)
<?php
add_action( 'wp_head', 'mxms_google_analytics' );
function mxms_google_analytics() {
?><script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-0000000-0', 'auto');
ga('send', 'pageview');
@gbrits
gbrits / Sequential axios calls
Created Dec 9, 2018
How to retrieve from an API sequentially via AXIOS. Open to improvement.
View Sequential axios calls
function retrievePagesSequentially() {
var index = 1;
function request() {
return window.axios.get(`/api/cache/${index}`).then((response) => {
let dataSet = response.data.length;
jQuery('#headerTop').text(`${((index - 1) * 250) + dataSet} Orders`);
ShopifyApp.flashNotice(`Page ${index} retrieved...`);
index++;
if (dataSet < 250) {
setTimeout(() => {
@gbrits
gbrits / states.html
Last active May 22, 2018
Australian state select (Ionic framework)
View states.html
<ion-select [(ngModel)]="state">
<ion-option value="ACT">Australian Capital Territory</ion-option>
<ion-option value="NSW">New South Wales</ion-option>
<ion-option value="NT ">Northern Territory</ion-option>
<ion-option value="QLD">Queensland</ion-option>
<ion-option value="SA ">South Australia</ion-option>
<ion-option value="TAS">Tasmania</ion-option>
<ion-option value="VIC">Victoria</ion-option>
<ion-option value="WA ">Western Australia</ion-option>
</ion-select>
@gbrits
gbrits / cd-aws-s3-wercker.md
Last active Oct 15, 2015 — forked from NicolasRitouet/cd-aws-s3-wercker.md
Automate AWS S3 deployment with BitBucket (or Github) and Wercker
View cd-aws-s3-wercker.md

This tutorial explains how to deploy automatically from bitbucket (or github) to AWS S3.

Create a bitbucket repository (public or private).

Add this repo on Wercker

  • Go to Create Application
  • Select use bitbucket (or github)
  • Choose your repo
  • For the next questions, choose the default answers