Skip to content

Instantly share code, notes, and snippets.

View defHLT's full-sized avatar
🐔

Artem Kholodnyi defHLT

🐔
View GitHub Profile
anonymous
anonymous / BitmapCache.java
Created October 22, 2014 14:27
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
import com.android.volley.toolbox.ImageLoader.ImageCache;
public class BitmapCache extends LruCache<String, Bitmap> implements ImageCache
{
public static final int SIZE = 10 * 1024 * 1024;
public BitmapCache()
{
anonymous
anonymous / continuous_deploy.sh
Created May 16, 2013 21:12
A short script to perform auto install on multiple Android devices by watching a specific folder for an .apk write. Usage: ./continuous_deploy.sh com.example.package/.MainActivity
folder="bin/classes/"
package="$1"
inotifywait -m -q -e close_write "$folder" | while read f; do
# take only the filename
f=`awk '{print $3}' <<< "$f"`
# rebuild the full path
path="$folder$f"
@deebloo
deebloo / rxjs-worker-map.example.js
Last active August 19, 2016 17:24
A RxJs operator that runs in a new thread. https://github.com/deebloo/rxjs-worker
// https://github.com/deebloo/rxjs-worker
var observable = Observable.of([0, 1, 2, 3, 4]);
observable
.map(function (data) {
return data.concat([5, 6, 7, 8, 9]);
})
.workerMap(function (data) {
return data.concat([10,11,12,13,14]);;
})
@mkurtikov
mkurtikov / ruby_sintata.rb
Created April 14, 2016 15:47
Sinatra Basics
require 'sinatra'
require 'sinatra/param'
require 'sinatra/json'
set :raise_sinatra_param_exceptions, true
set :show_exceptions, false
get '/hi' do
param :param1, Float, required: true
param :param2, Float, required: true
@nschwermann
nschwermann / ClipRevealFrame
Created December 19, 2014 06:34
CircularReveal backport
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class ClipRevealFrame extends FrameLayout{
private Path mRevealPath;
@halgari
halgari / gist:7028120
Last active January 31, 2018 12:32
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)]
@rauhs
rauhs / spy.clj
Created February 10, 2018 17:58
(ns spy.core)
(defn- get-hostname []
(.. java.net.InetAddress getLocalHost getHostName))
(def debug?
"ADAPT ME!!"
(delay (or (= "dev" (System/getProperty "nomad.env"))
(= (get-hostname) "sky"))))
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;
@sirupsen
sirupsen / tdo.rb
Created December 13, 2009 01:46
Gist for "What I Wish a Ruby Programmer Had Told Me One Year Ago".
class TodoList < Array
def self.load(file)
# read the file, create a list, create items, add them to the list, return the list
list = TodoList.new
File.read(file).each_line do |line|
list << line.chomp
end
list
end
@jdegoes
jdegoes / HigherKindedJava.java
Last active January 9, 2019 11:23
Modeling higher-kinded types in a language without them.
class Option<A> {
protected Option() { }
}
interface App<F, A> {
F proof();
}
class OptionF {
private OptionF() {}
private static class AppOption<A> implements App<OptionF, A> {