Skip to content

Instantly share code, notes, and snippets.

View jesperronn's full-sized avatar

Jesper Rønn-Jensen jesperronn

View GitHub Profile
@blurayne
blurayne / ui-widget-select.sh
Last active November 2, 2024 19:45
Pure BASH interactive CLI/TUI menu (single and multi-select/checkboxes)
#!/bin/bash
##
# Pure BASH interactive CLI/TUI menu (single and multi-select/checkboxes)
#
# Author: Markus Geiger <[email protected]>
# Last revised 2019-09-11
#
# ATTENTION! TO BE REFACTORED! FIRST DRAFT!
#
@ebidel
ebidel / sw_caching_size.js
Last active November 16, 2022 11:31
Print service worker cache sizes and overall bytes cached.
/**
* @author ebidel@ (Eric Bidelman)
* License Apache-2.0
*/
// Prints the bytes cached by service worker. Breaks out each cache
// overall in-memory bytes used by the Cache Storage API for the site.
async function getCacheStoragesAssetTotalSize() {
// Note: opaque (i.e. cross-domain, without CORS) responses in the cache will return a size of 0.
@maxivak
maxivak / __readme.md
Last active January 19, 2024 15:00
Load code in libraries in Rails 5

Load lib files in production (Rails 5)

If you have your code defined in classes in lib/ folder you may have problems to load that code in production.

Autoloading is disabled in the production environment by default because of thread safety.

Change config/application.rb:

    config.autoload_paths << Rails.root.join("lib")
 config.eager_load_paths &lt;&lt; Rails.root.join("lib")
@yalab
yalab / bootstrap-memo.md
Last active July 20, 2022 20:29
rails5 + webpacker + bootstrap
$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add [email protected] jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
@masutaka
masutaka / circle.yml
Created April 16, 2017 10:25
capistrano deployment using CircleCI 2.0
version: 2
jobs:
build:
docker:
- image: ruby:2.3.3-alpine
working_directory: /home/circleci/masutaka.net
steps:
- setup_remote_docker:
# https://circleci.com/docs/2.0/docker-layer-caching/
reusable: true
@sabman
sabman / dockerize-app.production.sh
Last active March 16, 2021 14:01
Running Rails 5.0.1 + PostGIS + puma + nginx in production using docker-compose 2 blog for this: https://medium.com/@sabman/running-rails-5-0-1-postgis-puma-nginx-in-production-using-docker-compose-2-d8d98cbef33c#.z9a3qqjar
APP_NAME=dockerized-rails
RAILS_ROOT=/usr/app/${APP_NAME}
RAILS_ENV=production
cd $APP_NAME
# Before we start we'll make sure that we have a scaffolded app just to make sure we can test everything is working.
docker-compose up
docker-compose run app bundle exec rails generate scaffold post title body:text published:boolean RAILS_ENV=development
# Blog post for this: https://medium.com/@sabman/running-rails-5-0-1-postgis-using-docker-compose-2-a0ce5e5fbaba#.j6scfvmw6
APP_NAME=dockerized-rails
rails _5.0.1_ new $APP_NAME -d postgresql
cd $APP_NAME
mkdir -p containers/development
RAILS_ENV=development
# 1. create a Dockerfile for development
cat > ./containers/development/Dockerfile <<EOF
@peterdemartini
peterdemartini / command.sh
Last active September 19, 2024 15:14
Exclude node_modules in timemachine
find `pwd` -type d -maxdepth 3 -name 'node_modules' | xargs -n 1 tmutil addexclusion
@jesperronn
jesperronn / Howto convert a PFX to a seperate .key & .crt file
Created April 15, 2016 12:46 — forked from TemporaryJam/Howto convert a PFX to a seperate .key & .crt file
How to convert a .pfx SSL certificate to .crt/key (pem) formats. Useful for NGINX
source: http://www.markbrilman.nl/2011/08/howto-convert-a-pfx-to-a-seperate-key-crt-file/
`openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]`
What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.
Now let’s extract the certificate:
`openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]`
/**
* Caches the return value of get accessors and methods.
*
* Notes:
* - Doesn't really make sense to put this on a method with parameters.
* - Creates an obscure non-enumerable property on the instance to store the memoized value.
* - Could use a WeakMap, but this way has support in old environments.
*/
export function Memoize(target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) {
if (descriptor.value != null) {