Skip to content

Instantly share code, notes, and snippets.

View dvliman's full-sized avatar

David Liman dvliman

View GitHub Profile
;; vm.clj
(aws/invoke state/ec2
{:op :RunInstances
:request {:InstanceType "c5d.2xlarge"
:MaxCount 1
:MinCount 1
:SubnetId "subnet-id"
:ImageId "ami-id"
:SecurityGroupIds ["sg-id"]
@dvliman
dvliman / gist:267b66ac3a321172fd35
Created January 4, 2015 03:32
linux-kernel-booting-process

GNU/Linux kernel internals

Linux kernel booting process. Part 1.

If you read my previous blog posts, you can note that sometime ago I have started to get involved low-level programming. I wrote some posts about x86_64 assembly programming for Linux. In the same time I started to dive into GNU/Linux kernel source code. It is very interesting for me to understand how low-level things works, how programs runs on my computer, how they located in memory, how kernel manages processes and memory, how network stack works on low-level and many many other things. I decided to write yet another series of posts about GNU/Linux kernel for x86_64.

Note, that I'm not professional kernel hacker and I don't write code for kernel at work, just a hobby. I just like low-level stuff and it is interesting to me how these

@dvliman
dvliman / gym.py
Created September 28, 2021 23:32 — forked from Alir3z4/gym.py
import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@dvliman
dvliman / kv.erl
Created October 22, 2017 17:34
erlang benchmark kv
% -*- coding: utf8 -*-
%% Benchmarking code samples.
%% Each benchmark is launched in it's own process to eliminate GC influence.
-module(benchmark).
-export([main/0]).
main() ->
% {Test name, TestFun1, TestFun2, Constructor}
% Constructor runtime isn't counted
# pgTAP extension
comment = 'Unit testing for PostgreSQL'
default_version = '1.1.0'
module_pathname = '$libdir/pgtap'
requires = 'plpgsql'
relocatable = true
superuser = false
[root@ip-172-31-19-212 certbot]# cat certbot-auto
#!/bin/sh
#
# Download and run the latest release version of the Certbot client.
#
# NOTE: THIS SCRIPT IS AUTO-GENERATED AND SELF-UPDATING
#
# IF YOU WANT TO EDIT IT LOCALLY, *ALWAYS* RUN YOUR COPY WITH THE
# "--no-self-upgrade" FLAG
#
@dvliman
dvliman / screen-gif.sh
Created August 23, 2020 05:10 — forked from julesjans/screen-gif.sh
Capture iOS Simulator to animated gif
# Turn on the simulator screen capture
xcrun simctl io booted recordVideo ~/simulator.mov
# Convert the iPhone 6s screen shot into a gif:
ffmpeg -i ~/simulator.mov -vf scale=320:-1 -r 6 -f gif -y simulator.gif
(defn pgobj->clj [^org.postgresql.util.PGobject pgobj]
(let [type (.getType pgobj)
value (.getValue pgobj)]
(case type
"json" (cheshire.core/parse-string value true)
"jsonb" (cheshire.core/parse-string value true)
"citext" (str value)
value)))
(extend-protocol next.jdbc.result-set/ReadableColumn
@dvliman
dvliman / auth-middleware.clj
Created July 22, 2020 17:41
buddy auth access rules snippet
;; File: src/some_app/middleware.clj
(defn open-gates [request]
true)
(def rules [{:pattern #"^/admin.*"
:handler admin-access
:redirect "/notauthorized"},
{:pattern #"^\/vclass.*"
:handler user-access
:redirect "/notauthorized"},
{:pattern #"^\/api.*"
@dvliman
dvliman / future-utils.clj
Created July 15, 2020 01:28
dpsutton's snippet
(defn ->Function
[f]
(reify java.util.function.Function
(apply [_ obj] (f obj))))
(defn future-map
[cf f]
(.thenApply cf (->Function f)))
(defn future->ch
([cf]
(future->ch cf (async/chan 1) true))