Skip to content

Instantly share code, notes, and snippets.

@mhluska
mhluska / fix-fastmail-1password.js
Created September 19, 2022 00:21
Fix for Fastmail Masked Email + 1Password Firefox extension prefill
for (const elem of document.querySelectorAll('[type="email"],[placeholder*=email i],[aria-label*=email i]')) {
const prevName = elem.name;
const clone = elem.cloneNode();
clone.name = 'email';
elem.replaceWith(clone);
setTimeout(() => { clone.replaceWith(elem) }, 5000);
}
I was drawn to programming, science, technology and science fiction
ever since I was a little kid. I can't say it's because I wanted to
make the world a better place. Not really. I was simply drawn to it
because I was drawn to it. Writing programs was fun. Figuring out how
nature works was fascinating. Science fiction felt like a grand
adventure.
Then I started a software company and poured every ounce of energy
into it. It failed. That hurt, but that part is ok. I made a lot of
mistakes and learned from them. This experience made me much, much
@mhluska
mhluska / fixtures.js
Last active March 13, 2019 22:43
No circular reference
const util = require('util')
norm_widget_1 = {
'foo': 1,
'bar': 'baz',
'_jv': {
'type': 'widget',
'id': '1',
'relationships': {
'widgets': {
@mhluska
mhluska / document.js
Last active September 7, 2018 12:09
Simulate document.querySelector() in Ember FastBoot
import Service, { inject as service } from '@ember/service';
import { getOwner } from '@ember/application';
import { computed } from '@ember/object';
export default Service.extend({
fastboot: service(),
init() {
this._elemCache = {};
this._super(...arguments);
@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'),
@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 / 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 / visual_regression.rb
Last active June 10, 2018 12:52
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 / 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() {
@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