Skip to content

Instantly share code, notes, and snippets.

@lukeburford
lukeburford / main.dart
Last active February 12, 2019 14:09
Dart OOP Example
void main() {
var deck = new Deck();
print(deck);
// Shuffle the deck
deck.shuffle();
print(deck.cardsWithSuit('Banana'));
@lukeburford
lukeburford / functions.php
Last active February 7, 2018 03:55
Add Jribbble to WordPress
// Load Jribbble
function lunamedia_theme_load_scripts() {
if (!is_admin()) {
if(is_page_template('page-about.php')){
// Register our Javascript
wp_register_script('jribbble', get_template_directory_uri() . '/js/jribbble.min.js', array('jquery'), false, false);
// Load our Javascript
wp_enqueue_script('jribbble');
}
@lukeburford
lukeburford / Shopify random blog post (Liquid server-side method)
Last active February 16, 2021 10:36
Display random post from a Shopify blog, for example on the store homepage. Shopify caches it's pages so a homepage refresh will not show a new post, but adding an item to the cart and returning to the homepage will. Based on: http://wiki.shopify.com/Featuring_one_randomly_picked_product
{% capture index %}{{ 'now' | date: '%S' | times: collections.frontpage.products.size | divided_by: 60 }}{% endcapture %}
{% for article in blogs.blog-name.articles offset:index limit:1 %}
<a href="{{article.url}}">{{ article.title }}</a>
{% endfor %}