Skip to content

Instantly share code, notes, and snippets.

@peterdalle
peterdalle / robots.txt
Created December 3, 2016 15:18
Robots.txt that makes sure Facebook and Twitter can crawl images on your site.
# Disallow everything.
User-agent: *
Disallow: /
# Certain social media sites are whitelisted to allow crawlers to access page markup when links to /images are shared.
User-agent: Twitterbot
Allow: /images
User-agent: facebookexternalhit
Allow: /images
@learner-long-life
learner-long-life / Rinkeby.md
Last active August 30, 2022 22:32
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

@kellyrmilligan
kellyrmilligan / s3Sync.sh
Created June 8, 2017 13:38
Sync files to s3 and set cache control headers
#!/bin/bash
if [[ "$1" != "" ]]; then
S3BUCKETNAME="$1"
else
echo ERROR: Failed to supply S3 bucket name
exit 1
fi
aws s3 sync build s3://$S3BUCKETNAME --delete --cache-control max-age=31536000,public
@dvdbng
dvdbng / vim-heroku.sh
Last active October 16, 2024 17:15
Run vim in heroku updated 2017
mkdir ~/vim
cd ~/vim
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
# Compiled on Jul 20 2017
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
export VIMRUNTIME="$HOME/vim/runtime"
export PATH="$HOME/vim:$PATH"
cd -
@giannisp
giannisp / gist:ebaca117ac9e44231421f04e7796d5ca
Last active July 14, 2024 18:27
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install [email protected]
brew unlink [email protected]
brew link postgresql
@mhluska
mhluska / gemini.sh
Last active November 22, 2017 15:33
Transfer money into Gemini exchange (no API, no Selenium)
#!/bin/bash
# Exit on error or unset variable.
set -e
set -u
source .env
# TODO: Find a builtin way to do this.
function urldecode() {
@mhluska
mhluska / visual_regression.rb
Last active May 6, 2025 16:15
Quick and dirty visual regression testing with Rails + Capybara + Selenium
# spec/rails_helper.rb
if ENV['SAVE_SCREENSHOTS']
module CapybaraElementExtensions
INTERACTION_METHODS = %i[set select_option unselect_option click
right_click double_click send_keys hover trigger drag_to execute_script
evaluate_script evaluate_async_script]
INTERACTION_METHODS.each do |method|
define_method method do |*args, &block|
@mhluska
mhluska / sanity.js
Created June 18, 2018 08:56
Sanity-ember-service
import Service, { inject as service } from '@ember/service';
export default Service.extend({
ajax: service(),
store: service(),
fastboot: service(),
client: null,
init() {
@mhluska
mhluska / user.rb
Last active September 13, 2018 12:21
Rails Many-to-many relationship generating incorrect SQL
class User < ApplicationRecord
has_many :order_items_bought,
-> { joins(:order).where.not(orders: { state: :expired }).order(created_at: :desc) },
foreign_key: :buyer_id,
class_name: :OrderItem
has_many :videos_bought,
-> { joins(:orders).select('DISTINCT ON (videos.id) videos.*').reorder('videos.id DESC') },
through: :order_items_bought,
source: :item,
@mhluska
mhluska / current-user.js
Last active September 3, 2018 10:51
Ember-simple-auth Current User Service
import Service, { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
export default Service.extend({
store: service(),
session: service(),
auth: alias('session.data.authenticated'),