Skip to content

Instantly share code, notes, and snippets.

Jari Pennanen Ciantic

  • Finland, Jyväskylä
Block or report user

Report or block Ciantic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Ciantic
Ciantic / Cargo.toml
Last active Dec 27, 2019
This example shows how to stream a file or shell execution stdout using Hyper and Futures (Rust)
View Cargo.toml
[package]
name = "yourpackage"
version = "0.1.0"
authors = ["John Doe"]
edition = "2018"
[[bin]]
name = "example"
path = "stream-a-file-using-rust-hyper.rs"
View z-layout.bat
rem Run this file as admin on startup using Task Scheduler
imdisk -a -o awe -s 1024M -m Z: -p "/fs:ntfs /q /y"
mkdir "z:\chrome\"
mkdir "z:\chrome\Application Cache\"
mkdir "z:\chrome\blob_storage"
mkdir "z:\chrome\Cache"
mkdir "z:\chrome\GPUCache"
mkdir "z:\chrome\Session Storage"
View doctest-fails.hs
newtype Maybe' a = Maybe' {getMaybe' :: Maybe a}
deriving Show
-- $setup
-- >>> :set -XScopedTypeVariables
-- >>> :set -XFlexibleContexts
-- >>> import Test.QuickCheck
-- $
-- | Maybe
@Ciantic
Ciantic / job-service-home-wifi.kt
Last active Jul 13, 2019
Listen for a home wifi (Android Q)
View job-service-home-wifi.kt
// Android Q specific way to listen for home wifi
fun jobListenWifiHome(ctx: Context) {
val jobScheduler = getSystemService(ctx, JobScheduler::class.java) ?: return
if (jobScheduler.getPendingJob(6) != null) {
return
}
var netspec = WifiNetworkSpecifier.Builder() // This requires Android Q
.setSsid("your home wifi SSID")
.build()
var req = NetworkRequest.Builder()
@Ciantic
Ciantic / svg-grid.php
Created May 29, 2019
Just some grid ball animation thing I threw away
View svg-grid.php
<?php
$w = 20;
$h = 3;
$spacing = 7;
$padding = 2;
?>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="<?php echo -$padding; ?> <?php echo -$padding; ?> <?php echo $w * $spacing + $padding * 2; ?> <?php echo $h * $spacing + $padding * 2; ?>"
version="1.1">
@Ciantic
Ciantic / sqlite.rowvalues.tests.ts
Created May 9, 2019
SQLite Row values does not seem to work, my test case
View sqlite.rowvalues.tests.ts
import sqlite3 from "sqlite3";
let db: any;
beforeEach(done => {
db = new sqlite3.Database(":memory:", () => {
db.run("CREATE TABLE foo (a INT, b INT)", done);
});
});
@Ciantic
Ciantic / sqlite-uses-gettime.test.ts
Created Apr 24, 2019
node sqlite3 uses getTime (unixepoch as milliseconds) for default date to integer conversion
View sqlite-uses-gettime.test.ts
import sqlite3 from "sqlite3";
let db: any;
beforeEach(done => {
db = new sqlite3.Database(":memory:", () => {
db.run("CREATE TABLE foo (num INT)", done);
});
});
@Ciantic
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";
@Entity()
export class MyEntity {
@PrimaryGeneratedColumn()
id?: number;
@Column()
name?: string;
@Ciantic
Ciantic / cloudflare-dyndns-a-aaaa-record-update.sh
Last active Mar 19, 2019
cloudflare dyndns script / update a A and AAAA record using bash script
View cloudflare-dyndns-a-aaaa-record-update.sh
#!/bin/bash
# Author: Jari Pennanen
# Url: https://gist.github.com/Ciantic/4e543f2d878a87a38c25032d5c727bf2
AUTH_EMAIL="john.doe@example.com" # Your Cloudflare email
AUTH_KEY="" # Get this from My profile -> API Keys -> View
DOMAIN="example.com" # main domain
SUBDOMAIN="home.example.com" # set A and AAAA-record of this subdomain
@Ciantic
Ciantic / wp_mail_disable.php
Last active Nov 2, 2018
Disable wp_mail, and save to file only
View wp_mail_disable.php
<?php
/**
* WP Mail for the development site, should not be used on production site
*
* Throw this in to your *wp_config.php*
*/
function wp_mail($to, $subject, $message, $headers = '', $attachments = array() ) {
$emails_dir = __DIR__ . "/.emails/";
if (!file_exists($emails_dir)) {
mkdir($emails_dir);
You can’t perform that action at this time.