Skip to content

Instantly share code, notes, and snippets.

@ace-subido
ace-subido / find_unique.rb
Last active November 29, 2019 04:57
Ruby Snippets
class FindUnique
DEFAULT_MAX_COMBINATIONS = ((CHARACTERS.size ** UNIQUE_LENGTH) * 0.9)
TRY_THRESHOLD = 4
UNIQUE_LENGTH = 6
CHARACTERS = %w[A B C D E F G H I J K L 1 2 3 4 5 6]
def self.call
if Something.count > DEFAULT_MAX_COMBINATIONS
Rails.logger.warn "This app has used more than 90% of the possible " \
@ace-subido
ace-subido / authenticate.rb
Last active March 1, 2020 16:07
AdminUsers::Operations::SetupTwoFactor code
module AdminUsers
class Authenticate
extend LightService::Action
expects :email, :password, :otp_attempt
promises :admin_user
executed do |c|
admin_user = AdminUser.find_by(email: c.email)
@ace-subido
ace-subido / blacksmith_guide.md
Last active February 17, 2019 15:48
Ragnarok Online Mobile - Tips

Progression

Level 1 - 20

Farming: Finish quests

Level 20 - 30

@ace-subido
ace-subido / README.md
Last active October 8, 2018 10:40
Small vuejs components all over your Rails Views

Use this if:

  • You just want a few interactive pieces here and there and you're still rendering everything from the Rails views
  • Your Rails frontend isn't a single-page VueJS application

Note: This works if your app has a rails/webpacker and VueJS installed

Usage

In your views:

@ace-subido
ace-subido / did
Last active July 16, 2018 16:37
Minimal Journal
# ~/.zshrc
alias did="vim '+normal Go' '+w' '+r !date' '+w' ~/did.txt"
@ace-subido
ace-subido / inflation_calculator
Last active August 27, 2018 16:58
Answer generator for the following Tito statement: "Entitled mga bata ngayon, ang laki nga ng mga sahod nila ngayon eh. Nung 1980 $salary_amount lang starting salary ko noon."
salary = 3000
puts "Tito: Noong 1980, #{salary} lang salary ko"
# > Tito: Noong 1980, 3000 lang salary ko
# Computed from CPI, source here https://docs.google.com/spreadsheets/d/1gPqRL2zKymVaOiWUqj3vMqc5FomahgbZdIsChcfq3Do/edit#gid=0
# Starting in 1980
inflation = [
{ year: 1980, value: 18.20 },
{ year: 1981, value: 13.08 },
@ace-subido
ace-subido / list-old-hdfs-files.sh
Last active April 13, 2022 00:41
Script to list/delete old files in an HDFS Directory
#!/bin/bash
usage="Usage: ./list-old-hdfs-files.sh [path] [days]"
if [ ! "$1" ]
then
echo $usage;
exit 1;
fi
if [ ! "$2" ]
@ace-subido
ace-subido / README.md
Last active June 23, 2017 12:14
Rakefile to publish Jekyll to a User Page

Disclaimer

This Rakefile will abuse your master branch. It will go against the usual git flow, if that doesn't ride well with you, don't use this.

Why did you do this? Why not just ride with the Github Pages Jekyll build server?

Too much wrangling with the dependencies on the Gemfile. My user page isn't some big project that everyone would use. I figured it's worth enough to sacrifice "best practices" for version control. It's just a user page, I don't want to pull my hair out trying to figure out dependencies in the build server when I add additional gems.

Setup

@ace-subido
ace-subido / answer.md
Last active July 10, 2022 14:27
You just won a 656 Million Dollar Lottery. What do you do now?
@ace-subido
ace-subido / initial-setup.md
Last active November 19, 2023 14:32
Benchmarking a Hadoop Cluster

Requirements

  1. HDP-2.2 installed by Ambari
  2. Install HDFS Client
  3. Patience

Instructions

Setup