Skip to content

Instantly share code, notes, and snippets.

View ahukkanen's full-sized avatar

Antti Hukkanen ahukkanen

  • Mainio Tech Ltd.
  • Finland
View GitHub Profile
@ahukkanen
ahukkanen / decidim_survey_test.rake
Created March 22, 2023 12:56
Test script for the Decidim surveys memory leak
# frozen_string_literal: true
namespace :decidim do
namespace :surveys do
task test_memory_leak: :environment do
unless Rails.env.test?
puts %(Please run this with "RAILS_ENV=test")
next
end
@ahukkanen
ahukkanen / test-sass
Last active March 23, 2022 14:49
Test scripts to measure performance difference for Decidim CSS compilation
#!/usr/bin/env node
const fs = require("fs");
// const sass = require("sass");
const sass = require("sass-embedded"); // npm i sass-embedded
const paths = [
"../decidim-accountability/app/packs",
"../decidim-admin/app/packs",
"../decidim-api/app/packs",
@ahukkanen
ahukkanen / psql_performance.sh
Created February 26, 2022 13:29
Inserts records and runs select queries on a PostgreSQL database to compare the performance of two alternate approaches.
#!/bin/bash
# Amount of inserts and selects
AMT_INSERTS=10000
AMT_SELECTS=1000
# Executes the given statements and prints out the elapsed time
execute_statements() {
local statements=("$@")
local tmp=$(mktemp /tmp/psql-performance.XXXXXX)
@ahukkanen
ahukkanen / chart_init.js
Last active May 17, 2020 07:56
Year label center alignment with Chart.js
// Initialization of the Chart using the defined scale type
var labels = [
'2015-01-01',
'2015-02-01',
'2015-03-01',
'2015-04-01',
'2015-05-01',
'2015-06-01',
// ...continue for 60 months in total for 5 years
@ahukkanen
ahukkanen / clamscan
Created December 2, 2018 14:12
A bash test script for testing ClamAV executables without installing ClamAV
#!/bin/bash
#
# THIS IS ONLY INTENDED TO BE USED FOR DEVELOPMENT PURPOSES
#
# This is a simple "dummy" version of the ClamAV clamscan executable. This can
# be used to test ClamAV integration libraries for returning the correct values
# expected from the ClamAV executables.
#
# For example, this can be used to test Clamby:
# https://github.com/kobaltz/clamby
@ahukkanen
ahukkanen / FilesystemLoader.php
Last active May 13, 2021 06:33
Example of using Symfony forms without symfony/framework-bundle
<?php
namespace Mainio\Symfony\FormsIntegration\Templating\Loader;
use Symfony\Component\Templating\Loader\FilesystemLoader as BaseFilesystemLoader;
use Symfony\Component\Templating\Storage\FileStorage;
use Symfony\Component\Templating\TemplateReferenceInterface;
class FilesystemLoader extends BaseFilesystemLoader
{