Skip to content

Instantly share code, notes, and snippets.

@garcia556
garcia556 / id_rsa.pub
Created January 25, 2023 15:43
xps_pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDN5bfKDkat2b2YfAwJUl1HaIrkMtT+67pmI6xl4BXK0CrM9xbaRFWHZKZLV9a3DQ0LTs11ST/+5sQO7xLgIF7YlkrzeZWiVJJVJgD5XqaZRTeHId509ZR82sT+vX1NbRp+gTcmccceinxJRnE5lozzyo1ut9iCCKY2Ixa4rKcAqkpbiRC1g+IGTYiXy0WOrjlp9pnI2/pTSqXQwkyDAIUbDLqYnZT7jjQ3uor2+tFYQsDJbqLkJbA+0hD0/yAwmrCAW/6VPVPn1GsYr0VWq/plFNLBD0BRC5VSw51A2AXxtTe+pKIQWfUEB9fWvyUJjQEoSKsvYfBrUvuXlrmk46BrprWINAunVT8ncp4Lf9RtLZdHJbaG3aPB5yFmh2Cidd8P3XOiHXYDsbPgGYjSZ2mEuvpibl9UWFHXnhiY/AxiG7+B7I8eqO4gYaVjRE2tsabxFIZpzu1BTZ7dfMzmpAFsN45pb1zK0npVcI9Z38szA3WdEFmYIB9FD5m6psVuH1U= dmitryg@dmitryg-xps
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
readonly PG_IMAGE="postgres:15.1-bullseye"
readonly PG_URL="postgres://kd_admin_auth:mysecretpassword@127.0.0.1:5432/kd_admin_auth"
flake8
@garcia556
garcia556 / get.c
Created December 3, 2017 21:08
POSIX shared memory IPC example (shm_open, mmap), working on Linux and macOS
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define STORAGE_ID "/SHM_TEST"
#define STORAGE_SIZE 32
int main(int argc, char *argv[])
@garcia556
garcia556 / pthreads-example.c
Last active December 3, 2017 02:35
Simple example of threads running simultaneously
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#define EXIT_TIMEOUT 1
#define THREAD_COUNT 3
pthread_t tid[THREAD_COUNT];
@garcia556
garcia556 / udp-server-echo.js
Created November 28, 2017 16:25
Node UDP echo server (use "netcat -u localhost 8080" for client)
const
dgram = require("dgram"),
server = dgram.createSocket("udp4");
const
PORT = 8080,
HOST = "0.0.0.0";
server.on("listening", () => {
var address = server.address();
@garcia556
garcia556 / BuildManager.cs
Last active April 6, 2023 05:47
Unity script to enable building for all platforms using command line
using UnityEditor;
/*
Methods to execute:
- RunMacOS
- RunWin
- RunWebGL
Command line arguments:
- output : build output path
@garcia556
garcia556 / koa-1045-test.js
Last active November 22, 2017 18:14
Trying to reproduce immutable empty query object for issue #1045
'use strict';
// to be run with node@7.10 and koa@2.3.0
// docker node@7.1.0 image can be build using: https://raw.githubusercontent.com/nodejs/docker-node/b502aa016335c81a586b430328d8fee4897ee440/7.10/alpine/Dockerfile
const
http = require("http"),
Koa = require("koa"),
app = new Koa(),
PORT = 12345,
@garcia556
garcia556 / node-helpers.js
Last active November 22, 2017 13:28
Some helper functions for node
'use strict';
const
fs = require("fs"),
crypto = require("crypto"),
{ promisify } = require("util");
var root = {};
root.clamp = (value, min, max) => { return Math.min(Math.max(value, min), max); };
@garcia556
garcia556 / r2pmml-lm-example.R
Created November 22, 2017 04:21
Creates a primitive linear regression model and exports it to PMML format
#!/usr/bin/env Rscript
# quick-and-dirty run method: docker run -it -v $(pwd):/app:ro -w /app r-base bash -c "apt-get update; apt-get install -y libxml2-dev; R -e 'install.packages(\"pmml\")'; ./script.R"
library(pmml)
types <- c("pr", "yes_no", "score")
cat("Enter model type of 1) Probability 2) Yes/No or 3) Score: ")
option <- readLines(file("stdin"),1)
@garcia556
garcia556 / install-docker-compose-latest.sh
Last active November 22, 2017 04:26
Install the latest version available of docker-compose
#!/bin/bash
# installs latest docker-compose version
# - works on Linux; on macOS there is a brew package for it
# - requires root permissions
# get latest version
VER=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep "tag_name" | cut -d\" -f4)
# get bin