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
@fongfan999
fongfan999 / vietnamese_sanitizer.rb
Last active September 25, 2019 10:28
Ruby script to sanitize Vietnamese "marks"
dic = {
'áàảãạăắặằẳẵâấầẩẫậ': 'a',
'ÁÀẢÃẠĂẮẶẰẲẴÂẤẦẨẪẬ': 'A',
'đ': 'd',
'Đ': 'D',
'éèẻẽẹêếềểễệ': 'e',
'ÉÈẺẼẸÊẾỀỂỄỆ': 'E',
'íìỉĩị': 'i',
'ÍÌỈĨỊ': 'I',
'óòỏõọôốồổỗộơớờởỡợ': 'o',

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 / _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 / gist:b146632acbd71ac797deed61803c66eb
Created June 3, 2017 06:20 — forked from ryansobol/gist:5252653
15 Questions to Ask During a Ruby Interview

Originally published in June 2008

When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.

To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.

What to expect

Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.