Skip to content

Instantly share code, notes, and snippets.

View mfifth's full-sized avatar

Matt Quinto mfifth

View GitHub Profile
So what you would do is find any letters within the string that show up at least twice. From there you look at the next letter beside it and save that in some sort of entry. That is the substring to beat. Then you run through the rest of the letters to see if anything can beat that record.
You do that so on and so forth until you reach the end of your substrings and then return the longest one the program found.
class Grade
include Comparable
attr_reader :grade
def initialize(string)
@grade = string.downcase
end
def ==(other_grade)
@grade == other_grade.grade
<form method="POST" action="https://payflowlink.paypal.com">
<input type="hidden" name="TYPE" value="S">
<input type="hidden" name="USER1" value="<%= payment_transaction.id %>">
<input type="hidden" name="INVOICE" value="<%= payment_transaction.invoice_code %>">
<input type="hidden" name="NAME" value="<%= payment_transaction.user %>">
<input type="hidden" name="ADDRESS" value="<%="#{billing_address.address_line_1} #{billing_address.address_line_2}" %>">
<input type="hidden" name="CITY" value="<%= billing_address.city %>">
<input type="hidden" name="STATE" value="<%= billing_address.state %>">
<input type="hidden" name="ZIP" value="<%= billing_address.postcode %>">
<input type="hidden" name="COUNTRY" value="<%= billing_address.country %>">
def sort_files(file_params, ar_object) # Active Record Object
if file_params.values.count >= 2 # <- If there are more than two files being submitted.
tmp_filename = "#{Rails.root}/tmp/" << Time.now.strftime('%Y-%m-%d-%H%M%S-%N').to_s << ".zip" # <- Unique file name
file_count = 0
Zip::File.open(tmp_filename, Zip::File::CREATE) do |zipfile| # <- Find or create a file with this name
file_params.values.each do |file| # <- Loop over all the files in the array.
new_filename = "#{file_count += 1}-#{file.original_filename}"
puts new_filename
zipfile.add(new_filename, file.path) # <- Add file to zip.
end
2018-01-05T22:08:07.966404+00:00 app[worker.1]: 4 TID-3otzo WARN: Terminating 1 busy worker threads
2018-01-05T22:08:07.968557+00:00 app[worker.1]: 4 TID-3otzo WARN: Work still in progress [#<struct Sidekiq::BasicFetch::UnitOfWork queue="queue:default", job="{\"class\":\"Sidekiq::Extensions::DelayedClass\",\"args\":[\"---\\n- !ruby/class 'Shop'\\n- :import_products\\n- - '1'\\n\"],\"retry\":true,\"queue\":\"default\",\"jid\":\"a11e1afe7d2ba185b877a4b9\",\"created_at\":1515187913.9918175,\"enqueued_at\":1515187913.9923136}">]
2018-01-05T22:08:07.969558+00:00 app[worker.1]: 4 TID-3otzo INFO: Pushed 1 jobs back to Redis
2018-01-05T22:08:07.970867+00:00 app[worker.1]: 4 TID-vwfvg Sidekiq::Extensions::DelayedClass JID-a11e1afe7d2ba185b877a4b9 INFO: fail: 2173.958 sec
2018-01-05T22:08:07.972118+00:00 app[worker.1]: 4 TID-3otzo INFO: Bye!
2018-01-05T22:08:08.253807+00:00 heroku[worker.1]: Process exited with status 0
const firebase = require('firebase-admin');
function get_artist_by_username(username){
firebase.database().ref('artists').where('artist_name', '==', data['vendor']).then(res => {
return res
});
}
@mfifth
mfifth / app.js
Created September 22, 2017 20:47
async function send_to_stripe(billing_data) {
console.log(billing_data)
stripe.customers.create({
email: billing_data['email']
}).then(customer => {
const res = client.query('UPDATE customers SET stripe_customer_id=$1 WHERE email=$2', [ customer.id, billing_data['email'] ])
return stripe.customers.createSource(customer.id, {
source: "" // <- What do I put here?
object: "card",
name: billing_data['first_name'] + billing_data['last_name'],
@mfifth
mfifth / app.js
Created September 21, 2017 18:56
router.get('/', add_site_form)
.get('/auth/', auth)
.get('/verify/:app_id', verify)
.get('/webhooks/:shop_id', go_webhooks)
.post('/webhooks/:action/:shop_id', go_webhook)
.post('/products/create/:shop_id', product_create);
.post('/customers/create/:shop_id', customer_create);
/mnt/c/Users/Matt/Desktop/NodeProjects/myapp/app.js:10
.post('/customers/create/:shop_id', customer_create);
@mfifth
mfifth / app.js
Last active September 21, 2017 17:04
var shopify = new shopifyAPI({
shop: 'kauai-project.myshopify.com', // MYSHOP.myshopify.com
shopify_api_key: 'xxxxxxxx', // Your API key
shopify_shared_secret: 'xxxxxxxxxx', // Your Shared Secret
shopify_scope: 'read_orders, write_orders, read_customers, write_customers, read_products',
redirect_uri: 'http://localhost:3000/dashboard',
});
async function send_to_shopify(billing_data) {
console.log(billing_data)
async function save_account(ctx) {
const {files, fields} = await asyncBusboy(ctx.req);
var email = fields.email;
var first_name = fields.firstName;
var last_name = fields.lastName;
var address = fields.address;
var addressTwo = fields.addressTwo;
var city = fields.addressCity;
var state = fields.addressState;
var zip = fields.addressZip;