Skip to content

Instantly share code, notes, and snippets.

View mishadoff's full-sized avatar
🐼

Misha Kozik mishadoff

🐼
View GitHub Profile
@mishadoff
mishadoff / pg_array_index.sql
Created May 28, 2019 20:23
Array GIN index
-- Tinkering with postgres arrays
-- Part I: PREPARE
-- create table
create table movies (
title text,
tags text[],
year int
);
@mishadoff
mishadoff / sql_not_in_empty.sql
Last active May 3, 2019 08:49
SQL NOT IN EMPTY LIST
create table test (
key text,
value text
);
insert into test (key, value) values ('1', 'Pulp Fiction');
insert into test (key, value) values ('2', 'Reservoir Dogs');
insert into test (key, value) values ('3', 'Inglorius Bastards');
insert into test (key, value) values ('4', 'Django');
insert into test (key, value) values ('5', 'Kill Bill');
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "[ERROR] Provide a path!\n");
return 1;
}
char* path = argv[1];
public class com.mishadoff.RomanTheStack {
public com.mishadoff.RomanTheStack();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: ldc #2 // float 14.88f
@mishadoff
mishadoff / git_time_diff
Created July 15, 2015 09:31
Find the time difference between two commits
#!/bin/bash
#
# Find the time difference between two commits
# Usage: ./git_time_diff.sh 863a810d 7407b97c
commit1=$1
commit2=$2
ts1=$(git show -s --format=%ct $commit1)
ts2=$(git show -s --format=%ct $commit2)
@mishadoff
mishadoff / clojure-cup-ideas.md
Created September 4, 2014 11:45
Clojure Cup Ideas

1. Writool - tool for writers

Online markdown text editor capable to generate PDF and HTML. Contains a set of useful options for writers:

  • spelling correction
  • grammar checker
  • translations
  • synonyms

2. StoryTeller

# Using STM
Create a custom implementation of some data structure. Data structure
should work according to its definition,
follow the Big-O limitations,
be completely thread-safe in concurrent environment and use only STM
primitives in implementation.
You are free to use any Java STM library, but we recommend
[Multiverse STM](http://multiverse.codehaus.org/overview.html)
@mishadoff
mishadoff / gist:919ab09841e81005d6a2
Created June 16, 2014 11:23
jopbox usage example
(:require [jopbox.client :as dbx])
(def *APP-KEY* "YOUR_APP_KEY")
(def *APP-SECRET* "YOUR_APP_SECRET")
;; make consumer and request token
(def consumer (dbx/make-consumer *APP-KEY* *APP-SECRET*))
(def request-token (dbx/fetch-request-token consumer nil))
;; generate authorization url
(defn solve [r t]
"r - initial radius, t - mls of paint"
(letfn [(nrings [n]
(+' (*' 2 n n)
(-' n)
(*' 2 r n)))
(binary [[a b]]
(cond (or (= a b) (= (inc a) b)) a
:else (let [avg (quot (+' a b) 2)
pnt (nrings avg)]
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>