Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Stanislav (Stas) Katkov skatkov

🏠
Working from home
View GitHub Profile
@skatkov
skatkov / dep-extract.rb
Created Oct 12, 2020
extract Ruby dependencies
View dep-extract.rb
#!/usr/bin/env ruby
require 'bundler'
require 'csv'
lock_file = Bundler::LockfileParser.new(Bundler.read_file("Gemfile.lock"))
def url_for(spec)
case spec.source
when Bundler::Source::Rubygems
@skatkov
skatkov / ruby_data_object_comparison.rb
Last active Sep 17, 2020 — forked from palexander/ruby_data_object_comparison.rb
Benchmark to compare hash, OpenStruct, struct, and classes in Ruby
View ruby_data_object_comparison.rb
require 'ostruct'
require 'benchmark'
COUNT = 10_000_000
NAME = "Test Name"
EMAIL = "test@example.org"
class Person
def initialize(name:, email:)
@name = name
View Gemfile.tools
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
ruby '2.6.6'
gem 'pronto'
@skatkov
skatkov / lefthook.yml
Created Jun 10, 2020
lefthook config
View lefthook.yml
pre-commit:
parallel: true
commands:
eslint:
glob: "*.{js}"
run: yarn prettier --write {staged_files} && yarn eslint {staged_files} && git add {staged_files}
css:
glob: "*.{css}"
run: yarn prettier --write {staged_files} && git add {staged_files}
rubocop:
View bundle-checkinstall
#!/bin/bash
BRANCH_CHANGE=$3
[[ $BRANCH_CHANGE -eq 0 ]] && exit
PREV_HEAD=$1
CURR_HEAD=$2
[ $PREV_HEAD == $CURR_HEAD ] && exit
# Don't run bundler if there were no changes in gems
@skatkov
skatkov / .env
Last active Aug 12, 2020
Progressive mailchimp subscription on Netlify
View .env
MAILCHIMP_API_KEY="...-us19"
MAILCHIMP_LIST_ID="..."
@skatkov
skatkov / subscribe.js
Created Aug 30, 2019
netlify function: mailchimp subscribe
View subscribe.js
/* eslint-disable */
const axios = require('axios');
require('dotenv').config();
exports.handler = function(event, context, callback) {
const password = process.env.MAILCHIMP_API_KEY;
console.log(password);
if (!password) {
console.error('No MailChimp API Key include in environment variables');
process.exit(1);
View gist:242e124c51b55160f877a5488d2c7635
### Keybase proof
I hereby claim:
* I am skatkov on github.
* I am skatkov (https://keybase.io/skatkov) on keybase.
* I have a public key ASDWCFGd352PjfJK8TGdTs4v1UJIgKEW8mOc8jJwECTOBQo
To claim this, I am signing this object:
@skatkov
skatkov / wip_graphql_demo.rb
Created May 2, 2018 — forked from marckohlbrugge/wip_graphql_demo.rb
Ruby example of creating a todo and then completing it using wip.chat graphql.
View wip_graphql_demo.rb
# NOTE: Be sure to set the API key further down in the code!
require "net/http"
require "uri"
require "json"
class WIP
def initialize(api_key:)
@api_key = api_key
end
@skatkov
skatkov / string_auto_clear.rb
Last active Jan 29, 2018
String removal from malloc
View string_auto_clear.rb
class String
def auto_clear
begin
result = yield self
result.equal?(self) ? nil : result # avoid leaking
ensure
clear
end
end
end