Skip to content

Instantly share code, notes, and snippets.

View borischerkasky's full-sized avatar

Boris Cherkasky borischerkasky

View GitHub Profile
@borischerkasky
borischerkasky / CachingDynamoStore.scala
Created February 23, 2020 20:48
DynamoDB writer with write through cache
import akka.actor.Scheduler
import com.github.blemale.scaffeine.{Cache, Scaffeine}
import play.api.libs.json.OWrites
import scala.reflect.runtime.universe._
import scala.concurrent.duration._
import scala.concurrent.{ExecutionContext, Future}
class CachingDynamoStore[A : Indexable : OWrites](store: DataStore[A], cache: Cache[String, A])(
implicit executionContext: ExecutionContext,
def get_next_page(res)
res.headers['link']&.
split(',')&.
select{|x| x.include? 'next'}&.first&.split(';')&.
first&.
gsub(/[ ><]/,'')
end
@borischerkasky
borischerkasky / full_script.rb
Created August 11, 2019 19:18
full Github PR statistics script
class TeamPrStatistics
attr_accessor :team, :stats
class Stat
attr_accessor :titles
attr_reader :name
def initialize(name)
@name = name
@titles = []
end
# since i'm overriding HTTParty's headers i need to provide the user agent so GitHub won't reject the api call
headers = {"User-Agent"=>"Httparty", "Accept"=>"application/vnd.github.mockingbird-preview"}
@borischerkasky
borischerkasky / github_pullrequest.rb
Created August 10, 2019 16:28
get pullrequest from github
username 'put your username here'
token = 'put your personal token from GitHub here, prefeably via ENV VAR'
auth = { username: uname, password: token }
url = "https://api.github.com/repos/#{owner}/#{repo_name}/pulls?per_page=1&state=all"
res = HTTParty.get(url, basic_auth: auth)
body = JSON.parse(res.body)
@borischerkasky
borischerkasky / docker-compose.yml
Last active December 9, 2021 00:59
localstack docker compose
version: "3"
services:
localstack:
image: localstack/localstack
ports:
- "4568-4576:4568-4576"
- "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
environment:
- DOCKER_HOST=unix:///var/run/docker.sock