Skip to content

Instantly share code, notes, and snippets.

View dunkrupp's full-sized avatar
🎉

Drew Ruppel dunkrupp

🎉
View GitHub Profile
@dunkrupp
dunkrupp / GetURLParameter.js
Last active August 29, 2015 14:19
grab URLParams, get values
// Search for URL params
// i.e. search 'customer[comments]'
var getcomment = checkParam(getUrlParameter('customer%5Bcomment%5D'));
function getUrlParams(param)
{
var pageURL = window.location.search.substring(1);
var urlVar = pageURL.split('&');
for (var i = 0; i < urlVar.length; i++)
{
@dunkrupp
dunkrupp / MergePDF.php
Created May 6, 2015 20:04
Merge Multiple PDFs w/ PHP
<?php
#Used to merge multiple PDFs into one document.
public static function mergepdf()
{
$dir = '/path/to/file/';
$fileArray= array($dir."number1.pdf",$dir."number2.pdf");
$datadir = $dir;
$outputName = $datadir."merged.pdf";
@dunkrupp
dunkrupp / phoneformat.js
Created May 22, 2015 18:48
Format Phone Number
var phone = $("#phone").val();
phone = phoneFormat(phone);
function phoneFormat(phone) {
phone = phone.replace(/[^0-9]/g, '');
phone = phone.replace(/(\d{3})(\d{3})(\d{4})/, "$1.$2.$3");
return phone;
}
@dunkrupp
dunkrupp / active_carriers.php
Last active July 31, 2018 17:48
Retrieves a list of active carriers in Magento 2
<?php
/** @var \Magento\Shipping\Model\Config $methods */
$shippingConfig = $this->objectManager->create('Magento\Shipping\Model\Config');
$deliveryMethods = $shippingConfig->getAllCarriers();
/** @var \Magento\Framework\App\Config\ScopeConfigInterface $scopConfig */
$scopeConfig = $this->objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface');
$carriers = [];
@dunkrupp
dunkrupp / Logger.php
Last active August 24, 2023 16:32
MonoLog log file truncation method.
<?php
namespace \App\Logger;
class Logger extends \Monolog\Logger
{
const MAX_SIZE = 2097152;
/**
* Truncates the log file per iteration.
@dunkrupp
dunkrupp / .gitattributes
Created January 6, 2022 18:18
.Net .gitattributes
* text=auto
###### Git
.gitattributes text
.gitignore text
.gitconfig text
.gitmodules text
##### Windows
*.bat text eol=crlf
# frozen_string_literal: true
module PubliclyIdentifiable
extend ActiveSupport::Concern
include ActiveModel::Validations
included do
attribute :public_id, default: -> { PubliclyIdentifiable.generate_public_id }
end
# frozen_string_literal: true
class BaseOperation
include Callee
include Dry::Monads[:do, :result]
private
def capture_and_fail(message, exception)
Rails.logger.error(exception.message)