Skip to content

Instantly share code, notes, and snippets.

View richpeck's full-sized avatar

Richard Peck richpeck

  • Frontline Utilities LTD | Software Development & Visual Design
  • United Kingdom
View GitHub Profile
@wojtha
wojtha / Locales.yaml
Created January 15, 2014 10:13 — forked from s-andringa/Locales.yml
config.exceptions_app and ExceptionController
# config/locales/en.yml
en:
exception:
show:
not_found:
title: "Not Found"
description: "The page you were looking for does not exists."
internal_server_error:
title: "Internal Server Error"
module ApplicationHelper
# get the name of the current layout in views
# http://stackoverflow.com/a/9438314/2535178
def current_layout
layout = controller.send(:_layout)
if layout.instance_of? String
layout
else
File.basename(layout.identifier).split('.').first
end
@kevinhughes27
kevinhughes27 / product_update
Created April 3, 2014 16:20
update shopify product inventory with the API
I start by getting the product data from Shopify for the product in question, you might already have this data in your database. Using the Shopify API gem for ruby this looks like:
ruby > product = ShopifyAPI::Product.find(183524354)
which returns the following JSON:
{"body_html":"A Baseball Cap","created_at":"2014-03-14T19:25:19-04:00","handle":"moose","id":183524354,"product_type":"hat","published_at":"2014-03-14T19:25:05-04:00","published_scope":"global","template_suffix":null,"title":"Hat","updated_at":"2014-04-03T12:06:34-04:00","vendor":"kevins_sweet_test_shop","tags":"","variants":[{"barcode":null,"compare_at_price":null,"created_at":"2014-03-14T19:25:19-04:00","fulfillment_service":"manual","grams":0,"id":419761934,"inventory_management":"shopify","inventory_policy":"deny","option1":"Red","option2":null,"option3":null,"position":1,"price":"10.00","product_id":183524354,"requires_shipping":true,"sku":"","taxable":true,"title":"Red","updated_at":"2014-04-03T12:06:34-04:00","inventory_quantity":10,"old
@mlanett
mlanett / rails http status codes
Last active February 3, 2025 11:36
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@StefanWallin
StefanWallin / README.md
Last active January 15, 2022 06:22 — forked from konklone/ssl.rules
nginx ssl config with multiple SNI vhosts and A+ SSL Labs score as of 2014-11-05

Configuring nginx for SSL SNI vhosts

Gotchas

Remarks

  • My version of konklones SSL config does not have SPDY support(my nginx+openssl does not support it)
  • You need a default ssl server (example.org-default.conf).
  • Some SSL-options have to be unique across your instance, so it's easier to have them in a common file(ssl.conf).
@douglascorrea
douglascorrea / app.styl
Last active October 27, 2016 18:23
Angular Directive for Particles JS - https://github.com/VincentGarreau/particles.js
.particleJs
background-color transparent
width 35%
height 100%
display block
position absolute
top 0px
left 0px
@Geesu
Geesu / assets.rake
Created December 8, 2014 16:55
Disable asset precompilation on heroku
Rake::Task["assets:precompile"].clear
namespace :assets do
task 'precompile' do
puts "Not pre-compiling assets..."
end
end
@pbosetti
pbosetti / mruby-play.c
Last active December 18, 2021 21:41
mruby gem example on how to use Data_Wrap_Struct for wrapping C structs into an mruby object
/***************************************************************************/
/* */
/* play.c - mruby testing */
/* Copyright (C) 2015 Paolo Bosetti and Matteo Ragni, */
/* paolo[dot]bosetti[at]unitn.it and matteo[dot]ragni[at]unitn.it */
/* Department of Industrial Engineering, University of Trento */
/* */
/* This library is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU GENERAL PUBLIC LICENSE 2.0. */
/* */
@waissbluth
waissbluth / _hreflang.html.haml
Last active July 27, 2022 17:57
Ruby on Rails SEO. Add a <link rel="alternate" hreflang="es" href="http://es.example.com/" /> link to every other locale for the same page. Per https://support.google.com/webmasters/answer/189077?hl=en
-# For each locale except the current one
- (I18n.available_locales - [I18n.locale]).each do |locale|
-# Add a link to the current URL but in `locale` language
%link{rel: 'alternate', hreflang: locale, href: url_for(locale: locale)}
@quinncomendant
quinncomendant / .htaccess for WP subdirectory installation
Last active September 12, 2022 03:22
This .htaccess file works with Wordpress installed under a subdirectory wp/ inside the document root.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Make the admin still accessible from /wp-admin
RewriteCond %{REQUEST_URI} ^/wp-admin/?(.*)
RewriteRule .* wp/wp-admin/$1 [L,R=301]
RewriteCond %{REQUEST_URI} ^/wp/?$
RewriteRule .* wp/wp-admin/ [L,R=301]
# Base is the URL path of the home directory
RewriteBase /