Skip to content

Instantly share code, notes, and snippets.

View lukeholder's full-sized avatar
👾

Luke Holder lukeholder

👾
View GitHub Profile
@lukeholder
lukeholder / das_download.rb
Last active October 12, 2022 01:32 — forked from itsgoingd/das_download.rb
Script to download all Destroy All Software screencasts w/ login (works as of Apr 2021)
#! /usr/bin/env ruby
# usage:
# $ das_download.rb email password
# based on various gists from this thread https://gist.github.com/maca/1798070
require "mechanize"
require "nokogiri"
require "fileutils"
class DasDownloader
@lukeholder
lukeholder / cart.html
Last active July 18, 2017 02:35
Cart with errors
{% extends "shop/_layouts/main" %}
{% block main %}
<div class="row">
<div class="twelve columns">
{% if cart.lineItems|length %}
<table class="u-full-width">
<thead>
<tr>
<?php
namespace Craft;
$craft = require '../craft/app/bootstrap.php';
$craft->plugins->loadPlugins();
$productIds = craft()->elements->getCriteria('Commerce_Product', ['limit' => null])->ids();
// Configuration
@lukeholder
lukeholder / address.twig
Created September 14, 2016 13:12
simple address form
<form method="post">
{% set model = cart.shippingAddress %}
<input type="hidden" name="action" value="commerce/cart/updateCart">
<input type="hidden" name="redirect" value="placeyourredirecturlhere"/>
{{ getCsrfInput() }}
<div class="row">
<div class="six columns">
<label>First Name *</label>
<input type="text" id="shippingAddress-firstName" class="u-full-width" name="shippingAddress[firstName]" value="{{ model.firstName ?? "" }}">
<?php
craft()->on('commerce_discounts.onBeforeMatchLineItem', function ($event)
{
/** @var Commerce_LineItemModel $currentLineItem */
$currentLineItem = $event['lineItem'];
/** @var Purchasable $currentPurchasable */
$currentPurchasable = $currentLineItem->getPurchasable();
@lukeholder
lukeholder / import.php
Last active January 10, 2018 09:58
Basic example to import Products and their variants into Craft Commerce
<?php
namespace Craft;
// This file could be placed into your public_html folder and visited to import a cheese product.
$craft = require '../craft/app/bootstrap.php';
$craft->plugins->loadPlugins();
$newProduct = new Commerce_ProductModel();

Code Hint Helpers for PHP Storm

Add this code block into the phpdoc of Craft's WebApp.php class.

This will enable PHP Storm IDE features for services like craft()->market_product->method()

 * @property Market_AddressService         $market_address
 * @property Market_CartService            $market_cart
 * @property Market_CountryService         $market_country
@lukeholder
lukeholder / nginxConfig
Created July 14, 2015 10:52
nginxConfig
server {
listen 80;
server_name tenina.com direct.tenina.com new.tenina.com;
# server_name .tenina.com;
root /home/forge/tenina.com/public;
rewrite /2013/12/brown-sugar-pavlova-summer-berries/ http://tenina.com/recipes/brown-sugar-pavlova-with-summer-berries permanent;
rewrite /2013/12/pomegranate-sangria/ http://tenina.com/recipes/pomegranate-sangria permanent;
rewrite /2013/12/tasmanian-salmon-pate/ http://tenina.com/recipes/tasmanian-salmon-pate permanent;
rewrite /2013/12/fruit-mince-baklava/ http://tenina.com/recipes/fruit-mince-baklava permanent;
require 'sequel'
connection_string = 'driver={Timberline Data};dbq=\\\\doric-server19\\Timberline Office\\Gold\\DORIC GROUP\\;codepage=1252;dictionarymode=0;standardmode=1;maxcolsupport=1536;shortenames=0;databasetype=1;uid=l;pwd=Doricsep14;'
DB = Sequel.odbc(:driver=>'Timberline Data',:drvconnect=>connection_string)
DB.extend_datasets do
Sequel::Dataset.def_sql_method(self, :select, %w'select distinct limit columns into from join where group order having compounds')
@lukeholder
lukeholder / timberline-sage-300.rb
Created July 8, 2014 04:45
Connect to Timberline Sage 300 from Ruby on Windows through ODBC using the Sequel Gem
require 'sequel'
connection_string = 'driver={Timberline Data};dbq=\\\\doric-server19\\Timberline Office\\Gold\\DORIC GROUP\\;codepage=1252;dictionarymode=0;standardmode=1;maxcolsupport=1536;shortenames=0;databasetype=1;uid=luke;pwd=Awesome;'
db = Sequel.odbc(:driver=>'Timberline Data',:drvconnect=>connection_string)
# I found this returns true sometimes even if the connection is not working.
puts db.test_connection
master_company = db.fetch('SELECT * FROM ABM_MASTER__COMPANY').all