Skip to content

Instantly share code, notes, and snippets.

View koryteg's full-sized avatar
🏠
Working from home

Kory Tegman koryteg

🏠
Working from home
View GitHub Profile
@fnky
fnky / hooks.js
Last active January 7, 2024 12:32
React Hooks: useReducer with actions and selectors (Redux-like)
function useSelectors(reducer, mapStateToSelectors) {
const [state] = reducer;
const selectors = useMemo(() => mapStateToSelectors(state), [state]);
return selectors;
}
function useActions(reducer, mapDispatchToActions) {
const [, dispatch] = reducer;
const actions = useMemo(() => mapDispatchToActions(dispatch), [dispatch]);
return actions;
@qutek
qutek / calculateStripeFee.js
Created February 3, 2018 06:20
[Calculate Stripe Fee] Calculate stripe fee to ask customer to cover stripe fee #javascript #stripe
/**
* Calculate stripe fee from amount
* so you can charge stripe fee to customers
* lafif <hello@lafif.me>
*/
var fees = {
USD: { Percent: 2.9, Fixed: 0.30 },
GBP: { Percent: 2.4, Fixed: 0.20 },
EUR: { Percent: 2.4, Fixed: 0.24 },
CAD: { Percent: 2.9, Fixed: 0.30 },
@ibraheem4
ibraheem4 / postgres-brew.md
Last active May 1, 2024 09:43 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@PurpleBooth
PurpleBooth / README-Template.md
Last active May 6, 2024 07:22
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kristianmandrup
kristianmandrup / Converting libraries to Ember CLI addons.md
Last active April 21, 2023 17:14
Guide to Developing Addons and Blueprints for Ember CLI

Converting libraries to Ember CLI addons

In this guide we will cover two main cases:

  • Ember specific library
  • vendor library

Ember library

The Ember library will assume that Ember has already ben loaded (higher in the loading order) and thus will assume it has access to the Ember API.

@clhenrick
clhenrick / README.md
Last active April 1, 2024 14:55
PostgreSQL & PostGIS cheatsheet (a work in progress)
@bryanlittlefield
bryanlittlefield / coupon-object.phtml
Created October 24, 2013 16:01
[MAGENTO] Get Coupon Object (Name,Description)
First Load Coupon Object
--------------------------
<?php $coupon = Mage::getModel('salesrule/coupon');
$coupon->load($this->getQuote()->getCouponCode(), 'code');
$couponObj = Mage::getModel('salesrule/rule')->load($coupon->getRuleId());
?>
Then Use the Following to get the Name or Description
-----------------------------------------------------
<?php echo $couponObj->getName(); ?>
@bryanlittlefield
bryanlittlefield / functions.php
Created October 9, 2013 18:55
[WORDPRESS] CleanUp Wordpress Dashboard Place the following in the functions.php file of your theme
// Clean Up Dashboard
add_action('admin_init', 'rw_remove_dashboard_widgets');
function rw_remove_dashboard_widgets() {
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); // recent comments
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal'); // incoming links
remove_meta_box('dashboard_plugins', 'dashboard', 'normal'); // plugins
remove_meta_box('dashboard_quick_press', 'dashboard', 'normal'); // quick press
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'normal'); // recent drafts
@bryanlittlefield
bryanlittlefield / getprice.phtml
Created May 14, 2013 18:56
[MAGENTO] Get Prices/Formatting
<?php
//get product price snippet
echo $this->getPriceHtml($_product, true);
//get $_product price
echo $_product->getPrice();
echo number_format($_product->getPrice(), '2', '.', ',');
//get $_product special price
@bryanlittlefield
bryanlittlefield / urls.phtml
Last active December 17, 2015 02:09
[MAGENTO] Global URL's
<?php echo $this->getSkinUrl('images/image.gif');?> => Current Theme Skin URL
<?php echo $this->getUrl('url-here');?> => Current Theme Base URL
<!-- ===================================================================== -->
Mage::getBaseUrl() => Gets base url path e.g. http://my.website.com/
Mage::getBaseUrl('media') => Gets MEDIA folder path e.g. http://my.website.com/media/