Skip to content

Instantly share code, notes, and snippets.

View abelorian's full-sized avatar
🎯
Focusing

Abel O'Rian abelorian

🎯
Focusing
View GitHub Profile
@abelorian
abelorian / google_auth.rb
Created December 21, 2023 18:00
Login con Google. Obtener el usuario con OAuth2
# Instalar gem 'google-apis-core'
require 'google/api_client/client_secrets'
class GoogleAuth
# url definida en console.google
REDIRECT_TO = "http://localhost:4002"
@abelorian
abelorian / agora.rb
Last active September 22, 2023 11:35
Agora dynamic Key ruby RTC example. Gem agora_dynamic_key https://rubygems.org/gems/agora_dynamic_key
# In Gemfile: gem 'agora_dynamic_key', '~> 0.1.0'
require 'dynamic_key'
class Agora
EXPIRATION_TIME_IN_SECONDS = 3600*3
def generate_rtc_token channel_name = 'any_channel_name'
params = {
@abelorian
abelorian / extend_string.rb
Last active March 6, 2023 23:44
Removing Accents In a Ruby String (Updated)
# RemoveAccents version 1.0.3 (c) 2008-2009 Solutions Informatiques Techniconseils inc.
#
# This module adds 2 methods to the string class.
# Up-to-date version and documentation available at:
#
# http://www.techniconseils.ca/en/scripts-remove-accents-ruby.php
#
# This script is available under the following license :
# Creative Commons Attribution-Share Alike 2.5.
#
@abelorian
abelorian / spreedly_conecta.json
Created May 6, 2022 21:25
Spreedly + Conekta purchase payload
{
"transaction": {
"payment_method_token": "TOKEN_CARD",
"amount": 60,
"currency_code": "MXN",
"retain_on_success": true,
"email": "abel@mail.com",
"gateway_specific_fields": {
"conekta": {
"customer": "John Doe",
@abelorian
abelorian / starken_api_rest.md
Last active March 11, 2021 22:32
Starken API Rest - WebService
@abelorian
abelorian / server.md
Last active January 25, 2021 18:29
My ubuntu 18.04 server

Droplet

Create a new, start with the smallest droplet. Use Ubuntu 20.04, log in as root.

Server

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install build-essential git-core curl zlib1g-dev libssl-dev libreadline-dev libmysqlclient-dev nginx -y
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install nodejs -y
@abelorian
abelorian / zip_s3_files.rb
Last active December 8, 2020 15:55
Zip files from remote server (S3)
protect_from_forgery :except => :get_job_resumes #Optional
require 'zip'
def get_job_resumes
@job = Job.find(params[:job_id])
@file = "#{Rails.root}/files/cvs.zip"
@applications = Application.get_applicants_all(@job.id) # app context method
Zip::ZipOutputStream.open(@file) do |zos|
@applications.each do |application|
user = application.user
@abelorian
abelorian / gist:96fcbb44503dc71eb83cbacc00400deb
Created July 16, 2020 17:13 — forked from brianr/gist:82ff15b17c839ff14748
Rollbar RQL: Search for occurrences in last 24 hours by url pattern
select *
from item_occurrence
where timestamp >= unix_timestamp() - 24 * 60 * 60
and request.url like '%mydomain.com%'
@abelorian
abelorian / mediastream.rb
Last active July 14, 2020 22:26
[RUBY] Mediastream API example + HTTP.rb Gem
class Mediastream
API_KEY = 'da...'
API_URL = 'https://platform.mediastre.am/api/live-stream'
PROFILE = {
"enabled": true,
"profile": "720p",
"video_bitrate": 2000000,
"audio_bitrate": 96000,
@abelorian
abelorian / Gemfile
Created June 25, 2020 15:11 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers