Skip to content

Instantly share code, notes, and snippets.

View defHLT's full-sized avatar
🐔

Artem Kholodnyi defHLT

🐔
View GitHub Profile
@defHLT
defHLT / day_1.clj
Last active December 10, 2016 17:10
Advent of Code 2016 -- day 1
(ns advent-of-code.day-1)
(def data
(let [xf (map (fn [x] [(if (= (first x) \R) 1 -1)
(Integer/parseInt (apply str (rest x)))]))]
(as-> (slurp "resources/aoc-d1-input") $
(clojure.string/split $ #"[, \n]+")
(into [] xf $))))
(def locations (atom #{}))
(def triangles [566 477 376 575 488 365 50 18 156 558 673 498 133 112 510 670 613 25 84 197 643 910 265 611 894 252 545 581 3 598 98 742 574 628 746 193 129 677 265 187 445 169 288 242 128 569 744 439 685 748 471 256 23 157 218 343 491 777 905 633 778 867 840 672 772 947 500 763 420 449 665 653 23 558 858 745 407 904 766 194 576 11 541 423 179 690 274 174 747 279 741 538 336 507 698 667 689 920 467 405 861 35 575 631 992 317 573 981 817 536 44 816 205 653 45 631 683 509 300 418 712 192 865 666 133 859 32 331 54 572 432 259 552 456 267 766 931 643 902 840 557 465 318 175 491 863 329 463 795 564 589 213 805 340 323 123 602 812 499 898 931 555 899 835 341 316 487 789 677 790 797 341 502 123 502 196 136 702 617 82 939 581 362 801 834 951 464 941 843 7 756 971 273 297 661 270 620 387 776 96 80 891 125 92 376 175 141 435 247 949 719 586 478 578 662 801 446 202
@defHLT
defHLT / aoc-d3.clj
Last active December 3, 2016 19:26
Advent of Code: Day 3
(def triangles [566 477 376 575 488 365 50 18 156 558 673 498 133 112 510 670 613 25 84 197 643 910 265 611 894 252 545 581 3 598 98 742 574 628 746 193 129 677 265 187 445 169 288 242 128 569 744 439 685 748 471 256 23 157 218 343 491 777 905 633 778 867 840 672 772 947 500 763 420 449 665 653 23 558 858 745 407 904 766 194 576 11 541 423 179 690 274 174 747 279 741 538 336 507 698 667 689 920 467 405 861 35 575 631 992 317 573 981 817 536 44 816 205 653 45 631 683 509 300 418 712 192 865 666 133 859 32 331 54 572 432 259 552 456 267 766 931 643 902 840 557 465 318 175 491 863 329 463 795 564 589 213 805 340 323 123 602 812 499 898 931 555 899 835 341 316 487 789 677 790 797 341 502 123 502 196 136 702 617 82 939 581 362 801 834 951 464 941 843 7 756 971 273 297 661 270 620 387 776 96 80 891 125 92 376 175 141 435 247 949 719 586 478 578 662 801 446 202
cache:
paths:
- app/version.properties
before_script:
- export ANDROID_HOME=/opt/android
- touch app/version.properties
- ./gradlew clean
build:
@defHLT
defHLT / state.kt
Last active September 20, 2016 11:38
var state: MutableMap<String, Any?> = HashMap()
private var foo: Int by state
private var bar: String by state
override fun onSaveInstanceState(): Parcelable {
// ...
@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 / 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
<!DOCTYPE html>
<html>
<head>
<title>SVG SMIL Animate with Path</title>
</head>
<body>
<svg width="300px" height="100px">
<rect x="0" y="0" width="300" height="100" stroke="black" stroke-width="1" />
<rect x="0" y="0" width="20" height="20" fill="blue" stroke="black" stroke-width="1">
<animateMotion path="M 250,80 H 50 Q 30,80 30,50 Q 30,20 50,20 H 250 Q 280,20,280,50 Q 280,80,250,80Z"
@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);