Skip to content

Instantly share code, notes, and snippets.

View digerata's full-sized avatar

Mike Wille digerata

View GitHub Profile
@digerata
digerata / app-models-data_import.rb
Last active April 23, 2020 23:54
Importing a large CSV file
class DataImport < ApplicationRecord
belongs_to :company, optional: true # org in this case
belongs_to :user # employee in this case
enum status: %i[pending processing completed failed]
end
@digerata
digerata / dbsync.sh
Created September 24, 2019 12:25
Pull down a database from Heroku. Assumes Rails db names.
#!/bin/bash
APPNAME="$1"
REMOTE="$2"
if [[ "$3" != "" ]]; then
ENVIRONMENT="$3"
else
ENVIRONMENT="development"
fi
require 'uri'
require 'net/http'
class ExampleController < ApplicationController
def test_smartline
url = URI("https://smartlinedesign.quickbase.com/db/bngiubrjh?a=API_ImportFromCSV&ticket=9_bnhq59q6c_b3nhzn_irxj_a_-b_dgzffhkd5iim4bdnppgpdbs78vct64nqkdf97a28cfbqezkda565cd_jd3u8z")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@digerata
digerata / sample.html
Created October 18, 2017 19:00
Example of what is output for the template
<!DOCTYPE html>
<html lang='en'>
<head>
<!-- ... -->
</head>
<body>
<!-- ... -->
<!DOCTYPE html>
@digerata
digerata / stripe.rb
Created March 29, 2016 23:39
Stripe initializer that makes it easy to work with development and production keys.
# override in production...
if ENV['STRIPE_KEY']
Rails.logger.warn "Using production environment keys for Stripe."
STRIPE_KEY = ENV['STRIPE_KEY']
STRIPE_PUBLISH = ENV['STRIPE_PUBLISH']
else
Rails.logger.warn "Using test keys for Stripe."
# dev values...
Calling abort on jQuery (1.11.1) will result in an exception:
SyntaxError: JSON Parse error: Unexpected identifier "undefined"
Test case:
$.get('http://jsonip.com').abort();
$("input[data-role='tagsinput']").each(function() {
var placeholder = $(this).data('placeholder');
var saved = $(this).data('saved');
var autocomplete = jQuery(this).data('autocomplete');
jQuery(this).select2({
tags: true,
placeholder: placeholder,
minimumInputLength: 1,
ajax: {
@digerata
digerata / _compass-retina-sprites.scss
Created October 8, 2012 17:34 — forked from estahn/_compass-retina-sprites.scss
Using Compass to generate normal and retina sprite maps at once
@mixin all-retina-sprites($map, $map2x) {
@media (min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2),
(-webkit-min-device-pixel-ratio: 1.5),
(min-device-pixel-ratio: 1.5),
(min-resolution: 1.5dppx) {
$base-class: sprite-map-name($map);
.#{$base-class}-all-retina-sprites {
//Receiving the transaction response
-(void)transactionResults:(id)response
{
if ([[response objectForKey:@"Transaction status"] isEqualToString:@"Approved"])
{
NSLog(@"Transaction Approved");
NSLog(@"PNR ref: %@", [response objectForKey:@"PNFRef"]);
NSLog(@"Invoice: %@", [response objectForKey:@"Invoice"]);
NSLog(@"Card Type:%@", [response objectForKey:@"CardType"]);
}
//Initialization - replace these values with your own account information
[[PATransactionHandler dataHolder] setDelegate:self];
[[PATransactionHandler dataHolder] setMerchantId:@"<mid>"];
[[PATransactionHandler dataHolder] setLoginId: @"<login id>"];
[[PATransactionHandler dataHolder] setUserName: @"<username>"];
[[PATransactionHandler dataHolder] setPassWord: @"<password>"];
[[PATransactionHandler dataHolder] setAppName: @"iPad Test"];
//Customization
[[PATransactionHandler dataHolder] setBackgroundImage:[UIImage imageNamed:@"background.png"]];