Skip to content

Instantly share code, notes, and snippets.

View htmelvis's full-sized avatar
🕸️

Ed Wieczorek htmelvis

🕸️
View GitHub Profile
@htmelvis
htmelvis / Foxy Shipping International
Last active August 29, 2015 14:22
Shipping snippet for FoxyCart 2.0 International Shipping calculation. Currently not complete just has the conditional for GB and US. Twig templating language with JavaScript.
{% if context == 'cart' or context == 'checkout' %}
<script type="text/javascript" charset="utf-8">
(function (FC, $) {
FC.customFlatRates = {};
FC.customFlatRates.shipping_results = [];
FC.customFlatRates.config = {
'autoSelect': false /* Set to true if you'd like the top shipping option to be automatically selected for the user */
};
@htmelvis
htmelvis / gist:309ed2fcdf23d087f846
Created July 5, 2015 13:03
Simple ROT13 Cypher for JS
var Decipher = function(text, rot){
var lookup = ["a","b","c","d","e","f","g","h","i","j",
"k", "l", "m", "n", "o", "p", "q", "r",
"s", "t", "u", "v", "w", "x", "y", "z"];
//clone the original lookup table to make a new one
var newLookup = lookup.slice(0);
//This is the offset to go off of
var offset = rot;
//split the message into characters to check against table but lowercase all chars first
@htmelvis
htmelvis / materialshadows.scss
Created September 30, 2015 12:32
Sass Functions and Mixins for Material Design Style Shadows
@mixin card($depth) {
@if $depth < 1 {
box-shadow: none;
} @else if $depth > 5 {
@warn "Invalid $depth `#{$depth}` for mixin `card`.";
} @else {
box-shadow: bottom-shadow($depth), top-shadow($depth);
}
}
/// Computes a top-shadow for a card effect.
@htmelvis
htmelvis / gist:c0cef083ecc536473b4c
Created January 7, 2016 21:12
Whatsup: Alias for checking running port processes
# Check what server processes are currently running on a given port
function _checkForRunningServer(){
echo "Currently checking port: $1"
lsof -wni tcp\:$1;
#would like to expand to pass arg to kill said server ps
}
#register the alias in your .bashrc or .zshrc
alias whatsup=_checkForRunningServer
@htmelvis
htmelvis / iterator.js
Created February 15, 2016 13:45
Timed Iteration in JavaScript
(function() {
var i = 0,
adArray = [13,14,15,16,17,18,19,110,111,112,113,114,115,116],
l = adArray.length;
(function iterator() {
console.log('Loop: ', i, ' Loop content: ', adArray[i]);
//update before evaluating the conditional
if (++i < l) {
setTimeout(iterator, 1500);
{% if context == 'cart' or context == 'checkout' %}
<script type="text/javascript" charset="utf-8">
(function (FC, $) {
//Set the text of the newsletter subscribe button
FC.json.config.lang.checkout_newsletter_subscribe = "Don’t get left out! Stay up to date on our latest products and promotions.";
//set the default checked method to checked on the checkbox for subscribe
FC.customFlatRates = {};
@htmelvis
htmelvis / selectText.js
Created November 30, 2016 20:24
Select Text From Div on Click (jQuery)
function selectText(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
}
@htmelvis
htmelvis / package.json
Created November 14, 2017 18:39
NODE, JEST, REACT, WEBPACK PACKAGE.JSON EXAMPLE
{
"name": "Example",
"version": "1.0.0",
"description": "This is an example of a complex app using Jest",
"main": "index.js",
"scripts": {
"start": "npm-run-all --parallel watch:server watch:build",
"watch:build": "webpack -d --watch --progress --colors",
"watch:server": "nodemon \"server/server.js\" --watch \"./server\"",
"test": "jest",

Keybase proof

I hereby claim:

  • I am htmelvis on github.
  • I am htmelvis (https://keybase.io/htmelvis) on keybase.
  • I have a public key ASAV6FrNQK0Zl0R1gMHIHD4IWYCaam194OtilTajxec2Ego

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am htmelvis on github.
  • I am edbmt (https://keybase.io/edbmt) on keybase.
  • I have a public key ASDYH-eq0PAGeH2fznBggNYRrcFiYAUrhlka-Dp5IArytAo

To claim this, I am signing this object: