Skip to content

Instantly share code, notes, and snippets.

View defHLT's full-sized avatar
🐔

Artem Kholodnyi defHLT

🐔
View GitHub Profile
@defHLT
defHLT / reflog.sh
Created January 5, 2017 13:48
Undo a git rebase.
# Solution found here: http://stackoverflow.com/questions/134882/undoing-a-git-rebase
# The easiest way would be to find the head commit of the branch as it was immediately before the rebase started in the reflog...
git reflog
# and to reset the current branch to it (with the usual caveats about being absolutely sure before reseting with the --hard option).
# Suppose the old commit was HEAD@{5} in the ref log
git reset --hard HEAD@{5}
final View target = findViewById(R.id.target);
// Create path you would like your view to follow
Path p = new Path();
RectF circle = new RectF(0, 0, 400f, 400f);
p.arcTo(circle, 0, 180);
p.arcTo(circle, 180, 180);
final PathMeasure pm = new PathMeasure(p, false);
@defHLT
defHLT / gist:6b68dd358b7b57ca71f1
Created July 5, 2015 18:55
Sqlite Mandelbrot
-> ice ~ % sqlite3
SQLite version 3.8.6 2014-08-15 11:46:33
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite>
WITH RECURSIVE xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2), yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0), m(iter, cx, cy, x, y) AS ( SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis UNION ALL SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m WHERE (x*x + y*y) < 4.0 AND iter<28 ), m2(iter, cx, cy) AS ( SELECT max(iter), cx, cy FROM m GROUP BY cx, cy ), a(t) AS ( SELECT group_concat( substr(' .+*#', 1+min(iter/7,4), 1), '') FROM m2 GROUP BY cy ) SELECT group_concat(rtrim(t),x'0a') FROM a;
sqlite> ....#
..#*..
..+####+.
// Insert current date in Google Spreadsheet
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or FormApp or SpreadsheetApp.
ui.createMenu('Custom Menu')
.addItem('Insert Date', 'insertDate')
.addToUi();
}
@defHLT
defHLT / output.txt
Created February 24, 2018 11:40 — forked from jonpryor/output.txt
Demonstrate bash dynamic scoping
start: str=begin
inner: str=outer
end: str=begin
@defHLT
defHLT / rich-already-answered-that.md
Created February 21, 2018 02:36 — forked from reborg/rich-already-answered-that.md
Clojure Design Decisions

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats. The link below jumps at the answer in this file, the link on the question points back at the original post.

Index:

@defHLT
defHLT / gist:b41496e4f41d36b5e0c7d5c96eb327cd
Created January 31, 2018 12:32 — forked from halgari/gist:7028120
Async Agents via core.async
(use 'clojure.core.async)
(defprotocol ISendable
(channel [this]))
(defn async-agent [state]
(let [c (chan Long/MAX_VALUE) ;; <<-- unbounded buffers are bad, but this matches agents
a (atom state)]
(go-loop []
(when-let [[f args] (<! c)]
@defHLT
defHLT / ray-parser.rb
Last active September 11, 2017 14:27
Parser from markdown to wordpress for RayWenderlich website
#!/usr/bin/ruby
require 'redcarpet'
class RayParser < Redcarpet::Render::HTML
# *important concept*
def emphasis(text)
"<i>#{text}</i>"
end
import hu.akarnokd.rxjava2.schedulers.BlockingScheduler
import io.reactivex.Single
import io.reactivex.functions.BiFunction
import io.reactivex.plugins.RxJavaPlugins
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.launch
import kotlinx.coroutines.experimental.runBlocking
import java.util.concurrent.TimeUnit
" Plugins
call plug#begin('~/.config/nvim/plugged')
" Autocomplete
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
let g:deoplete#enable_at_startup = 1
" JS
Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern' }
Plug 'pangloss/vim-javascript'