Skip to content

Instantly share code, notes, and snippets.

View yzhanginwa's full-sized avatar

Ethan Zhang yzhanginwa

View GitHub Profile
@yzhanginwa
yzhanginwa / gist:8eaf93e3174e1b8743c220a0b3daa987
Created December 9, 2021 18:02
To make deep sorted JSON string out of a Ruby Hash, Array, or Scalar
require 'json'
def to_deep_sorted_json(obj)
if obj.instance_of?(Array)
return '[' + obj.map{|o|to_deep_sorted_json(o)}.join(',') + ']'
end
if obj.instance_of?(Hash)
keys = obj.keys.sort
return '{' + keys.map{|k| JSON.generate(k) + ':' + to_deep_sorted_json(obj[k])}.join(',') + '}'
module ActiveAdmin
module Filters
module FormtasticAddons
alias :old_seems_searchable? :seems_searchable?
def seems_searchable?
return false if ransacker?
old_seems_searchable?
end
def klass
@yzhanginwa
yzhanginwa / git-pre-receive-hook.sh
Created November 17, 2016 15:44 — forked from caniszczyk/git-pre-receive-hook.sh
A reasonable git pre-receive-hook
#!/bin/sh
#
# For each ref, validate the commit.
#
# - It disallows deleting branches without a /.
# - It disallows non fast-forward on branches without a /.
# - It disallows deleting tags without a /.
# - It disallows unannotated tags to be pushed.
#! /usr/bin/env ruby
require 'watir-webdriver'
require 'openssl'
require 'open-uri'
require 'nokogiri'
# bad pinterest, having a bad cert
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE