Skip to content

Instantly share code, notes, and snippets.

@giuliohome
giuliohome / unit_test.bat
Created November 15, 2023 08:46
python unit test with one's company's ssl root cert on windows
set CURL_CA_BUNDLE=C:\path\to\mycompanyCA.pem
set PYTHONPATH=src
python -m unittest test\mytest.py
@giuliohome
giuliohome / ubuntu-sleep.yaml
Created November 1, 2023 16:52 — forked from tcdowney/ubuntu-sleep.yaml
Ubuntu Sleep Pod
apiVersion: v1
kind: Pod
metadata:
name: ubuntu
labels:
app: ubuntu
spec:
containers:
- image: ubuntu
command:
@giuliohome
giuliohome / soap_call.py
Last active October 21, 2023 14:22
calling a wsdl service from python
from zeep import Client
wsdl = 'http://www.dneonline.com/calculator.asmx?WSDL'
arg = {'intA':2, 'intB':3}
op = 'Add'
client = Client(wsdl)
res = client.service[op](**arg)
print(res) # 5
@giuliohome
giuliohome / async_loop.py
Last active October 3, 2023 12:09
The script simulates a scenario where certain activities depend on others as weak dependencies and may be restarted if the dependencies are completed.
import asyncio
# weak dependencies list as (dependency, dependent)
weak_deps = [(2,3),(4,1)]
# e.g. let's say activity 2 updates input of activity 3 as a weak dependency, etc...
async def gather_with_first_completed(awaitable_results):
# Create a list to store the completed results
completed_results = []
@giuliohome
giuliohome / workflow.hs
Last active October 1, 2023 20:15
Async Workers with Condition Handling
import Control.Concurrent.STM
import Control.Monad
import Control.Concurrent
workerWaitForCondition :: TVar Bool -> IO ()
workerWaitForCondition condition = atomically $ do
c <- readTVar condition
unless c retry
workerMakeConditionTrue :: TVar Bool -> IO ()
package io.github.nomisrev
import app.cash.sqldelight.driver.jdbc.asJdbcDriver
import arrow.continuations.SuspendApp
import arrow.continuations.ktor.server
import arrow.fx.coroutines.autoCloseable
import arrow.fx.coroutines.closeable
import arrow.fx.coroutines.resourceScope
import com.zaxxer.hikari.HikariConfig
import com.zaxxer.hikari.HikariDataSource
@giuliohome
giuliohome / scala-http-postgres-html-docker.scala
Created September 30, 2023 08:18 — forked from keynmol/scala-http-postgres-html-docker.scala
Sample gist showing how to run a HTTP server with Typelevel Scala libraries, and a postgres docker container
//> using dep "org.http4s::http4s-scalatags::0.25.2"
//> using dep "org.http4s::http4s-dsl::0.23.23"
//> using dep "org.http4s::http4s-ember-server::0.23.23"
//> using dep "org.tpolecat::skunk-core::0.6.0"
//> using dep "com.dimafeng::testcontainers-scala-postgresql::0.41.0"
//> using dep "com.outr::scribe-slf4j::3.12.2"
import skunk.*, codec.all.*, syntax.all.*
import cats.effect.*
import scalatags.Text.all.*
open Donald
open System.Data.Common
open System.Data.SQLite
open System.Threading.Tasks
open Giraffe
open Giraffe.ViewEngine
open FsToolkit.ErrorHandling
open Microsoft.AspNetCore.Builder
[<RequireQualifiedAccess>]
@giuliohome
giuliohome / my_video_capture.html
Created March 14, 2023 16:27
video capture, html5
<!DOCTYPE html>
<html>
<body>
<h1>Recording Video from the User</h1>
<p>Acquire access to the camera</p>
<video id="player" controls></video>
<a id="download">Download</a>
@giuliohome
giuliohome / Dockerfile
Last active February 28, 2024 16:42
alpine node container to build and test react without ssl verification
FROM node:16.14.0-alpine
RUN mkdir my
RUN echo enableStrictSsl: false > ./my/.yarnrc.yml
COPY fe-react-01/yarn.lock ./my
COPY fe-react-01/src ./my/src
COPY fe-react-01/.yarn ./my/.yarn
COPY fe-react-01/tsconfig.json ./my
COPY fe-react-01/package.json ./my
COPY fe-react-01/public ./my/public