Skip to content

Instantly share code, notes, and snippets.

View ajmalafif's full-sized avatar
💻

Ajmal Afif ajmalafif

💻
View GitHub Profile
@bgreenlee
bgreenlee / report.rb
Created March 1, 2009 06:01
Displays a mysql-style report for an array of ActiveRecord objects. Stick it in your .irbrc.
# mysql-style output for an array of ActiveRecord objects
#
# Usage:
# report(records) # displays report with all fields
# report(records, :field1, :field2, ...) # displays report with given fields
#
# Example:
# >> report(records, :id, :amount, :created_at)
# +------+-----------+--------------------------------+
# | id | amount | created_at |
@ma11hew28
ma11hew28 / .bash_profile
Last active September 4, 2015 20:34
.bash_profile file
# Homebrew, Ruby, Bash Completion
# After upgrading Ruby, run: gem pristine --all --only-executables
export PATH="/usr/local/bin:/usr/local/opt/ruby/bin:$PATH"
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Directory Shortcuts
alias prj='cd "$HOME/Projects/"'
@mislav
mislav / pagination.md
Created October 12, 2010 17:20
"Pagination 101" by Faruk Ateş

Pagination 101

Article by Faruk Ateş, [originally on KuraFire.net][original] which is currently down

One of the most commonly overlooked and under-refined elements of a website is its pagination controls. In many cases, these are treated as an afterthought. I rarely come across a website that has decent pagination, and it always makes me wonder why so few manage to get it right. After all, I'd say that pagination is pretty easy to get right. Alas, that doesn't seem the case, so after encouragement from Chris Messina on Flickr I decided to write my Pagination 101, hopefully it'll give you some clues as to what makes good pagination.

Before going into analyzing good and bad pagination, I want to explain just what I consider to be pagination: Pagination is any kind of control system that lets the user browse through pages of search results, archives, or any other kind of continued content. Search results are the o

@carolineschnapp
carolineschnapp / settings.html
Last active January 19, 2023 13:01
Additional settings for multiple currencies support
<fieldset>
<legend>Money options</legend>
<table>
<tr>
<td><label for="show_multiple_currencies">Show currency selector?</label></td>
<td><input type="checkbox" id="show_multiple_currencies" name="show_multiple_currencies" checked="checked" /></td>
</tr>
<tr>
<td colspan="2"><small>Although you will be able to display prices on your store front in different currencies, Shopify will still process orders in your shop's currency.</small></td>
</tr>
@carolineschnapp
carolineschnapp / currencies.liquid
Last active May 2, 2024 15:47
currencies.liquid
{% if settings.show_multiple_currencies %}
{{ "//cdn.shopify.com/s/javascripts/currencies.js" | script_tag }}
{{ "jquery.currencies.min.js" | asset_url | script_tag }}
<script>
Currency.format = '{{ settings.currency_format | default: 'money_with_currency_format' }}';
var shopCurrency = '{{ shop.currency }}';
@carolineschnapp
carolineschnapp / gist:773649
Last active August 21, 2019 13:17
currency-picker.liquid
<label class="currency-picker__wrapper">
<span class="currency-picker__label">Pick a currency</span>
<select class="currency-picker" name="currencies" style="display: inline; width: auto; vertical-align: inherit;">
{% assign codes = 'USD,EUR,GBP,CAD,ARS,AUD,BBD,BDT,BSD,BHD,BRL,BOB,BND,BGN,ILS,MMK,KYD,CLP,CNY,COP,CRC,HRK,CZK,DKK,DOP,XCD,EGP,XPF,FJD,GHS,GTQ,GYD,GEL,HKD,HUF,ISK,INR,IDR,NIS,JMD,JPY,JOD,KZT,KES,KWD,LVL,LTL,MXN,MYR,MUR,MDL,MAD,MNT,MZN,ANG,NZD,NGN,NOK,OMR,PKR,PYG,PEN,PHP,PLN,QAR,RON,RUB,SAR,RSD,SCR,SGD,SYP,ZAR,KRW,LKR,SEK,CHF,TWD,THB,TZS,TTD,TRY,UAH,AED,UYU,VEB,VND,ZMK' | split: ',' %}
{% assign supported_codes = settings.supported_currencies | split: ' ' %}
<option value="{{ shop.currency }}" selected="selected">{{ shop.currency }}</option>
{% for code in supported_codes %}
{% if code != shop.currency and codes contains code %}
<option value="{{ code }}">{{ code }}</option>
{% endif %}
@elivz
elivz / wordpress-w3tc-site.conf
Created March 20, 2011 18:06
Nginx configuration for WordPress with W3 Total Cache plugin. See http://elivz.com/blog/single/wordpress_with_w3tc_on_nginx/
server {
# Redirect yoursite.com to www.yoursite.com
server_name yoursite.com;
rewrite ^(.*) http://www.yoursite.com$1 permanent;
}
server {
# Tell nginx to handle requests for the www.yoursite.com domain
server_name www.yoursite.com;
@burin
burin / each_with_index.coffee
Created June 27, 2011 14:33
each_with_index handlebars helper, adds an {{index}} prop accessible from within the block
Handlebars.registerHelper 'each_with_index', (array, fn) ->
buffer = ''
for i in array
item = i
item.index = _i
buffer += fn(item)
buffer
<script>
// (c) Copyright 2016 Caroline Schnapp. All Rights Reserved. Contact: mllegeorgesand@gmail.com
// See https://docs.shopify.com/themes/customization/navigation/link-product-options-in-menus
var Shopify = Shopify || {};
Shopify.optionsMap = {};
Shopify.updateOptionsInSelector = function(selectorIndex) {
@defunkt
defunkt / gitio
Created September 11, 2011 08:11
Turn a github.com URL into a git.io URL.
#!/usr/bin/env ruby
# Usage: gitio URL [CODE]
#
# Turns a github.com URL
# into a git.io URL
#
# Copies the git.io URL to your clipboard.
url = ARGV[0]
code = ARGV[1]