Skip to content

Instantly share code, notes, and snippets.

View etozzato's full-sized avatar
💀
I work hard so my cat doesn't have to

Emanuele Tozzato etozzato

💀
I work hard so my cat doesn't have to
View GitHub Profile
@etozzato
etozzato / dev_console.js
Last active May 12, 2023 04:58
how to delete all your Reddit comments
// Go to your comment listing https://old.reddit.com/user/user_name/comments/
// Open the dev console and run this one-liner.
// Reload the page and run again as needed!
// Don't click on [next >] pagination button
document.querySelectorAll('form.toggle.del-button a:not(.no)').forEach(function(el,idx){setTimeout(function(){el.click()},idx*555)})
@etozzato
etozzato / openai.md
Created March 15, 2023 23:30
GPT and Rails development...

👨‍💻 show me how to use Redis in ruby to keep a count of active sessions that are triggered by a check-in event and expire in 3 minutes

🤖 Sure, here's an example of how you can use Redis in Ruby to keep track of active sessions and expire them after 3 minutes:

require 'redis'

redis = Redis.new

# Define a method to handle check-in events
def handle_check_in_event(user_id)
@etozzato
etozzato / downloader.dart
Created January 11, 2022 23:41
Asset downloader for Flutter apps
import 'dart:io';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:download_assets/download_assets.dart';
enum DownloaderOrientation { vertical, horizontal }
enum DownloaderStatus { ready, downloading, downloaded, error }
class Downloader extends StatefulWidget {
final DownloaderOrientation orientation;
@etozzato
etozzato / puma.rb
Last active January 28, 2024 20:12
A section of config/puma.rb that will automatically generate a self-signed X509 certificate and provide https in development
if Rails.env.development?
FileUtils.mkdir_p(Rails.root.join('config', 'certs'))
key_path = Rails.root.join('config', 'certs', 'development.key')
crt_path = Rails.root.join('config', 'certs', 'development.crt')
unless File.exist?(key_path) && File.exist?(crt_path)
def cert_domain
'localhost' # Setting[:cookie_domain] || 'localhost'
end
@etozzato
etozzato / sample.rb
Last active February 3, 2020 09:31
Implement this: WithFallbackConcern
# frozen_string_literal: true
FactoryBot.define do
factory :sample do
identifier { SecureRandom.uuid }
traceability_sample { 'AA123456789' }
traceability_batch { nil }
end
end
@etozzato
etozzato / rspec_model_testing_template.rb
Created January 29, 2020 12:31 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@etozzato
etozzato / licence_reader.rb
Created January 18, 2020 19:03
California BCC Bureau of Cannabis Control's License CSV Parser
require 'csv'
# This LicenseReader will receive a CSV file containing business license information. Different US states will implement completely different formats,
# the following example is for California. The LicenseReader, integrated into the LIMS will allow the laboratory to type a license `C11-0001123-LIC` and
# return attribute data businessuctures compatible with the creation of the Client and License model.The output must remain constant but the input must
# be parsed using several regular expressions depending on the data made available by the regulatory agency. The class must take into consideration
# fault tolerancy when data is incomplete. Particularly badly businessucture in the example is the column Business Contact Information!
#
# "License Number","License Type","Business Owner","Business Contact Information","Business businessucture","Premise Address","Status","Issue Date","Expiration Date","Activities","Adult-Use/Medicinal"
# "C11-0001129-LIC","Cannabis - Dibusinessibutor License","RICHARD
@etozzato
etozzato / att.txt
Last active August 2, 2016 14:38
PharmWare - Sample Test attributes
Basic Attributes:
batch_id
sample_id
samle_name
sample_strain
category
picture_url
tested_at (iso8601 date)
expires_at (iso8601 date)
List of Analites:
@etozzato
etozzato / ex.js
Last active June 23, 2016 14:11
simpy ex
navigator.geolocation.getCurrentPosition(function(pos) {
var coords = pos.coords;
var weatherUrl = 'http://api.openweathermap.org/data/2.5/weather?' +
'lat=' + coords.latitude + '&lon=' + coords.longitude + '&units=metric';
ajax({ url: weatherUrl, type: 'json' }, function(data) {
simply.text({ title: data.name, subtitle: data.main.temp });
});
});
105 The Cannabis Extraction and Concentrates Wizard – Bryce Berryessa Bryce Berryessa
104 The Young Mavericks Disrupting the Cannabis Tracking Software Space Kyle Sherman and Chase Wiseman
103 Locating the Perfect Real Estate for your Cannabis Business Matt Chapeldaine
102 Cannabis Oil Extraction Technology with Andy Joseph Andy Joseph
101 Tech That is Changing Cannabis Cultivation with Greg Eisenbeis Greg Eisenbeis
100 What is Selling in Cannabis Dispensaries with Roy Bingham Roy Bingham
99 Cannabis Tourism with Bud and Breakfast CEO, Sean Roby Sean Roby
98 Bringing the Cannabis Market to your Door with Healthy Headie Holly Alberti-Evans
97 How CBD Can Help Your Pets Julianna Carella & Marjorie Fischer
96 Inside The Cannabis Cup with Nico Escondido of High Times Nico Escondido