Skip to content

Instantly share code, notes, and snippets.

View EdgarOrtegaRamirez's full-sized avatar
📝
​Learning!

Edgar Ortega EdgarOrtegaRamirez

📝
​Learning!
View GitHub Profile
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / google-api-deno.ts
Created September 29, 2022 14:00
Google API Deno Example
import { Content as ShoppingAPI, auth } from "https://googleapis.deno.dev/v1/content:v2.1.ts";
const merchantId = BigInt(124123123);
const serviceAccountConfig = await Deno.readTextFile("./service-account.json");
const credentials = auth.fromJSON(JSON.parse(serviceAccountConfig));
const shoppingAPI = new ShoppingAPI(credentials);
const response = await shoppingAPI.productsList(merchantId, {})
console.log(response);
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / payload.json
Created May 10, 2022 18:52
Github Actions Context Payload for Push Event
{
"payload":{
"after":"65aeff1fc085e1e369533de9f59b2754c5bb20b1",
"base_ref":null,
"before":"77a9bae00f0d6996e0883ce6d23f2778c6a2ee25",
"commits":[
{
"author":{
"email":"email@gmail.com",
"name":"First Last",
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / append_gzip.rb
Last active March 3, 2022 18:37
Ruby - Append to a gzip CSV file
require "zlib"
open_mode = "ab" # append / binary
file = File.open('path-to-file.csv.gz', open_mode)
gz = Zlib::GzipWriter.new(file)
gz.write("new,row,csv\n")
gz.close
# http://ruby-doc.org/core-2.5.3/IO.html#method-c-new
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / ssl.rb
Last active January 14, 2021 19:50
Ruby: Disable OpenSSL certificate verification
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / gist:159716f83dc74c14813e20787228c1ca
Created August 31, 2020 20:49
Install lib v8 v3 therubyracer
Works in macOS Catalina v10.15.x
$ brew install v8@3.15
$ bundle config build.libv8 --with-system-v8
$ bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
$ bundle install
"""
This sample demonstrates an implementation of the Lex Code Hook Interface
in order to serve a sample bot which manages orders for flowers.
Bot, Intent, and Slot models which are compatible with this sample can be found in the Lex Console
as part of the 'OrderFlowers' template.
For instructions on how to set up and test this bot, as well as additional samples,
visit the Lex Getting Started documentation http://docs.aws.amazon.com/lex/latest/dg/getting-started.html.
"""
import math
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / Dockerfile
Created March 11, 2020 14:48
Docker Image – Ruby 2.6.2 / Alpine Linux 3.9
FROM ruby:2.6.2-alpine3.9
LABEL Version 2.6.2
LABEL Name Ruby-Node-Browsers
RUN gem install bundler -v 1.17.3 \
&& gem cleanup all
RUN apk add --no-cache --update \
bash \
build-base \
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / init.vim
Created August 28, 2019 19:09
Neovim config
" Be iMproved
set nocompatible
let g:ale_completion_enabled = 0
" ALE - some of the options need to be defined before ALE is initialized
let g:ale_echo_cursor = 1
let g:ale_close_preview_on_insert = 1
let g:ale_set_balloons = 1
let g:ale_sign_column_always = 1
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / deep.sh
Last active July 25, 2019 15:19
Rails deep nested associations
➜ bin/rails c
Loading development environment (Rails 5.2.3)
2.6.2 :001 > class Profile < ApplicationRecord
2.6.2 :002?> has_many :persons, inverse_of: :profile, dependent: :destroy
2.6.2 :003?> has_many :foos, :through => :persons
2.6.2 :005?> accepts_nested_attributes_for :persons
2.6.2 :006?> end
=> [:persons]
2.6.2 :007 > class Person < ApplicationRecord
2.6.2 :008?> has_one :foo, inverse_of: :person, dependent: :destroy
@EdgarOrtegaRamirez
EdgarOrtegaRamirez / install.sh
Created July 13, 2018 14:21
Install SQLite3 in Linux from source code (amalgamation)
wget https://www.sqlite.org/2018/sqlite-autoconf-3240000.tar.gz
tar xvfz sqlite-autoconf-3240000.tar.gz
cd sqlite-autoconf-3240000
./configure
make
make install # you may need sudo