Skip to content

Instantly share code, notes, and snippets.

View carlflor's full-sized avatar

Carl Flor carlflor

View GitHub Profile
@carlflor
carlflor / areJsonStringsSimilar.js
Created July 6, 2023 16:54
compare if two json strings are similar
function areJsonStringsSimilar(jsonString1, jsonString2) {
function areArraysSimilar(arr1, arr2) {
if (arr1.length !== arr2.length) return false;
for (let i = 0; i < arr1.length; i++) {
if (typeof arr1[i] === 'object') {
if (!areObjectsSimilar(arr1[i], arr2[i])) return false;
} else if (arr1[i] !== arr2[i]) {
return false;
}
const debounce = (func, wait = 1000) => {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
on alfred_script(q)
tell application "iTerm2"
activate
do script q
end tell
end alfred_script
@carlflor
carlflor / new-mac-setup.md
Last active July 20, 2018 10:18
Yay, new Mac! Let's set up!

simple dev environment

NOTE: $ indicates the following command should be done in command line. Do not include the $ in your command.

  1. iTerm2 - (unless you want to use default Terminal mac app)

  2. Xcode Command Line Tools (also includes git)

# cd and new tab stuff
tell application "iTerm2"
tell current window
tell current session
write text "cd ~/go/somewhere"
write text "clear"
end tell
create tab with default profile
tell current tab
#sample setup for vcr gem
#spec/support/vcr.rb
require 'vcr'
VCR.configure do |c|
c.cassette_library_dir = 'spec/support/cassettes'
c.hook_into :webmock
c.ignore_localhost = true
c.configure_rspec_metadata!
c.allow_http_connections_when_no_cassette = true
@carlflor
carlflor / Gemfile-lock-fix.md
Created May 25, 2016 07:03
This fixes the Gemfile.lock conflict when doing git rebase

If both the upstream and your feature branch have made changes to Gemfile, you will likely receive merge conflicts on Gemfile.lock when you rebase your feature branch. Don't try to resolve these manually; you'll probably just screw it up. Instead do this:

    git checkout --ours Gemfile.lock
    bundle
    git add Gemfile.lock
    git rebase --continue

This ensures that you get a correct Gemfile.lock at each step along the way.

@carlflor
carlflor / gist:b7c50801fa21a62c58f9
Created March 11, 2015 03:36
AlertView for Swift (iOS)
if self.reviews.count == 0 {
var alert = UIAlertController(title: "Whoops...", message: "No reviews yet!", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Okay",
style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) in
self.navigationController?.popViewControllerAnimated(true)
return //force return since popViewControllerAnimated(true) returns a ViewController instead of void
}))
//alternative action
/*alert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { action in