Skip to content

Instantly share code, notes, and snippets.

View joeswann's full-sized avatar

Joe Swann joeswann

View GitHub Profile
@joeswann
joeswann / countries.js
Created December 12, 2021 20:11
Country List w/ iso2
[
{iso: 'NZ',name: 'New Zealand', },
{iso: 'AU',name: 'Australia', },
{iso: 'US',name: 'United States', },
{iso: 'GB',name: 'United Kingdom', },
{iso: 'AF',name: 'Afghanistan', },
{iso: 'AX',name: 'Åland Islands', },
{iso: 'AL',name: 'Albania', },
{iso: 'DZ',name: 'Algeria', },
{iso: 'AS',name: 'American Samoa', },
@joeswann
joeswann / rails_engine_rename.sh
Last active June 14, 2018 03:29
[rails_engine_rename.sh]
# Note, works best if your engine name isn't reserved
# Rename in files
find ~/www/rails/engines/old_engine/ -type f | xargs sed -i s/Old/New/g
find ~/www/rails/engines/old_engine/ -type f | xargs sed -i s/old/new/g
# Remove -n to run command
find ~/www/rails/engines/old_engine -type f -name '*' -print0 | xargs -0 rename -n 's/(.*)old\.(.*)/$new\.$2/g';
@joeswann
joeswann / normalise.php
Last active June 14, 2018 00:44
[normalise_array.php] Normalise a nested array
function formatOptionGroups($raw_option_groups) {
//Normalise everything
$return = [
'option_groups' => [],
'option_types' => [],
'option_values' => [],
'option_prices' => [],
];
//Foreach Group (eg Size/Simple Prong)
@joeswann
joeswann / VendBase.php
Last active June 14, 2018 00:52
[oauth2.php] Oauth 2 example
<?php
namespace JoeSwann;
class VendBase {
public function __construct(&$app, $settings = array()) {
$this->app = $app;
$this->settings = $settings;
$this->db = $this->app['db'];
<?php
namespace Joeswann;
class NuorderConnector {
public $oauth_consumer_key;
public $oauth_consumer_secret;
public $endpoint;
public $oauth_verifier;
public $oauth_token;
@joeswann
joeswann / mailchimp.html
Last active June 14, 2018 00:49
[mailchimp.js] Mailchimp ajax
<form class="newsletter" action="https://example.us2.list-manage.com/subscribe/post-json?u=xxxxxxx&id=xxxxxxxx&c=?" method="get" >
<div class="close"></div>
<div class="success">
Thankyou for signing up!
</div>
<div class="error">
Please check your email address is correct.
</div>
<input name="NAME" type="text" placeholder="Full Name" />
<input name="EMAIL" type="text" placeholder="Email Address" />
@joeswann
joeswann / campaignmonitor.html
Last active June 14, 2018 01:00
[campaignmonitor.js] Campaign monitor ajax
<form class="form-newsletter" action="http://xxxx.createsend.com/t/d/s/xxxx/" method="post" >
<h3>Newsletter</h3>
<div class="success">
Thankyou for signing up!
</div>
<div class="error">
Please check your email address is correct.
</div>
<input name="cm-xxxx-xxxx" type="email" placeholder="Email Address" required />
<button type="submit" value="Sign Up" name="submit">Sign Up</button>
@joeswann
joeswann / ffmpeg_gif_from_jpg.sh
Last active June 14, 2018 00:57
[ffmpeg_gif_from_jpg.sh] Create a smooth gif using ffmpeg
convert -dispose none -delay 1.5 *.jpg -coalesce a.gif
@joeswann
joeswann / rails_reset.sh
Last active June 14, 2018 00:56
[rails_reset.sh] Reset tables, precompile assets, etc
rake db:drop;rake db:create; rake db:migrate; rake db:seed;
bundle exec rake assets:precompile RAILS_ENV=production
@joeswann
joeswann / problems-with-shopify.md
Last active August 29, 2015 13:57
Issues I have with shopify
  • Shopify fees + cut + paypal cut + plugin fees can add up
  • Preset image sizes without good cropping options
  • No advanced functionality easily possible, eg facebook login, update news feeds, etc
  • No advanced data for anything (eg extra product info), best alternative is to host data on a separate server
  • Extremely basic blog functionality
  • Limiting results only works some of the time, eg can't do for product in collection limit = 5
  • Website settings in admin is only HTML, meaning nothing advanced can be done here
  • No good way to add extra listings, like events, stockists, job listings etc
  • No nice way to do post type linking, eg linking products to articles or products to stockists
  • No nice way to do advanced ajax (eg filtered infinite scroll on blog posts)