Skip to content

Instantly share code, notes, and snippets.

View mhenrixon's full-sized avatar
🐢
I may be slow to respond.

Mikael Henriksson mhenrixon

🐢
I may be slow to respond.
View GitHub Profile
#!/usr/bin/env bash
# Rename all files with "_component" in the name to remove "_component"
directory="app/views/components"
find "$directory" -type f -name "*_component*" | while read file; do
dir=$(dirname "$file")
name=$(basename "$file")
new_name=${name/_component/}
@mhenrixon
mhenrixon / _form.html.haml
Created May 18, 2011 11:02
A complete sample of how to perform nested polymorphic uploads in rails using carrierwave
=semantic_form_for [:admin, @dog], validate: true, html: {multipart: true} do |f|
=f.inputs do
=f.input :name
=f.input :kennel_name
=f.input :birthdate
=f.input :gender, as: :radio, collection: {'Tik' => 'F', 'Hane' => 'M'}
=f.input :father_id, as: :select, collection: @dogs
=f.input :mother_id, as: :select, collection: @bitches
=f.semantic_fields_for :pictures do |pic|
@mhenrixon
mhenrixon / tUnit2Rspec
Created November 26, 2020 21:29 — forked from yannis/tUnit2Rspec
Test::Unit to Rspec conversion ruby script
require "highline/import"
from_path = ask "Enter path for file to convert: "
to_path = ask "Enter the path where to save the spec file: "
unless File.exists? from_path
puts "Sorry this file doesn't exist!: #{from_path}"
puts "Please try again"
return
end
t_unit = File.read(from_path).to_s
require 'delayed/backend/active_record'
module Delayed
module Backend
module ActiveRecord
class Configuration
attr_accessor :cluster
end
# A job object that is persisted to the database.
version: '3.7'
services:
app-base: &app-base
image: docker-registry.wunder.tax/company/project-base:latest
env_file:
- .env.example
- .env
environment:
BUNDLE_GITLAB__WUNDER__TAX: ${BUNDLE_GITLAB__WUNDER__TAX}
WEBPACKER_DEV_SERVER_HOST: app-assets
@mhenrixon
mhenrixon / JobRegistry.cs
Created January 10, 2011 11:03
A quick way to setup quartz with structuremap
internal class JobRegistry :Registry
{
public JobRegistry()
{
ForSingletonOf<PlaynGO.Common.InversionOfControl.IContainer>().Use<PlaynGO.StructureMap.Container>();
ForSingletonOf<IJobFactory>().Use<WpsJobFactory>();
var col = new NameValueCollection();
ForSingletonOf<ISchedulerFactory>().Use<StdSchedulerFactory>().Ctor<NameValueCollection>("props").Is(ctx =>
{
tap "codeclimate/formulae"
tap "eugenmayer/dockersync"
tap "heroku/brew"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-fonts"
tap "homebrew/cask-versions"
tap "homebrew/core"
tap "homebrew/services"
tap "joshuaclayton/formulae"
@mhenrixon
mhenrixon / cs_merge
Last active February 1, 2020 03:43
How we merged multiple github repos into a monolithic project repo
#!/bin/bash
#
# This script merges all the repos we have into subfolders in a new repo
#
# Clones or copies a repository from either disc or remote repository.
cloppy() {
local dir=$1
if [[ -z $2 ]]; then
local repo=$dir
@mhenrixon
mhenrixon / pg_kill.sh
Last active December 22, 2019 12:20
Kills all connections to postgresql (un)specified database(s)
#!/usr/bin/env bash
# kill all connections to the postgres server
if [ -n "$1" ] ; then
where="where pg_stat_activity.datname = '$1'"
echo "killing all connections to database '$1'"
else
where="where pg_stat_activity.datname in (select datname from pg_database where datname != 'postgres')"
echo "killing all connections to database"
fi
3:20:50 PM worker.1 | 2019-05-06T13:20:50.801Z pid=72940 tid=ovbsba1tc INFO: Booting Sidekiq 6.0.0.pre1 with redis options {:url=>"redis://localhost:6379/7", :driver=>:async, :id=>"Sidekiq-server-PID-72940"}
3:20:50 PM worker.1 | 2019-05-06T13:20:50.997Z pid=72940 tid=ovbsba1tc INFO: Running in ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
3:20:50 PM worker.1 | 2019-05-06T13:20:50.997Z pid=72940 tid=ovbsba1tc INFO: See LICENSE and the LGPL-3.0 for licensing details.
3:20:50 PM worker.1 | 2019-05-06T13:20:50.997Z pid=72940 tid=ovbsba1tc INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
3:20:50 PM worker.1 | No async task available!
3:20:50 PM worker.1 | /Users/mikaelhenrikson/.gem/ruby/2.5.5/gems/async-1.17.1/lib/async/task.rb:148:in `current'
3:20:50 PM worker.1 | /Users/mikaelhenrikson/.gem/ruby/2.5.5/gems/async-io-1.23.0/lib/async/io/host_endpoint.rb:49:in `connect'
3:20:50 PM worker.1 | /Users/mikaelhenrikson/.gem/ruby/2.5.5/bundler/gems/redis-rb-c6eb41aa