Skip to content

Instantly share code, notes, and snippets.

View uchilaka's full-sized avatar

Uchenna Chilaka uchilaka

View GitHub Profile
@uchilaka
uchilaka / mock_dialogs.js
Created November 13, 2020 17:05 — forked from apeckham/mock_dialogs.js
mock javascript alert, confirm, prompt
var MockPrompt = {
install: function() {
MockPrompt.message = undefined;
MockPrompt.value = undefined;
MockPrompt.returnValue = undefined;
MockPrompt.originalPrompt = window.prompt;
window.prompt = function(message, value) {
MockPrompt.message = message;
MockPrompt.value = value;
@shwei
shwei / fastify-in-firebase-function.js
Last active July 4, 2021 07:38
Use fastify in firebase function
'use strict';
const functions = require('firebase-functions');
const fastify = require('./fastify');
exports.greetFromFastify = functions.https.onRequest(fastify);
@uchilaka
uchilaka / .eslintrc.js
Last active October 5, 2020 13:28
A Google Cloud Function that acts on new Storage File objects, extracts EXIF data using ImageMagick and parses out text content using the Google Cloud Vision API
module.exports = {
parser: "babel-eslint",
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures: {
modules: true,
//experimentalObjectRestSpread: true
}
},
@Chocksy
Chocksy / kill_sidekiq_job.rb
Last active April 25, 2024 14:07
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
@ncochard
ncochard / babel-webpack.md
Last active September 29, 2023 05:15
The correct way to compile ES6 using babel...

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
@dillansimmons
dillansimmons / passUTM.js
Last active January 11, 2024 18:00
Pass current UTMS to in page links Javascript
// JS for grabbing utm params and parsing into url
var getRefQueryParam = function() {
var temp = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
var decode = function(s) {
return decodeURIComponent(s.split("+").join(" "));
};
temp[decode(arguments[1])] = decode(arguments[2]);
});
return temp;
@rambabusaravanan
rambabusaravanan / .gitconfig
Last active April 30, 2024 04:40
Git Diff and Merge Tool - IntelliJ IDEA
# Linux
# add the following to "~/.gitconfig" file
[merge]
tool = intellij
[mergetool "intellij"]
cmd = /usr/local/bin/idea merge $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")
trustExitCode = true
[diff]
@tonysneed
tonysneed / Mac OS X: Open in Visual Studio Code
Last active March 27, 2024 10:02
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@radavis
radavis / .railsrc
Last active March 22, 2024 16:42
Using .railsrc and a Rails Template
# ~/.railsrc
--database=postgresql
--skip-bundle
--skip-spring
--skip-test-unit
--skip-turbolinks
--template=/path/to/rails_template.rb
@bkrauska
bkrauska / gist:9742260
Last active August 4, 2022 06:57
DiffMerge git mergetool & difftool setup
Install http://download-us.sourcegear.com/DiffMerge/4.2.0/DiffMerge_4.2.0.697.stable_x64.msi
// this is an adaptation of http://adventuresincoding.com/2010/04/how-to-setup-git-to-use-diffmerge
Then run the following commands from the git bash
git config --global merge.tool diffmerge
git config --global mergetool.diffmerge.cmd "sgdm --merge --result=\$MERGED \$LOCAL \$BASE \$REMOTE"