Skip to content

Instantly share code, notes, and snippets.

View yefim's full-sized avatar

Yefim Vedernikoff yefim

View GitHub Profile
@yefim
yefim / Dockerrun.aws.json
Last active April 7, 2023 16:11
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "<AWS_ACCOUNT_ID>.dkr.ecr.us-east-1.amazonaws.com/<NAME>:<TAG>",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "443"
}
@yefim
yefim / refined-mastodon.js
Created December 16, 2022 09:01
Adds total boost and favs counts to URLs
import { Mastodon } from 'megalodon'
import _ from 'lodash';
const client = new Mastodon('https://blumpus.com', 'YOUR_ACCESS_TOKEN');
const clients = {};
const main = async () => {
const res = await client.getHomeTimeline();
const urls = res.data.map((r) => r.url).filter(Boolean).map((url) => {
@yefim
yefim / Gemfile
Last active December 7, 2022 16:48
bundle - bundle exec ruby server.rb - bundle exec ruby cdn.rb -p 4321
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
gem 'sinatra'
gem 'sinatra-contrib'
@yefim
yefim / Code.js
Last active December 6, 2022 18:33
To install into Google Sheets, follow the "Creating a custom function" instructions found here: https://developers.google.com/apps-script/guides/sheets/functions and paste the snippet below into the editor. Follow the instructions to create a personal access token. After you install, use =TOTAL_CONTRIBUTIONS("yefim") in your sheet.
/**
*
* YOUR GITHUB PERSONAL ACCESS TOKEN GOES BELOW!
*
* To create a token, follow these instructions: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
* For Step 7, only select the "read:user" scope.
*/
var PERSONAL_ACCESS_TOKEN = 'yourtokengoeshere';
var getDateRange = function(days) {
@yefim
yefim / q.coffee
Last active November 17, 2020 03:02
Queue implementation in CoffeeScript
class Q
constructor: (@bound) ->
@offset = 0
@length = 0
@data = []
enqueue: (value) ->
return undefined if @length == @bound
@data.push value
++@length
dequeue: ->
import 'dart:html';
void main() {
window.onMessage.listen((message) { print('1'); });
window.onMessage.listen((message) { print('2'); });
window.onMessage.listen((message) { print('3'); });
window.onMessage.listen((message) { print('4'); });
window.postMessage({'a': 'b'}, '*');
}
void main() async {
final t1 = () => Future.delayed(Duration(seconds: 1), () => true); // should short circuit
final t2 = () => Future.delayed(Duration(seconds: 3), () => true);
final t3 = () => Future.delayed(Duration(seconds: 2), () => false);
final timers = [t1, t2, t3];
bool isDirty = false;
print('Running');
void main() async {
final t1 = () => Future.delayed(Duration(seconds: 1), () => print('1'));
final t2 = () => Future.delayed(Duration(seconds: 3), () => print('3'));
final t3 = () => Future.delayed(Duration(seconds: 2), () => print('2'));
final timers = [t1, t2, t3];
print('Running');
Stopwatch stopwatch = new Stopwatch()..start();
void main() async {
final t1 = () => Future.delayed(Duration(seconds: 1), () => print('1'));
final t2 = () => Future.delayed(Duration(seconds: 3), () => print('3'));
final t3 = () => Future.delayed(Duration(seconds: 2), () => print('2'));
final timers = [t1, t2, t3];
print('Running');
Stopwatch stopwatch = new Stopwatch()..start();
@yefim
yefim / editDistance.js
Last active April 26, 2019 23:53
Levenshtein distance implementation in JavaScript
const editDistance = (a, b) => {
if (a === '' || b === '') {
return Math.max(a.length, b.length);
}
return (a[0] === b[0] ? 0 : 1) + Math.min(
editDistance(a.substring(1), b.substring(1)),
editDistance(a.substring(1), b),
editDistance(a, b.substring(1))
);