Skip to content

Instantly share code, notes, and snippets.

@lekaha
lekaha / jekyll-post.py
Last active May 17, 2016 15:41
nbconvert config script
try:
from urllib.parse import quote # Py 3
except ImportError:
from urllib2 import quote # Py 2
import os
import sys
import datetime
fullname = None
f = None
for arg in sys.argv:
@lekaha
lekaha / jekyll-post.tpl
Created May 17, 2016 15:50
nbconvert template
{% extends 'markdown.tpl' %}
{%- block header -%}
---
layout: post
title: "{{resources['metadata']['name']}}"
categories: wiki
tags:
- python
- notebook
@lekaha
lekaha / RakeFile.rb
Last active May 17, 2016 15:54
Build script
GH_PAGES_DIR = "lekaha.github.io"
desc "Build Jekyll site and copy files"
task :build do
Dir.foreach('notebooks') do |item|
next if item == '.' or item == '..' or Dir.exists?(item) or item[/^(.*\.(md|ipynb_checkpoints|py|tpl)$)?$/i]
Dir.chdir "notebooks/"
sh "ipython nbconvert --config jekyll-post #{item}"
Dir.chdir "../"
end
@lekaha
lekaha / android dependencies
Last active June 21, 2018 12:00
dependencies.gradle
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
ext {
@lekaha
lekaha / RoundedBottomSheetDialogFragment.kt
Created June 23, 2018 16:31 — forked from ArthurNagy/RoundedBottomSheetDialogFragment.kt
Rounded modal bottom sheet as seen in new Google products(Tasks, News, etc.)
package com.your.package
import android.app.Dialog
import android.os.Bundle
import com.your.package.R
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
/**
* BottomSheetDialog fragment that uses a custom
@lekaha
lekaha / dsl_marker.kt
Created June 29, 2018 01:03
Example of using DSL marker annotation
@DslMarker
annotation class ReceiptDsl
data class Amount(val total: Int, val tax: Float)
data class Receipt(val title: String, val date: String, val staffName: String, val amount: Amount)
@ReceiptDsl
class AmountBuilder {
var total: Int = 0
var tax: Float = .0f
fun println(λ: () -> Any) = kotlin.io.println(λ())
@lekaha
lekaha / GlideConfiguration.kt
Created July 10, 2018 02:54
Glide using tips
@GlideModule
class MyAppGlideModule: AppGlideModule() {
override fun applyOptions(context: Context, builder: GlideBuilder) {
super.applyOptions(context, builder)
builder.setDefaultRequestOptions(
RequestOptions()
.format(DecodeFormat.PREFER_ARGB_8888)
.diskCacheStrategy(DiskCacheStrategy.DATA)
@lekaha
lekaha / SimpleRxBluetoothAdapter.java
Created September 18, 2018 08:00
SimpleRxBluetoothAdapter is a BT utility with Rx
package mobile.lekeha.android.bluetoothadapter;
import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;