Skip to content

Instantly share code, notes, and snippets.

View dcorking's full-sized avatar

David Corking dcorking

View GitHub Profile
@brickgale
brickgale / .htaccess
Last active January 28, 2022 16:24
Laravel force https for Heroku
#add this on public/.htaccess for Laravel
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@dcorking
dcorking / rails_helper.rb
Last active May 17, 2017 07:58
rails_helper or spec_helper snippet to trace the clock before and after each rspec example
ENV["RAILS_ENV"] ||= 'test'
require 'spec_helper'
# ...
RSpec.configure do |config|
# Can help you spot problems with system time, timezones and time travel,
# especially if multiple specs interact with each other
# Check this doc for the difference between ::now and ::current :
# http://api.rubyonrails.org/classes/ActiveSupport/Testing/TimeHelpers.html#method-i-travel_to
config.around(:each) do |example|
puts "Time.now: #{Time.now}"
@iisaint
iisaint / connect_unlockAccount.js
Created March 1, 2017 05:26
Connect to a parity node
/*
* connect to ethereum node
*/
const ethereumUri = 'http://localhost:8540';
const address = '0x004ec07d2329997267Ec62b4166639513386F32E'; // user
let web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider(ethereumUri));
if(!web3.isConnected()){
@iisaint
iisaint / connect.js
Created March 1, 2017 05:21
Using node.js to connect to parity node
const Web3 = require('web3');
/*
* connect to ethereum node
*/
const ethereumUri = 'http://localhost:8540';
let web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider(ethereumUri));
@BretFisher
BretFisher / docker-for-mac.md
Last active March 31, 2025 10:12
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@xavierlepretre
xavierlepretre / promisifyWeb3.js
Created January 8, 2017 17:36
Convert `web3` asynchronous calls into Promises.
module.exports = {
promisify: function (web3) {
// Pipes values from a Web3 callback.
var callbackToResolve = function (resolve, reject) {
return function (error, value) {
if (error) {
reject(error);
} else {
resolve(value);
}
@peterdemartini
peterdemartini / command.sh
Last active March 6, 2025 07:29
Exclude node_modules in timemachine
find `pwd` -type d -maxdepth 3 -name 'node_modules' | xargs -n 1 tmutil addexclusion
@dcorking
dcorking / one_liners.sh
Created August 3, 2016 08:12
One liners I wish I had thought of before now
# preview the most recently modified file in the current directory
ls -t |head -n 1 | xargs less # sadly less drops out on SIGINT
@dduvnjak
dduvnjak / add_cloudflare_ips.sh
Last active April 20, 2025 05:41
Add CloudFlare IP addresses to an EC2 Security Group using awscli
# first we download the list of IP ranges from CloudFlare
wget https://www.cloudflare.com/ips-v4
# set the security group ID
SG_ID="sg-00000000000000"
# iterate over the IP ranges in the downloaded file
# and allow access to ports 80 and 443
while read p
do
@CMCDragonkai
CMCDragonkai / curl_custom_dns.sh
Last active December 23, 2024 19:58
cURL: Selecting a custom DNS server to resolve domain names
#!/usr/bin/env bash
# this can be useful when developing against a custom DNS server, or
# for example, if you made a change to the DNS settings of a domain, and you
# know the authoritative nameserver IP address for a domain, you could use this
# to bypass the intermediate DNS cache, and apply an HTTP request using the new
# DNS settings supplied by your specified (authoritative) nameserver
curl --dns-servers <DNSIP,DNSIP> url.com