Skip to content

Instantly share code, notes, and snippets.

View dejanvasic85's full-sized avatar

Dejan Vasic dejanvasic85

View GitHub Profile
@dejanvasic85
dejanvasic85 / delete_jobs.go
Last active January 16, 2020 02:46
golang: Deleting all items in Dynamo DB with a full scan
package main
import (
"fmt"
"strconv"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
@dejanvasic85
dejanvasic85 / poll.ts
Created January 2, 2020 23:40
Polling in javascript
const poll = async (fn: any, timeout: number, interval: number) => {
const endTime = Date.now() + timeout;
const checkCondition = async (resolve: any, reject: any) => {
const result = await fn();
if (result) {
resolve(result);
} else if (Date.now() < endTime) {
setTimeout(checkCondition, interval, resolve, reject);
} else {
@dejanvasic85
dejanvasic85 / types.ts
Last active December 31, 2019 03:56
Typescript MSSQL unit of work pattern
export interface Repository {
beginTransaction: () => Promise<Transaction>;
}
@dejanvasic85
dejanvasic85 / create-pg.sh
Created November 4, 2019 07:54
Create local postgres database with docker
# Postgres Docker creates a volume by default so we only need the following parameters
docker run -e POSTGRES_USER=<dbuser> -e POSTGRES_PASSWORD=<dbpassword> -e POSTGRES_DB=<dbname> -p 5432:5432 --name <dbname> -d postgres
package main
import (
"fmt"
"sync"
"github.com/dghubble/sling"
)
func main() {
@dejanvasic85
dejanvasic85 / pg.sh
Created February 11, 2019 01:11
Running postgres in docker
docker run -d --name my_postgres -v my_dbdata:/var/lib/postgresql/data -p 54320:5432 postgres:11
class PageBrowser() implements AutoCloseable {
final SeleniumDriver mDriver;
public PageBrowser() {
mDriver = new SeleniumDriver(); // setup the rest of the driver
}
TPage <TPage> goTo() {
// Todo Java Reflection on TPage and inject SeleniumDriver
}
export function* request(apiCall) {
const response = yield apiCall
if (response.status === 401) {
yield put(SessionActions.logout())
return null
}
return response
}
#!/usr/bin/env bash
cluster="cluster-name"
x="aws ecs wait services-stable --cluster $cluster --services $cluster"
echo "Waiting until ecs services report as healthy"
for i in 1 2 3 4 5; do (eval $x) && break || sleep 5; done
@dejanvasic85
dejanvasic85 / .travis.yml
Created April 1, 2018 02:45
Final Travis Deploy
deploy:
- provider: script
skip_cleanup: true
script: chmod +x ./deploy.sh && ./deploy.sh
on:
branch: master