Skip to content

Instantly share code, notes, and snippets.

View wout's full-sized avatar
🕳️

Wout wout

🕳️
View GitHub Profile
@akiatoji
akiatoji / gist:3044056
Created July 3, 2012 23:06
Nginx + Passenger 3 + RVM for Rack app on OS X using homebrew only

Most examples I found tell you to run rvmsudo or passenger-install-nginx-module. I ran into problems with these because:

  1. rvmsudo leaves root owned directories and files under rvm passenger gem directory. This will give you seemingly odd errors later when you try to remove/upgrade passenger gem, or try to use homebrew to install passenger.

  2. There's no good place to put nginx using passenger-install-nginx-module. Putting it under /usr/local means you have to remember it's there amongst homebrew files. Anywhere else, you still have to remember you put it there. We'd rather manage nginx install via homebrew.

So to install everything with homebrew, this is what it took:

gem install passenger
@stephendolan
stephendolan / lucky_spec_action.yml
Last active April 27, 2020 21:48
GitHub Action - Lucky Setup and Spec
name: Lucky Build and Spec CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
@fernandes
fernandes / Dockerfile
Last active June 20, 2020 06:16
Docker multi stage build for Lucky Framework app
FROM crystallang/crystal:0.34.0-alpine-build AS build-env
ARG LUCKY_ROOT=/app
ARG DEV_PACKAGES="nodejs yarn"
ENV LUCKY_ENV=production
ENV NODE_ENV=production
WORKDIR $LUCKY_ROOT
# install packages
RUN apk update \
@vuongpd95
vuongpd95 / rails-docker-compose.md
Created September 27, 2020 13:53
docker-compose for Rails application on Local
# docker/webapp/Dockerfile
FROM ruby:2.6.6

SHELL ["/bin/bash", "-c"]
RUN apt-get update -qq && apt-get install -y postgresql-client memcached tzdata nano
# Install node 12, yarn
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
@kjellm
kjellm / app.rb
Last active July 26, 2021 04:46
Event Source proof of concept. Copyright 2017 Kjell-Magne Øierud. License: MIT https://opensource.org/licenses/MIT
require_relative 'base'
require_relative 'event'
require_relative 'cmd'
require_relative 'crud'
require_relative 'model'
require_relative 'read'
require 'pp'
class Application < BaseObject
@YusukeHosonuma
YusukeHosonuma / map_filter.hs
Created May 8, 2016 13:19
Haskell - implement map and filter functions by recursion and foldr versions.
-- | recursion version
map' :: (a -> b) -> [a] -> [b]
map' _ [] = []
map' f (x:xs) = f x : map' f xs
filter' :: (a -> Bool) -> [a] -> [a]
filter' _ [] = []
filter' f (x:xs)
| f x = x : (filter' f xs)
@julienma
julienma / README.md
Last active November 10, 2021 13:04
How to install Discourse 2.4+ on Dokku (2019)
@mstruve
mstruve / redis.rb
Created November 16, 2018 19:48
Redis Readonly Console
if ENV['REDIS_ACCESS_MODE'] == 'readonly'
class Redis
class Client
WRITE_COMMANDS = ::Rails.cache.data.command.map { |a| a[0] if a[2].include?('write') }.compact.to_set.freeze
def process(commands)
if commands.flatten.any? { |c| WRITE_COMMANDS.include?(c.to_s) }
raise NotImplementedError, "REDIS_ACCESS_MODE is set to 'readonly', disallowing writes"
end
require 'openssl'
def verify_sign(key, signature, data)
# Verifies with a public key that the data was signed with their private key
pubkey = key.public_key
if pubkey.verify(OpenSSL::Digest::SHA256.new, signature, data)
puts 'the signature is valid'
else
puts 'the signature is invalid'
end
end
@somebox
somebox / presenters.md
Last active March 26, 2022 02:12
Thoughts About Rails Presenters

Thoughts about Rails Presenters

This is a collection of links, examples and rants about Presenters/Decorators in Rails.


The "Decorator" pattern slowly started gaining popularity in Rails several years ago. It is not part of core Rails, and there's many different interpretations about how it should work in practice.

Jay Fields wrote about it in 2007 (before he switched back to Java and then Clojure): http://blog.jayfields.com/2007/03/rails-presenter-pattern.html