Skip to content

Instantly share code, notes, and snippets.

View jarretgabel's full-sized avatar
💭
run() { }

Jarret Gabel jarretgabel

💭
run() { }
View GitHub Profile
@jarretgabel
jarretgabel / sticky item
Created April 25, 2019 13:54
quick sticky method
/**
* Set sticky
*/
setSticky() {
if(!this.item) return;
const bounds = this.item.getBoundingClientRect();
const boundsTop = bounds.top < 0 ? bounds.top : 0;
const boundsBottom = bounds.bottom < this.screen.height ? bounds.bottom : 0;
let apples = document.querySelectorAll(".apple");
let oranges = document.querySelectorAll(".orange");
let fruit = { apples: apples, oranges:oranges };
// same as
let fruit = { apples, oranges };
console.log(fruit.apples) // NodeList
console.log(fruit.orange.length) // Number
@jarretgabel
jarretgabel / createSVG
Last active January 9, 2018 00:47
method i use to create svgs dyamically
createSVG(opts) {
let svg = document.createElementNS("http://www.w3.org/2000/svg", opts.type);
if(opts.type === "text") {
let anchor = "middle";
if(opts.anchor) {
anchor = opts.anchor;
}
let alignment = "auto";
if(opts.alignment) {
alignment = opts.alignment;
@jarretgabel
jarretgabel / spree_checkout_api_payment_amount_issue.md
Last active August 29, 2015 14:08
Spree Checkout API "payment amount" issue

I'm having a problem with the spree checkout api, specifically the "payment" state. The "amount" property, equal to my order total, that's being passed into the API is cleared out so when the API creates a new payment for that order, the total isn't translated into the new payment.

I noticed some stuff in the Checkout.rb update_params_payment_source method but i can't track down why that "amount" property isn't being transfered when it rebuilds the payment. Here are screenshot references of my issue

Notice the "amount" property in the first payment object "0.0". It *should be the value of the order like "25.00"

API request to transition from checkout state "payment" to "confirm"

http://cl.ly/image/3Z3o3n1L050v

API response after transition from checkout state "payment" to "confirm"
@jarretgabel
jarretgabel / mobile-redirection-htaccess
Created February 18, 2014 20:36
htaccess mobile redirect
RewriteEngine On
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]

Animated Hamburger - Spin

Construct a hamburger button with minimal markup and animate the interactions.

A Pen by Caley Jack on CodePen.

License.

@jarretgabel
jarretgabel / QuotationWrapperByLine
Created June 6, 2012 22:48
Takes a txt file with a list and adds quotes before and after each line with a comma seperator
#!/bin/bash
echo -n "Enter target filename and press [ENTER]: "
read target
echo -n "Enter destination filename and press [ENTER]: "
read destination
touch $destination
echo -e "" > $destination