Skip to content

Instantly share code, notes, and snippets.

View geetfun's full-sized avatar

Simon Chiu geetfun

View GitHub Profile
@geetfun
geetfun / cheatsheet.rb
Created January 12, 2023 15:00 — forked from mabenson00/cheatsheet.rb
Rails ActiveRecord JSON cheatsheet
# Basic key operators to query the JSON objects :
# #> : Get the JSON object at that path (if you need to do something fancy)
# -> : Get the JSON object at that path (if you don't)
# ->> : Get the JSON object at that path as text
# {obj, n} : Get the nth item in that object
# https://www.postgresql.org/docs/9.4/functions-json.html#FUNCTIONS-JSONB-OP-TABLE
# Date
# date before today
.champ-moderator-badge-inner-wrapper {
position: relative;
.champ-moderator-badge-icon {
background: #333333;
color: white !important;
border-radius: 50px;
position: absolute;
right: 10px;
top: -5px;
font-size: 10px;
@geetfun
geetfun / champ-below-header.liquid
Created March 12, 2019 01:19
Champ Below Header Example
<div class="container">
<div class="row">
<div class="col">
<div class="below-header">
<div class="below-header-wrapper">
<h2>Welcome to Champ's live demo</h2>
<p>Did you know that this isn't just a demo?<br>This is our live pre-sales Q&A and support forum. Take a look around and say "Hello".</p>
</div>
</div>
</div>
@geetfun
geetfun / compare_hmac.rb
Created October 28, 2018 01:27
Generate hmac comparison
calculated_hmac = Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', SHARED_SECRET, data))
ActiveSupport::SecurityUtils.secure_compare(calculated_hmac, hmac_header)
@geetfun
geetfun / email_template.html.liquid
Created September 7, 2018 04:45
Email template for Champ
<p>The following topics you're following has been updated:</p>
{% for topic in topics %}
<p>
<b><a href="{{ topic.url }}" target="_blank">{{ topic.title }}</a></b>
<br>
Last post: {{ topic.last_post_excerpt }}
</p>
{% endfor %}
Founder to CEO
How to build a great company from the ground up
By Matt Mochary
Table of Contents
Introduction
Part I -- The Beginning
Chapter 1: Getting Started
@geetfun
geetfun / post-images-new-tab-version-1.html.liquid
Last active May 20, 2018 21:45
Champ App - Enlarge post images in new tab
<style type="text/css">
.post img:hover {
cursor: pointer;
}
</style>
<script type="text/javascript">
  $(function() {
$(document).on("click", ".post img", function(e) {
var $this = $(this);
@geetfun
geetfun / storage.yml
Created April 26, 2018 18:18
Example mirror storage yaml for ActiveStorage configuration
production:
service: Mirror
primary: amazon1
mirrors:
- amazon2
<style type="text/css">
.ajaxcart__product-meta,
.cart__product-property {
display: none;
}
</style>
<script type="text/javascript">
var cssClasses = [".ajaxcart__product-meta", ".cart__product-property"];
setInterval(function() {
jQuery.each(cssClasses, function(index, cssClass) {