Skip to content

Instantly share code, notes, and snippets.

View terlar's full-sized avatar

Terje Larsen terlar

View GitHub Profile
@terlar
terlar / diagram.d2
Last active June 12, 2024 19:54
Diagrams, example
internet: "Public Internet"
google: "Google Cloud" {
ext-lb: "HTTP(S) Load Balancer"
cloud-armor: "Cloud Armor"
ext-vpc: "shared-external-vpc" {
waf: WAF
}
{ lib }:
{
filterDivergedAttrsRecursive =
lhs: rhs:
let
pred = path: v: (!lib.hasAttrByPath path rhs || (lib.getAttrFromPath path rhs) != v);
recurse =
path: set:
lib.listToAttrs (
@terlar
terlar / bitbucket-to-github.sh
Created May 18, 2017 07:55
Migrate bitbucket repo to github
#!/bin/bash
set -xeuo pipefail
main() {
local usr="${1?user must be provided}"
local bb_repo="${2?bitbucket repo must be provided}"
local target="${bb_repo##*/}"
git clone --mirror "${bb_repo}" "${target}"
cd "${target}" || exit
@terlar
terlar / kubectl.fish
Last active January 31, 2021 04:11
Kubernetes fish completions
# kubernetes - is an open source system for managing containerized
# applications across multiple hosts, providing basic mechanisms for
# deployment, maintenance, and scaling of applications.
# See: https://kubernetes.io
function __kubectl_no_command
set -l cmd (commandline -poc)
if not set -q cmd[2]
return 0
end

Run controller action

Example 1:

c = IndexController.new
c.params = { utf8: '✓', test: 'param' }
c.action
diff --git a/lib/kviberg/common/opening_hours_entry.rb b/lib/kviberg/common/opening_hours_entry.rb
index 26d7912..56c6372 100644
--- a/lib/kviberg/common/opening_hours_entry.rb
+++ b/lib/kviberg/common/opening_hours_entry.rb
@@ -18,6 +18,20 @@ module Kviberg
"#{day} #{opens} - #{closes}"
end
+ def current_day?(time = Time.now)
+ dayOfWeek == time.strftime('%u').to_i
require_relative '../../../web_test_helper'
module Web
class PostAdWithDescriptionPropertyTest < PostAdTestCase
def test_post_ad_with_multiline_description
description = "This is a multiline\ndescription\nindeed it is\n"
post_ad_with_properties({
key: 'description',
type: 'description',
@terlar
terlar / parse_ruby_object.sh
Created January 23, 2015 09:09
Parse ruby object output
#!/usr/bin/env bash
sed -e 's/^ "request" => "//g' \
-e 's/\\"/"/g' \
-e 's/<\([A-Za-z:]*\) /\1.new(/g' \
-e 's/ \([A-Za-z]*\):/\1: /g' \
-e 's/[A-Z_]* (\([0-9]\))/\1/g' \
-e 's/>/)/g' \
-e 's/"$//g' \
"$@"
class FakeTranslationBackend < I18n::Backend::Simple
# rubocop:disable ParameterLists
def lookup(locale, key, scope = [ ], options = { })
I18n.normalize_keys(locale, key, scope, options[:separator]).join('.')
end
end
def setup
I18n.backend = FakeTranslationBackend.new
end
@terlar
terlar / nginx.conf
Created April 23, 2014 15:52
nginx and prax
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;