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
@zhongwencool
zhongwencool / httpoison_request_response_example.ex
Last active January 27, 2021 16:02
maxwell vs httpoison vs httppotion examples
defmodule Httpoison.GitHub do
use HTTPoison.Base
def process_url(url) do
"https://api.github.com" <> url
end
def process_request_headers(headers) do
Dict.put headers, :"User-Agent", "github-httpoison"
end
@v-kolesnikov
v-kolesnikov / 00_destructuring.md
Created February 6, 2016 17:28 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

@mokevnin
mokevnin / Dockerfile
Last active January 27, 2016 15:01
python handler for battle.hexlet.io
FROM hexlet/hexlet-base
RUN apt-install python-pip python-dev
RUN apt-install python3-pip python3-dev
RUN pip3 install pytest
ENV PYTHONDONTWRITEBYTECODE 1
@paulirish
paulirish / what-forces-layout.md
Last active April 30, 2024 17:56
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@CMCDragonkai
CMCDragonkai / http_streaming.md
Last active April 25, 2024 17:19
HTTP Streaming (or Chunked vs Store & Forward)

HTTP Streaming (or Chunked vs Store & Forward)

The standard way of understanding the HTTP protocol is via the request reply pattern. Each HTTP transaction consists of a finitely bounded HTTP request and a finitely bounded HTTP response.

However it's also possible for both parts of an HTTP 1.1 transaction to stream their possibly infinitely bounded data. The advantages is that the sender can send data that is beyond the sender's memory limit, and the receiver can act on

@ostinelli
ostinelli / ecdsa_example.rb
Last active April 14, 2024 17:32
ECDSA usage from Ruby.
require 'openssl'
require 'base64'
# ===== \/ sign =====
# generate keys
key = OpenSSL::PKey::EC.new("secp256k1")
key.generate_key
public_key = key.public_key
public_key_hex = public_key.to_bn.to_s(16).downcase # public key in hex format
#%RAML 0.8
title: World Music API
baseUri: http://example.api.com/{version}
version: v1
schemas:
- halLink: |
{ "$schema": "http://json-schema.org/schema",
"type": "object",
"description": "a Hypertext Application Language link",
@ahoy-jon
ahoy-jon / small-Y.clj
Last active April 22, 2017 05:37
Small and pluggable Y combinator in clojure.
;; ; made this macro scraching my head between the simplicity of Haskell for fix
;; ; and the absence of curryfication in Clojure.
;; (P expr-fn) ; makes expr-fn lazy
;; (P P expr-fn) ; curry one time expr-fn
;; (P P P expr-fn) ; curry two time expr-fn
;; (= ((((P P P str) "a") "b") "c") "abc") ;=> true
(defmacro P [& f]
(let [x (gensym 'x)] ;; cannot be replaced by x# due to nested macro expansion.
@seyhunak
seyhunak / apache_bench.sh
Last active July 5, 2023 17:02
Rails - Apache Bench - Load Testing (if Devise Sign-in Required)
1.
LOGIN_PAGE=http://localhost/users/sign_in
curl --cookie-jar cookie_file $LOGIN_PAGE | grep csrf-token
2.
<meta content="csrf-token" name="csrf-token" />
@skanev
skanev / rubocop.rb
Last active March 13, 2024 08:24
A Rubocop wrapper that checks only added/modified code
#!/usr/bin/env ruby
# A sneaky wrapper around Rubocop that allows you to run it only against
# the recent changes, as opposed to the whole project. It lets you
# enforce the style guide for new/modified code only, as opposed to
# having to restyle everything or adding cops incrementally. It relies
# on git to figure out which files to check.
#
# Here are some options you can pass in addition to the ones in rubocop:
#