Skip to content

Instantly share code, notes, and snippets.

View TSMMark's full-sized avatar
🐶

Mark Allen TSMMark

🐶
View GitHub Profile
@TSMMark
TSMMark / useYouTubeIframeAPIReady.ts
Created January 28, 2021 01:02
React hook to return boolean true once the YouTube Iframe API is ready (onYouTubeIframeAPIReady)
const useYouTubeIframeAPIReady = (): boolean => {
const [isReady, setIsReady] = useState<boolean>(false)
useEffect(() => {
if (window.YT.Player) {
setIsReady(true)
return
}
window['onYouTubeIframeAPIReady'] = () => {
@TSMMark
TSMMark / check_parameter_types.rb
Created February 10, 2021 01:44
Check if a method has kwargs and/or ordered params
# Has kwargs? (Keyword arguments)
def method_has_keyword_parameters?(method)
method.parameters.any? do |param|
type, _name = param
type == :key
end
end
# Has ordered arguments?
@TSMMark
TSMMark / update_with_latest_master.yml
Last active January 7, 2025 16:01
GH Action Workflow to merge master into current branch when a label is added to a PR
# .github/workflows/update_with_latest_master.yml
#
# This is a Github Action Workflow to merge master into current branch when a label is added to a PR.
# Label: `update with latest master`
#
# 1) Add this yml file to your github workflows directory.
# 2) Add the issue/pr label: `update with latest master` to your project.
# 3) Any time you want to merge master into a branch, just add the `update with latest master` label to it!
#
# NOTE: This will trigger a new commit on your branch, potentially triggering CI, and other workflows.
@TSMMark
TSMMark / pipe.js
Created September 9, 2021 17:07
Ben Lesh's Pipe function
// https://twitter.com/BenLesh/status/1435711312617746432
const pipe = (start, ...fns) => fns.reduce((prev, fn) => fn(prev), start);
// Example usage:
// pipe(source, map(fn), filter(fn))
@TSMMark
TSMMark / ._README.md
Last active April 30, 2022 21:04
alias `binding.pry` as `debugger` in .pryrc pry config file

alias binding.pry as debugger in .pryrc pry config file

The Problem

In my experience, debugger is easier for people to remember and to type. And so most devs on our team prefer typing debugger over binding.pry. However, debugger is worse than binding.pry because it doesn't use Pry, which is better than standard byebug / irb repl.

The Solution

Alias binding.pry as debugger. Now we should be able to use debugger and binding.pry interchangeably, and it will always use Pry!