Skip to content

Instantly share code, notes, and snippets.

View IhostVlad's full-sized avatar
💻
Senior full-stack developer

Vladislav V IhostVlad

💻
Senior full-stack developer
View GitHub Profile
@IhostVlad
IhostVlad / Cargo.toml
Last active March 4, 2022 14:52
Micro eventsourcing Rust + AWS serverless
[package]
name = "lambda_runtime"
version = "0.4.1"
edition = "2021"
[dependencies]
tokio = { version = "1.0", features = ["macros", "io-util", "sync", "rt-multi-thread"] }
hyper = { version = "0.14", features = ["http1", "client", "server", "stream", "runtime"] }
serde = { version = "1", features = ["derive"] }
serde_json = "^1"
@IhostVlad
IhostVlad / Cargo.toml
Created October 5, 2021 09:58
HN comments Postgres Rust
[package]
name = "hnrs"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[profile.release]
"codegen-units" = 1
lto = "fat"
@IhostVlad
IhostVlad / bench.cc
Last active September 15, 2021 10:19
// g++ -o bench.exe --std=c++17 -lpqxx bench.cc
// POSTGRES_CONNECTION_STRING=<connection string> ./bench.exe <threads count> <iterations count> <max rows> <mode 0-5>
#include <iostream>
#include <functional>
#include <pqxx/pqxx>
#include <thread>
#include <future>
#include <cstring>
#include <vector>
/* eslint-disable @typescript-eslint/explicit-function-return-type */
const SHA256 = require('crypto-js/sha256')
const encHex = require('crypto-js/enc-hex')
const HmacSHA256 = require('crypto-js/hmac-sha256')
const AWS_SHA_256 = 'AWS4-HMAC-SHA256'
const AWS4_REQUEST = 'aws4_request'
const AWS4 = 'AWS4'
const X_AMZ_DATE = 'x-amz-date'
@IhostVlad
IhostVlad / config.cloud.js
Created September 7, 2020 10:35
HackerNews Inline Ledger in Cloud
import { declareRuntimeEnv } from 'resolve-scripts'
export default {
target: 'cloud',
mode: 'production',
staticPath: declareRuntimeEnv('RESOLVE_CLOUD_STATIC_URL'),
eventstoreAdapter: {
module: 'resolve-eventstore-postgresql-serverless',
options: {
awsSecretStoreArn: declareRuntimeEnv('RESOLVE_ES_SECRET_ARN'),
@IhostVlad
IhostVlad / pure-tsql-json.sql
Created June 19, 2019 15:13
Convert JSON to and from string in pure T-SQL
-- Copyright from https://www.red-gate.com/simple-talk/sql/t-sql-programming/consuming-json-strings-in-sql-server/
CREATE TYPE dbo.Hierarchy AS TABLE
(
element_id INT NOT NULL, /* internal surrogate primary key gives the order of parsing and the list order */
sequenceNo [int] NULL, /* the place in the sequence for the element */
parent_ID INT,/* if the element has a parent then it is in this column. The document is the ultimate parent, so you can get the structure from recursing from the document */
[Object_ID] INT,/* each list or object has an object id. This ties all elements to a parent. Lists are treated as objects here */
NAME NVARCHAR(2000),/* the name of the object, null if it hasn't got one */
StringValue NVARCHAR(MAX) NOT NULL,/*the string representation of the value of the element. */
@IhostVlad
IhostVlad / index.test.js
Created June 17, 2019 10:39
hackernews-stress
import { Selector } from 'testcafe'
const ROOT_URL = `https://jd05ienjxfkjegg8mim64t8z1e.resolve.sh`
const roundSeed = `${Date.now()}-${Math.floor(Math.random()*100000000000)}`
fixture`Testcafe stress`
test('Testcafe stress test', async (t) => {
await t.setNativeDialogHandler(() => true)
{
fixture`HackerNews`.page`https://jd05ienjxfkjegg8mim64t8z1e.resolve.sh/`
test('HackerNews 1', async t => {
await t.setNativeDialogHandler(() => true)
const pageContent = (await t.eval(() => window.document.body.innerHTML))
console.log(pageContent)
})
test('HackerNews 2', async t => {
await t.setNativeDialogHandler(() => true)
fixture`ResolveJS`.page`https://github.com/reimagined/resolve`
test('ResolveJS', async t => {
await t.setNativeDialogHandler(() => true)
const locationPath = (await t.eval(() => window.location)).pathname
await t.expect(locationPath).eql('/reimagined/resolve')
// await t.expect(locationPath).eql('/reimagined/resolve2')
})
curl "https://api.github.com/repos/ORG/REPO/statuses/COMMIT_SHA?access_token=ACCESS_TOKEN" -H "Content-Type: application/json" -X POST -d "{\"state\": \"success\", \"context\": \"continuous-integration/drone/push\", \"target_url\": \"\"}"