Skip to content

Instantly share code, notes, and snippets.


Jari Pennanen Ciantic

  • Finland, Jyväskylä
View GitHub Profile
Ciantic / example-typeorm-jest.test.ts
Created Apr 16, 2019
Example of testing TypeOrm with Jest and Sqlite in-memory database
View example-typeorm-jest.test.ts
import { createConnection, getConnection, Entity, getRepository } from "typeorm";
import { PrimaryGeneratedColumn, Column } from "typeorm";
export class MyEntity {
id?: number;
name?: string;
Ciantic / dirname-filename-basename.bat
Created Apr 1, 2016
How to get filename, dirname, and basename in bat?
View dirname-filename-basename.bat
set filepath="C:\some path\having spaces.txt"
for /F "delims=" %%i in (%filepath%) do set dirname="%%~dpi"
for /F "delims=" %%i in (%filepath%) do set filename="%%~nxi"
for /F "delims=" %%i in (%filepath%) do set basename="%%~ni"
echo %dirname%
echo %filename%
echo %basename%
Ciantic / Cargo.toml
Last active May 1, 2022
This example shows how to stream a file or shell execution stdout using Hyper and Futures (Rust)
View Cargo.toml
name = "yourpackage"
version = "0.1.0"
authors = ["John Doe"]
edition = "2018"
name = "example"
path = ""
Ciantic / run-powershell-command-once-scheduled.ps1
Last active Apr 5, 2022
Run powershell command only once, scheduled
View run-powershell-command-once-scheduled.ps1
$t = New-ScheduledTaskTrigger -Once -At (get-date).AddSeconds(10); $t.EndBoundary = (get-date).AddSeconds(60).ToString('s'); Register-ScheduledTask -Force -TaskName JustTrying -Action (New-ScheduledTaskAction -Execute "powershell.exe" -Argument '-NoProfile -WindowStyle Hidden -command "& {dir}"') -Trigger $t -Settings (New-ScheduledTaskSettingsSet -DeleteExpiredTaskAfter 00:00:01)
View paytrail-example-without-nonsense.php
ini_set('display_errors', 1);
use Paytrail\SDK\Client;
use Paytrail\SDK\Exception\HmacException;
use Paytrail\SDK\Exception\ValidationException;
use Paytrail\SDK\Model\Address;
use Paytrail\SDK\Model\CallbackUrl;
use Paytrail\SDK\Model\Customer;
Ciantic / sqlite3_update_hook.cs
Created Feb 11, 2022
This is test code I threw away, it looks like SQLite3 update hook is *per* connection, making it useless for subscribing for events between processes (even if they use same database).
View sqlite3_update_hook.cs
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using SQLitePCL;
static public class Thing {
public static void ListenSqlite(DbContext context)
var c = context.Database.GetDbConnection() as SqliteConnection;
SQLitePCL.raw.sqlite3_update_hook(c.Handle, test_func, new object());
Ciantic /
Last active Feb 7, 2022
cloudflare dyndns script / update a A and AAAA record using bash script
# Author: Jari Pennanen
# Url:
AUTH_EMAIL="" # Your Cloudflare email
AUTH_KEY="" # Get this from My profile -> API Keys -> View
DOMAIN="" # main domain
SUBDOMAIN="" # set A and AAAA-record of this subdomain
View seo-framework-disable-content-image.php
// Disable article images that come from the content e.g. first <img /> tag
add_filter('the_seo_framework_image_generation_params', function( $params, $args, $context ) {
if (isset( $params['cbs']['content'])) {
return $params;
}, 11, 3);
View keyboardlistener.cs
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Windows.Input;
using System.Windows.Threading;
using System.Collections.Generic;
namespace Ownskit.Utils
// Yaml to JSON with Rust
// Dependencies serde_yaml and serde_json
fn main() {
let json_value: serde_json::Value = serde_yaml::from_str(&"
test: some value here
another: value here