Skip to content

Instantly share code, notes, and snippets.

View knapo's full-sized avatar
⛰️

Krzysztof Knapik knapo

⛰️
View GitHub Profile
@knapo
knapo / class_ext_infinite_loop.rb
Last active July 28, 2021 09:34
class_ext_infinite_loop.rb
class Foo
def bar
puts 'bar'
end
end
module FooExt
def bar
puts 'ext bar'
super
@knapo
knapo / semaphore.yml
Created February 27, 2021 06:19
Skip semaphore job on certain github PR labels
jobs:
- name: Run my job
commands:
# Get PR labels from github api
- >
if [ ! -z "$SEMAPHORE_GIT_PR_NUMBER" ];
then
export PR_DETAILS=$(curl -fsS -H "Accept: application/vnd.github.v3+json" -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/ORG_NAME/REPO_NAME/pulls/$SEMAPHORE_GIT_PR_NUMBER);
export PR_LABELS=$(echo $PR_DETAILS | tr '\r\n' ' ' | jq '.labels[] | .name');
fi
@knapo
knapo / Dockerfile
Created January 22, 2021 07:14
ruby + unoconv + puppeteer on alpine Dockerfile
FROM ruby:2.7-alpine as base
ENV APP_HOME /home/app
ENV GROVER_NO_SANDBOX true
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
WORKDIR $APP_HOME
COPY package.json $APP_HOME/
@knapo
knapo / big_decimal_type.rb
Created January 3, 2020 08:37
big_decimal_type.rb
module GraphQL
module Types
class BigDecimal < GraphQL::Schema::Scalar
description "Represents decimal numeric values"
def self.coerce_input(value, _ctx)
::BigDecimal(value.to_s)
rescue ArgumentError
nil
end
@knapo
knapo / install-haproxy.sh
Created February 11, 2019 09:36
install-haproxy.sh
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2019 TextMaster
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@knapo
knapo / disable-transparent-hugepages
Created August 23, 2017 11:54
disable-transparent-hugepages
#!/bin/bash
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
@knapo
knapo / ways_to_use_vcr.rb
Created August 18, 2016 13:27 — forked from myronmarston/ways_to_use_vcr.rb
Ways to use VCR for a request made by a let block
# 1) Use VCR.use_cassette in your let block. This will use
# the cassette just for requests made by creating bar, not
# for anything else in your test.
let(:foo) { VCR.use_cassette("foo") { create(:bar) } }
it "uses foo" do
foo
end
# 2) Wrap the it block that uses #foo in VCR.use_cassette.
@knapo
knapo / action_mailer.rb
Last active November 17, 2015 08:45
Why `Rails.application.config.action_mailer` sucks?
# config/initilizers/action_mailer.rb
ActionMailer::Base.default_url_options = {}
Rails.application.config.action_mailer.default_url_options = { host: "localhost:3001" }
# console
[1] pry(main)> Rails.application.config.action_mailer[:default_url_options]
=> {:host=>"localhost:3001"}
[2] pry(main)> ActionMailer::Base.default_url_options
=> {}
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS