Skip to content

Instantly share code, notes, and snippets.

@turadg
turadg / Dockerfile
Created March 12, 2024 13:17
a3p image builders
#----------------
# upgrade-8
#----------------
## START
# on agoric-upgrade-7-2, with upgrade to agoric-upgrade-8
FROM ghcr.io/agoric/ag0:agoric-upgrade-7-2 as prepare-upgrade-8
ENV UPGRADE_TO=agoric-upgrade-8
# put env functions into shell environment
@turadg
turadg / subdomains.rb
Last active January 21, 2024 19:45 — forked from rtekie/subdomains.rb
Drop-in utility to test your app subdomains with Capybara, Rspec, and a Javascript driver (Poltergeist, Webkit, or Selenium)
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
# (e.g. save as spec/support/subdomains.rb)
def switch_to_subdomain(subdomain)
# lvh.me always resolves to 127.0.0.1
hostname = subdomain ? "#{subdomain}.lvh.me" : "lvh.me"
Capybara.app_host = "http://#{hostname}"
end
@turadg
turadg / github-expand-project-sidebar.user.js
Last active September 16, 2023 03:48
Focus the Checks view on the selected result type
// ==UserScript==
// @name GitHub project sidebar opener
// @namespace http://tampermonkey.net/
// @version 0.1
// @description On GitHub issue pages, expand the Projects sidebar by default
// @author Turadg Aleahmad
// @run-at document-idle
// @match https://github.com/*
// @require https://greasyfork.org/scripts/398877-utils-js/code/utilsjs.js?version=877686
// @icon https://github.githubassets.com/pinned-octocat.svg
@turadg
turadg / resolv.conf
Last active October 29, 2022 22:53
# Hard-code DNS resolver to Google's servers
#
# *Setup*
# # download this file while DNS is working
# curl https://gist.github.com/turadg/7876784/raw --output ~/google-resolv.conf
# # replace your old DNS resolver
# sudo cp /etc/resolv.conf /etc/resolv.conf.auto && sudo mv ~/google-resolv.conf /etc/resolv.conf
# # make it uneditable so Vagrant doesn't clobber it
# sudo chattr +i /etc/resolv.conf
@turadg
turadg / application.rb
Last active May 14, 2019 06:04
Handle only 404s dynamically. It uses a normal controller and route for 404s, letting everything else go to the Rails default /public error pages. In my case it was to use the subdomain logic in my ApplicationController.
module MyApp
class Application < Rails::Application
require Rails.root + 'lib/custom_public_exceptions'
config.exceptions_app = CustomPublicExceptions.new Rails.public_path
end
end
@turadg
turadg / install-ruby-2.0.0.sh
Last active August 9, 2018 06:58 — forked from sferik/install-ruby-2.0.0.sh
Install Ruby 2.0 with Readline and latest OpenSSL
#!/usr/bin/env sh
brew update
# upgrade any that were already installed
brew upgrade rbenv ruby-build readline openssl
# install what's missing
brew install rbenv ruby-build readline openssl
@turadg
turadg / generateFlowModuleNameMappers.js
Last active June 20, 2018 06:28
Helper to create .flowconfig module name mapper
#!/usr/bin/env node
/**
* Flowtype understands Node (or Haste) imports but not Webpack.
*
* Many codebases have webpack set up like:
* src/foo.js
* src/components/Bar.jsx
*
* And then import them like `require('foo')` or `require/components/Bar.jsx`
*
@turadg
turadg / silence-React-15-deprecations.js
Last active April 13, 2018 18:46
Jest setup file to stop React 15.5 createClass / PropTypes deprecation warnings
import React from 'react';
/**
* Since React v15.5, there's a warning printed if you access `React.createClass` or `React.PropTypes`
* https://reactjs.org/blog/2017/04/07/react-v15.5.0.html#new-deprecation-warnings
*
* `import * as React from 'react'` is required by Flowtype https://flow.org/en/docs/react/types/ ,
* but the * causes both those deprecated getters to be called.
* This is particularly annoying in Jest since every test prints two useless warnings.
*
@turadg
turadg / removeUnusedModules.sh
Created December 8, 2017 02:54
Find in webpack builds modules that are never imported
#!/bin/bash
echo "Testing prod build for modules in src that aren't ever imported."
echo
echo "NOTE: Any dev-only imports will appear to be unused."
USED_LIST_PATH=usedModules.txt
STATS_PATH=public/assets/stats.json
@turadg
turadg / rake.sh
Created February 23, 2011 16:28
Bash completion for ruby Rake
# bash completion for rake
#
# some code from on Jonathan Palardy's http://technotales.wordpress.com/2009/09/18/rake-completion-cache/
# and http://pastie.org/217324 found http://ragonrails.com/post/38905212/rake-bash-completion-ftw
#
# For details and discussion
# http://turadg.aleahmad.net/2011/02/bash-completion-for-rake-tasks/
#
# INSTALL
#