Skip to content

Instantly share code, notes, and snippets.

View m-radzikowski's full-sized avatar

Maciej Radzikowski m-radzikowski

View GitHub Profile
@m-radzikowski
m-radzikowski / migrate-comments-to-giscus.py
Last active April 7, 2024 20:35
Migrate comments from WordPress wpDiscuz (https://wpdiscuz.com/) to Giscus (https://giscus.app/) powered by GitHub Discussions
import hashlib
import re
from time import sleep
from urllib.parse import urlparse
import requests
from bs4 import BeautifulSoup
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
from markdownify import markdownify as md
@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)
{
"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)
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
#!/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
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 May 4, 2024 04:13
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/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...]
#!/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
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.
#!/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
<?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: