Skip to content

Instantly share code, notes, and snippets.

View cjavdev's full-sized avatar
👉

CJ Avilla cjavdev

👉
View GitHub Profile
# data = DATA.readlines
data = File.readlines(ARGV.first)
p data
.map(&:chomp)
.chunk_while { _2 != "" }
.map { _1.map(&:to_i) }
.map(&:sum)
.sort[-3..]
<!DOCTYPE html>
<html>
<head>
<title>Confirm subscription</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="css/base.css" rel="stylesheet" />
<script src="https://js.stripe.com/v3/"></script>
<script src="subscription.js" defer></script>
</head>
@cjavdev
cjavdev / fees.rb
Created August 29, 2022 13:38
Stripe fees
def if_you_ask_for(amount)
ask_for = amount
fee = 0.30 + (0.029 * amount)
receive = amount - fee
{
ask_for: ask_for.round(2),
fee: fee.round(2),
receive: receive.round(2),
}
Dir['./icons/*/*.svg'].each do |file|
print "."
system "inkscape -w 1024 -h 1024 #{file} -o #{file.gsub('.svg', '.png')}"
end
@cjavdev
cjavdev / heroku-vips.md
Created August 11, 2022 20:26
How to work with vips on heroku for the image_processing gem to work.
  1. Add the apt buildpack
heroku buildpacks:add --index 1 heroku-community/apt
  1. Create a file named Aptfile in the app root

  2. Edit the aptfile with content

const myPromise = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('Success for arrow function promise.');
}, 2000);
});
const myNamedPromise = new Promise(function callback(resolve, reject) {
setTimeout(() => {
resolve('Success for named callback in promise.');
@cjavdev
cjavdev / filter.js
Created January 5, 2022 21:06
useParameterToFilterArray
function useParameterToFilterArray(filterFn, array) {
const filteredArray = [];
for (let i = 0; i < array.length; i++) {
if (filterFn(array[i])) {
filteredArray.push(array[i]);
}
}
return filteredArray;
}
@cjavdev
cjavdev / .vimrc
Last active August 2, 2022 22:38
vim config
" Leader
let mapleader = " "
set autowrite " Automatically :write before running commands
set backspace=2 " Backspace deletes like most programs in insert mode
set et " Expand tabs to spaces
set ff=unix " Something about unix
set history=50
set incsearch " do incremental searching
" set laststatus=2 " Always display the status line
@cjavdev
cjavdev / clone_prod_db.sh
Created July 5, 2021 19:45
Quick and dirty clone heroku postgres db locally
#!/usr/bin/env bash
set -e
# Dump prod database into ./heroku.dump
curl `heroku pg:backups public-url` > heroku.dump
# Drop and recreate the local database
rails db:drop db:create