Skip to content

Instantly share code, notes, and snippets.

View gist:a1c51b8684e4211b4518ae287dd38359
# http://stackoverflow.com/questions/4673391/why-doesnt-haml-check-find-this-glaring-syntax-error
haml -c newsletter.html.haml
haml --debug newsletter.html.haml 2> /dev/null | sed '$d' | ruby -c
@kevinhq
kevinhq / Dockerfile
Created Feb 22, 2021
Dockerfile for Ruby 2.3 on Gitpod
View Dockerfile
FROM ubuntu:16.04
RUN apt-get update
### base ###
RUN apt-get update && \
apt-get install -yq build-essential sudo vim wget links curl rsync bc git git-core apt-transport-https libxml2 \
libxml2-dev libcurl4-openssl-dev openssl sqlite3 libsqlite3-dev gawk libreadline6-dev libyaml-dev autoconf \
libgdbm-dev libncurses5-dev automake zlib1g-dev libgmp-dev libssl-dev libmysqlclient-dev libpq-dev gnupg2 && \
rm -rf /var/lib/apt/lists/*
@kevinhq
kevinhq / delete-likes-from-twitter.md
Created Jan 31, 2021 — forked from aymericbeaumet/delete-likes-from-twitter.md
[Recipe] Delete all your likes/favorites from Twitter
View delete-likes-from-twitter.md

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('div[data-testid="unlike"]')) {
    d.click()
 }
@kevinhq
kevinhq / add_virtual_column_index_to_ahoy_events.rb
Created Aug 28, 2020
Virtual Column Index for ahoy_events table
View add_virtual_column_index_to_ahoy_events.rb
class AddVirtualColumnIndexToAhoyEvents < ActiveRecord::Migration[6.0]
def up
ActiveRecord::Base.connection.execute (
'ALTER TABLE ahoy_events ADD properties_id INT AS (JSON_UNQUOTE(properties->"$.id")) STORED;'
)
ActiveRecord::Base.connection.execute (
'ALTER TABLE ahoy_events ADD INDEX (properties_id);'
)
end
def down
@kevinhq
kevinhq / application.js
Created Jul 18, 2020
How to migrate from jquery-ujs to rails-ujs - replace
View application.js
- //= jquery_ujs
+ //= require rails-ujs
@kevinhq
kevinhq / example.html.erb
Created Jul 18, 2020
How to migrate from jquery-ujs to rails-ujs - step 1
View example.html.erb
<script src="/assets/jquery.js"></script>
<script src="/assets/jquery_ujs.js"></script>
@kevinhq
kevinhq / production.js
Created Jul 15, 2020
Step-by-Step guide on how to move from Sprockets to Webpacker - production.js
View production.js
// config/webpack/production.js
process.env.NODE_ENV = 'production';
const environment = require('./environment');
module.exports = environment.toWebpackConfig();
@kevinhq
kevinhq / erb.js
Created Jul 15, 2020
Step-by-Step guide on how to move from Sprockets to Webpacker - erb.js
View erb.js
// config/webpack/loaders/erb.js
module.exports = {
test: /\.erb$/,
enforce: 'pre',
exclude: /node_modules/,
use: [{
loader: 'rails-erb-loader',
options: {
runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner'
}
@kevinhq
kevinhq / custom_loader.js
Created Jul 15, 2020
Step-by-Step guide on how to move from Sprockets to Webpacker - custom_loader.js
View custom_loader.js
// config/webpack/loaders/custom_loaders.js
module.exports = {
test: /\.ya?ml$/,
loaders: ['json-loader', 'yaml-loader']
};
@kevinhq
kevinhq / example2.js
Created Jul 10, 2020
Step-by-Step guide on how to move from Sprockets to Webpacker - packs/example2.js
View example2.js
/* app/javascript/packs/example2.js */
// to call example1 var, you need:
import example1 from './example1';