Skip to content

Instantly share code, notes, and snippets.

Avatar

Ukaza Perdana ukazap

View GitHub Profile
@ukazap
ukazap / ubuntu-20.04-macbook-pro.md
Created Jan 10, 2021 — forked from johnjeffers/ubuntu-20.04-macbook-pro.md
Ubuntu 20.04 on a 15" Retina MacBook Pro (Mid-2014)
View ubuntu-20.04-macbook-pro.md

Ubuntu 20.04 on a 15" Retina MacBook Pro (Mid-2014)

These are notes from my efforts to get Ubuntu 20.04 installed on my older MacBook Pro. I'm making this gist public in the hopes that it's helpful to others.

I did a Minimal install, but selected the option to install additional 3rd-party drivers.

Wifi doesn't work during the install (because it requires a 3rd-party driver), so you won't be able to choose to download updates while installing. No big deal, run a software update after the install.

The installer takes about 25 minutes to complete. Post-install, most things work. The only driver I had to manually install was for the FaceTime camera. More on that below.

View gist:d250054cdad76e38a472f471a341d760
FROM ukazap/ruby:dev-bionic-2.6.3 AS dev
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt install -y tmux nodejs && npm install -g yarn && \
/usr/bin/rbenv exec gem install foreman
WORKDIR /app
EXPOSE 3000
EXPOSE 3035
ENV WEBPACKER_DEV_SERVER_HOST=0.0.0.0
CMD /bin/bash
@ukazap
ukazap / environment.js
Created Sep 24, 2019 — forked from wingrunr21/environment.js
Simple webpacker server side rendering
View environment.js
const webpack = require('webpack')
const { environment } = require('@rails/webpacker')
// Don't use commons chunk for server_side_render chunk
const entries = environment.toWebpackConfig().entry
const commonsChunkEligible = Object.keys(entries).filter(name => name !== 'server_side_render')
environment.plugins.set('CommonsChunkVendor', new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: (module, count) => {
@ukazap
ukazap / ping_pong.rb
Last active Sep 7, 2019
Rack middleware for GAE health check without a trip to DB
View ping_pong.rb
module PingPong # App Engine health check without a trip to DB
class Middleware
def initialize app, ping_path = '/status'
@app = app
@ping_path = ping_path
Rails.backtrace_cleaner.add_silencer { |line| line =~ /#{File.basename(__FILE__)}/ }
end
def pong_code
200
@ukazap
ukazap / read-access.sql
Created Jul 4, 2019 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
View read-access.sql
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@ukazap
ukazap / Dockerfile
Last active May 19, 2019
Debian Stretch + Ruby 2.6.3 + Nodejs + Yarn + Google Cloud SDK
View Dockerfile
FROM bitnami/ruby:2.6.3
ARG DEBIAN_VERSION="stretch"
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | \
tee /etc/apt/sources.list.d/yarn.list && \
echo "deb http://packages.cloud.google.com/apt cloud-sdk-$DEBIAN_VERSION main" | \
tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
@ukazap
ukazap / exponential_backoff.rb
Created Mar 5, 2019 — forked from nathanl/exponential_backoff.rb
Exponential backoff in Ruby
View exponential_backoff.rb
# Exponential backoff in Ruby
begin
make_request
rescue RequestError => e
if retries <= max_retries
retries += 1
sleep 2 ** retries
retry
else
raise "Timeout: #{e.message}"
View my_map.rb
class Array
def my_map
self.reduce([]) do |new_array, element|
new_array.push(yield(element))
end
end
end
[1, 2, 3].my_map { |x| x * 2 }
#=> [2, 4, 6]
@ukazap
ukazap / import_csv.rb
Last active Dec 2, 2018
Import passwords from a CSV file to password store (https://www.passwordstore.org)
View import_csv.rb
# Put this script in ~/.password-store alongside import.csv
# This script requires the CSV to have these columns:
# `title`, `username`, `password`, `additional_secret`
require "csv"
require "fileutils"
require "gpgme" # gem install gpgme
gpg_recipients = "hello@ukazap.space"
@ukazap
ukazap / Dockerfile
Created Nov 27, 2018
Tried and true Dockerfile for custom Rails 5 runtime in Google App Engine
View Dockerfile
# This Dockerfile for a Ruby application was generated by gcloud.
# The base Dockerfile installs:
# * A number of packages needed by the Ruby runtime and by gems
# commonly used in Ruby web apps (such as libsqlite3)
# * A recent version of NodeJS
# * A recent version of the standard Ruby runtime to use by default
# * The bundler gem
FROM gcr.io/google-appengine/ruby:latest