Skip to content

Instantly share code, notes, and snippets.

View defHLT's full-sized avatar
🐔

Artem Kholodnyi defHLT

🐔
View GitHub Profile
@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 / 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}
@defHLT
defHLT / BetterRecyclerView.java
Created September 4, 2016 22:56 — forked from okmanideep/BetterRecyclerView.java
A RecyclerView that intercepts the scroll on if the user is scrolling in that direction
public class BetterRecyclerView extends RecyclerView{
private static final int INVALID_POINTER = -1;
private int mScrollPointerId = INVALID_POINTER;
private int mInitialTouchX, mInitialTouchY;
private int mTouchSlop;
public BetterRecyclerView(Context context) {
this(context, null);
}
public BetterRecyclerView(Context context, @Nullable AttributeSet attrs) {
@defHLT
defHLT / clj_spec_playground.clj
Created July 16, 2016 19:38 — forked from ghoseb/clj_spec_playground.clj
Examples of Clojure's new clojure.spec library
(ns clj-spec-playground
(:require [clojure.string :as str]
[clojure.spec :as s]
[clojure.test.check.generators :as gen]))
;;; examples of clojure.spec being used like a gradual/dependently typed system.
(defn make-user
"Create a map of inputs after splitting name."
([name email]
@defHLT
defHLT / BadgeUtils
Created June 25, 2016 12:42 — forked from Tadas44/BadgeUtils
Launcher icon notification for Samsung and Sony Xperia devices
public class BadgeUtils {
public static void setBadge(Context context, int count) {
setBadgeSamsung(context, count);
setBadgeSony(context, count);
}
public static void clearBadge(Context context) {
setBadgeSamsung(context, 0);
@defHLT
defHLT / RxFirebase.java
Created May 24, 2016 16:57 — forked from gsoltis/RxFirebase.java
RxJava Bindings for Firebase
package com.firebase.client;
import com.firebase.client.core.Constants;
import rx.Observable;
import rx.Subscriber;
import rx.functions.Action0;
import rx.functions.Func1;
import rx.subscriptions.Subscriptions;
public class RxFirebase {
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.util.Pair;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import rx.Observable;
import rx.subscriptions.Subscriptions;
package rx.android.observables;
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.android.subscriptions.AndroidSubscriptions;
import rx.functions.Action0;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;