Skip to content

Instantly share code, notes, and snippets.

Avatar
👾

Luke Holder lukeholder

👾
View GitHub Profile
@lukeholder
lukeholder / das_download.rb
Last active Apr 29, 2021 — forked from itsgoingd/das_download.rb
Script to download all Destroy All Software screencasts w/ login (works as of Apr 2021)
View das_download.rb
#! /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 Jul 18, 2017
Cart with errors
View cart.html
{% extends "shop/_layouts/main" %}
{% block main %}
<div class="row">
<div class="twelve columns">
{% if cart.lineItems|length %}
<table class="u-full-width">
<thead>
<tr>
View create-test-order-in-craft-commerce.php
<?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 Sep 14, 2016
simple address form
View address.twig
<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 ?? "" }}">
View discount.php
<?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 Jan 10, 2018
Basic example to import Products and their variants into Craft Commerce
View import.php
<?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();
View readme.md

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
View 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;
View sage.rb
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 Jul 8, 2014
Connect to Timberline Sage 300 from Ruby on Windows through ODBC using the Sequel Gem
View timberline-sage-300.rb
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