Skip to content

Instantly share code, notes, and snippets.

View v-kolesnikov's full-sized avatar
✍️
I'm writing something just now! You can write me too! 😉

Vasily Kolesnikov v-kolesnikov

✍️
I'm writing something just now! You can write me too! 😉
View GitHub Profile
@brandur
brandur / go.mod
Last active July 25, 2023 21:41
PartialEqual implementation
module github.com/brandur/prequire
go 1.19
require github.com/stretchr/testify v1.8.1
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
@brandur
brandur / uuid.rb
Created April 14, 2022 00:34
UUID data type in Ruby
# typed: strict
# frozen_string_literal: true
require "base32"
require "securerandom"
require "ulid"
# A type to represent UUIDs. Particularly useful for annotating fields in API
# representations or Sorbet parameters to help prevent accidentally mixing up
# UUIDs and EIDs as they're being passed around as loose strings.
@cmod
cmod / hugofastsearch.md
Last active March 22, 2024 07:02 — forked from eddiewebb/readme.md
Fast, instant client side search for Hugo static site generator

Super fast, keyboard-optimized, client side Hugo search

This is a fork of and builds upon the work of Eddie Webb's search and Matthew Daly's search explorations.

It's built for the Hugo static site generator, but could be adopted to function with any json index compatible with Fuse fuzzy search library.

To see it in action, go to craigmod.com and press CMD-/ and start typing.

Fast Search

@ren6
ren6 / app_store_receipt_example.json
Created October 15, 2019 12:57
Example of App Store receipt with 2 auto-renewable transactions (trial and renewal)
{
"status": 0,
"environment": "Sandbox",
"receipt": {
"receipt_type": "ProductionSandbox",
"adam_id": 0,
"app_item_id": 0,
"bundle_id": "com.apphud.subscriptionstest",
"application_version": "1",
"download_id": 0,
class Jobs < ROM::Relation[:sql]
schema(:jobs) do
# ...
associations do
belongs_to :team
belongs_to :template
belongs_to :address
belongs_to :client
end
@palkan
palkan / Gemfile
Last active March 21, 2024 00:29
RSpec profiling with RubyProf and StackProf
gem 'stackprof', require: false
gem 'ruby-prof', require: false
@lnostdal
lnostdal / atomically_rename.clj
Last active August 27, 2021 10:12
Move a file atomically in Clojure
;;; Move a file atomically in Clojure.
;; This will also replace the target file if it exists since REPLACE_EXISTING is included in the options at the end.
;; user.dir == current working directory (on Linux at least).
(let [source-filename (str (System/getProperty "user.dir") "/source.txt")
target-filename (str (System/getProperty "user.dir") "/target.txt")
source-file (java.nio.file.Paths/get (java.net.URI/create (str "file://" source-filename)))
target-file (java.nio.file.Paths/get (java.net.URI/create (str "file://" target-filename)))]
(java.nio.file.Files/move source-file target-file
@adam12
adam12 / context.yml
Last active May 23, 2019 07:37 — forked from thinkerbot/context.yml
ERB vs Erubis vs Erubi
list:
- name: Adobe Systems
name2: Adobe Systems Inc.
url: http://www.adobe.com
symbol: ADBE
price: 39.26
change: 0.13
ratio: 0.33
- name: Advanced Micro Devices
name2: Advanced Micro Devices Inc.
@flash-gordon
flash-gordon / env_validation.rb
Created September 18, 2016 10:14
ENV validation POC
require 'dry-validation'
class EnvValidation
class ENV
def inspect
ivs = instance_variables.each { |v| "#{v}=#{instance_variable_get(v)}" }.join(', ')
"ENV[#{ivs}]"
end
def to_s
@v-kolesnikov
v-kolesnikov / y_combinator.clj
Last active August 12, 2016 18:12
Y-Combinator
(defn factorial [n]
(let [y (fn [f] (f f))
f (fn [g] (fn [n] (if (zero? n) 1 (* n ((g g) (dec n))))))]
((y f) n)))