Skip to content

Instantly share code, notes, and snippets.

Avatar

Maciej Radzikowski m-radzikowski

View GitHub Profile
@m-radzikowski
m-radzikowski / cdk.json
Created March 15, 2023 10:58
Context parameters example for Opinionated CI Pipeline (https://github.com/merapar/opinionated-ci-pipeline)
View cdk.json
{
"app": "...",
"context": {
"projectName": "myproject",
"environments": {
"default": {
"account": "111111111111",
"region": "us-east-1"
},
"prod": {
@m-radzikowski
m-radzikowski / cdk.ts
Last active March 15, 2023 10:55
Minimal usage example of Opinionated CI Pipeline (https://github.com/merapar/opinionated-ci-pipeline)
View cdk.ts
import {CDKApplication} from 'opinionated-ci-pipeline';
import {MyStack} from '../lib/myStack';
new CDKApplication({
stacks: {
create: (scope, projectName, envName) => {
new MyStack(scope, 'MyStack', {stackName: `${projectName}-${envName}-MyStack`});
},
},
repository: {
@m-radzikowski
m-radzikowski / cognito-app-client-auth.sh
Last active May 24, 2021 22:34
Amazon Cognito App Client authorization
View cognito-app-client-auth.sh
#!/usr/bin/env bash
# Discover Cognito User Pool and API Gateway params,
# authorize with Cognito App Client ID and Secret
# and make request to the API.
# set Cognito and API Gateway params
REGION="eu-west-1"
USER_POOL_NAME="apiAuth-dev"
CLIENT_NAME="MyServiceClient"
@m-radzikowski
m-radzikowski / LICENSE
Created December 15, 2020 16:22
This license applies to all public gists https://gist.github.com/m-radzikowski
View LICENSE
MIT License
Copyright (c) 2020 Maciej Radzikowski
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
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@m-radzikowski
m-radzikowski / script-template.sh
Last active March 19, 2023 20:59
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
View script-template.sh
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
View mint-setup.sh
#!/usr/bin/env bash
# Personal script to setup Linux Mint
# and install bunch of tools.
set -euo pipefail
echoerr() { echo "$@" 1>&2; }
ensure_sudo() {
@m-radzikowski
m-radzikowski / DropAllTables
Last active August 29, 2015 14:11
Drops all tables, views and routines in database. Based on http://stackoverflow.com/a/18625545/2512304
View DropAllTables
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
-- drop tables
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE()); -- from currently selected schema
SELECT IFNULL(@tables, 'dummy') INTO @tables; -- to prevent error when there are already no tables
@m-radzikowski
m-radzikowski / RepareGrub2OnOpenSuse.sh
Created February 20, 2014 14:17
Script to restore Grub2 for openSUSE after for example Windows installation.
View RepareGrub2OnOpenSuse.sh
#!/bin/sh
# openSUSE rescue system login: root
fdisk -l
mount /dev/sda5 /mnt # assume that linux partition (/) is on /dev/sda5, you can see this after "fdisk -l" command
mount --bind /dev /mnt/dev
mount --bind /sys /mnt/sys
mount --bind /proc /mnt/proc
chroot /mnt
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda
View AssetExistsExtension.php
<?php
/**
* Twig Filter for Symfony 2 - check if asset exists.
*
* Modified Alain's Tiemblo code: http://stackoverflow.com/a/16906315/2512304
*
* Installation:
* 1. Add this file to your bundle into src/Acme/DemoBundle/Twig/AssetExistsExtension.php
* 2. Update namespace, if your bundle isn't Acme/DemoBundle
* 3. Register it in app/config.yml:
@m-radzikowski
m-radzikowski / TruncateHtmlExtension.php
Created July 2, 2013 19:13
Twig Filter for Symfony 2 - truncate HTML string without stripping tags after reach the minimum length of displayed text
View TruncateHtmlExtension.php
<?php
/**
* Twig Filter for Symfony 2 - truncate HTML string without stripping tags after reach the minimum length of displayed text
* Truncates only first-level tags after reach the minimum, so returned text will be >= minimum
* Works well with (only?) utf-8 encoding.
*
* Installation:
* 1. Add this file to your bundle into src/Acme/DemoBundle/Twig/TruncateHtmlExtension.php
* 2. Update namespace, if your bundle isn't Acme/DemoBundle
* 3. Register it in app/config.yml: