Skip to content

Instantly share code, notes, and snippets.

View fongfan999's full-sized avatar
🏠
Working from home

Phong Phan fongfan999

🏠
Working from home
View GitHub Profile
@fongfan999
fongfan999 / kill_sidekiq_job.rb
Created March 18, 2023 06:23 — forked from Chocksy/kill_sidekiq_job.rb
Kill sidekiq jobs by process id for busy jobs and by jid for other sets.
# FOR BUSY JOBS
# take the process_id from the /busy page in sidekiq and kill the longest running one.
workers = Sidekiq::Workers.new
long_process_id = 'integration.3:4:71111aaa111' # Eg: 'integration.3:4:71d1d7f4ef5a'
workers.each do |process_id, thread_id, work|
process = Sidekiq::Process.new('identity' => process_id)
process.stop! if process_id == long_process_id
end
# FOR SCHEDULED JOBS
@fongfan999
fongfan999 / Gemfile
Created January 22, 2023 11:20 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@fongfan999
fongfan999 / test.js
Created November 18, 2022 18:00
Testing js
!function(t,e){"object"==typeof module&&"object"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error("jQuery requires a window with a document");return e(t)}:e(t)}("undefined"!=typeof window?window:this,function(f,t){function e(t,e){return e.toUpperCase()}var i=[],c=i.slice,g=i.concat,a=i.push,n=i.indexOf,s={},o=s.toString,m=s.hasOwnProperty,v={},_=f.document,r="2.1.4",C=function(t,e){return new C.fn.init(t,e)},l=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,h=/^-ms-/,u=/-([\da-z])/gi;function d(t){var e="length"in t&&t.length,i=C.type(t);return"function"!==i&&!C.isWindow(t)&&(!(1!==t.nodeType||!e)||("array"===i||0===e||"number"==typeof e&&0<e&&e-1 in t))}C.fn=C.prototype={jquery:r,constructor:C,selector:"",length:0,toArray:function(){return c.call(this)},get:function(t){return null!=t?t<0?this[t+this.length]:this[t]:c.call(this)},pushStack:function(t){var e=C.merge(this.constructor(),t);return e.prevObject=this,e.context=this.context,e},each:function(t,e){return C.each(
@fongfan999
fongfan999 / README.md
Created May 28, 2020 16:42 — forked from bazzel/README.md
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
@fongfan999
fongfan999 / web-fonts-asset-pipeline.md
Created May 24, 2020 09:13 — forked from anotheruiguy/web-fonts-asset-pipeline.md
Custom Web Fonts and the Rails Asset Pipeline

Web fonts are pretty much all the rage. Using a CDN for font libraries, like TypeKit or Google Fonts, will be a great solution for many projects. For others, this is not an option. Especially when you are creating a custom icon library for your project.

Rails and the asset pipeline are great tools, but Rails has yet to get caught up in the custom web font craze.

As with all things Rails, there is more then one way to skin this cat. There is the recommended way, and then there are the other ways.

The recommended way

Here I will show how to update your Rails project so that you can use the asset pipeline appropriately and resource your files using the common Rails convention.

@fongfan999
fongfan999 / fix-libv8-mac.txt
Created September 26, 2019 10:54 — forked from fernandoaleman/fix-libv8-mac.txt
Fixing libv8 and therubyracer on Mac
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8@3.15
bundle install

Keybase proof

I hereby claim:

  • I am fongfan999 on github.
  • I am fongfan999 (https://keybase.io/fongfan999) on keybase.
  • I have a public key ASAGuim3XRqDxYHLCi2OtkBsYUX0bCBNplitMOmCCtSY2Ao

To claim this, I am signing this object:

@fongfan999
fongfan999 / facebook-sdk.js
Last active December 2, 2018 08:13
Turbolinks 5 & Facebook SDK & ES6
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.1&appId=YOUR_APP_ID&autoLogAppEvents=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, "script", "facebook-jssdk"));
document.addEventListener("DOMContentLoaded", () => {
let fbRoot;
@fongfan999
fongfan999 / _comment.html.slim
Created November 22, 2018 04:05 — forked from dbridges/_comment.html.slim
Stimulus.js and Rails remote forms with error handling
- # app/views/comments/_comment.html.slim
li data-controller="comment" data-action="click->comment#hello"
= "#{comment.message} by #{comment.user.email}"
@fongfan999
fongfan999 / rails_webpacker_bootstrap_expose_jquery.md
Created November 2, 2018 10:01 — forked from andyyou/rails_webpacker_bootstrap_expose_jquery.md
Rails 5.2 with webpacker, bootstrap, stimulus starter

Rails 5.2 with webpacker, bootstrap, stimulus starter

This gist will collect all issues we solved with Rails 5.2 and Webpacker

Create Project

# Last few parameters(--skip-* part) is only my habbit not actully required
$ rails new <project_name> --webpack=stimulus --database=postgresql --skip-coffee --skip-test