Skip to content

Instantly share code, notes, and snippets.

View lirenyeo's full-sized avatar
🏇
Keep going!

Liren lirenyeo

🏇
Keep going!
View GitHub Profile
@lirenyeo
lirenyeo / rails-nested-attributes-association.rb
Last active June 10, 2023 07:07
Rails Nested Attributes vs Build from Association
class User < ApplicationRecord
has_many :posts
accepts_nested_attributes_for :posts, allow_destroy: true
has_one :profile
accepts_nested_attributes_for :profile
end
# To create nested records through the parent:
@lirenyeo
lirenyeo / sendgrid_qr_label.html
Created June 8, 2022 06:26
SendGrid Codeblock for QR label
<div style="background: white; text-align: center; padding-top: 1em; padding-bottom: 1em;">
<img src="{{qr_label}}" width="160" />
<div>{{qr_code}}</div>
</div>
@lirenyeo
lirenyeo / shihtzu_formtastic.md
Created May 25, 2022 14:21
Using Flag ShihTzu with Formtastic

FlagShihTzu + Formtastic + Active Admin

To get all flags available in a model:

User.flag_mapping
User.flag_options
User.flag_columns
@lirenyeo
lirenyeo / brightness.md
Last active November 8, 2021 15:08
Control screen brightness using xrandr
#!/bin/bash
# brightness: Change all monitors brightness in software.
# by hackerb9, 2019,2021

# Examples:  brightness 75;  brightness -10; brightness +10
# Usage:
#	brightess [n] [+n] [-n]
#	n	An integer from 0 to 100 specifies a brightness level.
#	+n	Increase brightness by n.
@lirenyeo
lirenyeo / create_vimeo_api.md
Last active May 19, 2021 15:14
[3 minutes] Creating Vimeo API Key

In order for developers to build feature for users to upload videos directly to Vimeo, account owner needs to create a 'developer app' that comes with Personal Access Token and Secret Keys (we usually just call all these "API Keys"), and pass that to programmers.

Vimeo also requires owner to specifically request for permission to do direct video upload, this request might take up to 5 days for approval, so please prepare it as early as possible.

Note: For direct video upload, the vimeo account needs to be of Pro, Business, Premium or Enterprise tier

Steps

  1. Visit https://developer.vimeo.com/apps/new
  2. Click 'Create An App'
  3. Fill in App name and description
@lirenyeo
lirenyeo / export.rb
Created December 19, 2020 06:49 — forked from KevinSia/export.rb
require 'prawn'
arr = HallSession
.joins(:check_in_sessions, :hall)
.group('check_in_sessions.hall_session_id, auditorium_halls.name, hall_sessions.start_at, hall_sessions.end_at, hall_sessions.id')
.select('auditorium_halls.name as hall_name, hall_sessions.start_at, hall_sessions.end_at, COUNT(*) as c')
.order('hall_name, start_at, end_at')
.map do |ci|
[

CSS Exercise (Ninja Joe Profile Page)

  1. Download the HTML file from here: https://bit.ly/2FwrMCN

  2. Style the site to make it look like this:

Desktop

Desktop Screenshot

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXVp7MwDPWKNM/O2kBN0+tOvIZG3aIMJnJ7vZcq2ANJy0zCNs7JbYAC7/LKN9L3vVT2E/PEZuIufVeIaq67DtuyuBxa+Dt9o9f91VVnScAJdS5NYMU2BN7whprzpVU+d0Dem9PONV+eSCn3DmexQEQrow2lRk3Ls7oUmB0sNtxeruVPuDNxyyqCCO8ajd60rro0R/YQZ5hcwqhXqaHZejXdqL4UJ4Xk5BIanfwPxoteHXCuPgvseMQ7P/1uS/6ryG8MZPxvBkBFAuy0EbKOwDNDOJEpawLn+iKAQjakmne774GG7bE8VQrPQuNfku2FeJiDzMNPoZ36ucJz8+bUmbz [email protected]

Google Places APIs

/maps/api/place/autocomplete

  • Takes input string and return multiple matching addresses with place_id
  • Can use lat,lng location + radius to create bias result
  • result is different than /textsearch
  • ex: no result for ไลฟ์ สุทธิสาร

/maps/api/place/queryautocomplete

  • Can process request like 'cafe near me'