Skip to content

Instantly share code, notes, and snippets.

# 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 February 22, 2021 03:10
Dockerfile for Ruby 2.3 on Gitpod
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 January 31, 2021 06:36 — forked from aymericbeaumet/delete-likes-from-twitter.md
[Recipe] Delete all your likes/favorites from Twitter

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 August 28, 2020 03:27
Virtual Column Index for ahoy_events table
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 July 18, 2020 12:57
How to migrate from jquery-ujs to rails-ujs - replace
- //= jquery_ujs
+ //= require rails-ujs
@kevinhq
kevinhq / example.html.erb
Created July 18, 2020 12:18
How to migrate from jquery-ujs to rails-ujs - step 1
<script src="/assets/jquery.js"></script>
<script src="/assets/jquery_ujs.js"></script>
@kevinhq
kevinhq / production.js
Created July 15, 2020 05:21
Step-by-Step guide on how to move from Sprockets to Webpacker - production.js
// config/webpack/production.js
process.env.NODE_ENV = 'production';
const environment = require('./environment');
module.exports = environment.toWebpackConfig();
@kevinhq
kevinhq / erb.js
Created July 15, 2020 05:16
Step-by-Step guide on how to move from Sprockets to Webpacker - 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 July 15, 2020 05:13
Step-by-Step guide on how to move from Sprockets to Webpacker - custom_loader.js
// config/webpack/loaders/custom_loaders.js
module.exports = {
test: /\.ya?ml$/,
loaders: ['json-loader', 'yaml-loader']
};
@kevinhq
kevinhq / example2.js
Created July 10, 2020 04:55
Step-by-Step guide on how to move from Sprockets to Webpacker - packs/example2.js
/* app/javascript/packs/example2.js */
// to call example1 var, you need:
import example1 from './example1';