Skip to content

Instantly share code, notes, and snippets.

View kirillzh's full-sized avatar
☀️

Kirill Zhukov kirillzh

☀️
View GitHub Profile
@kirillzh
kirillzh / DatabaseContents.kt
Last active February 15, 2023 07:33
Print contents of a SqlDelight (https://cashapp.github.io/sqldelight/) database. Formatted using picnic (https://github.com/JakeWharton/picnic)
import app.cash.sqldelight.async.coroutines.awaitQuery
import app.cash.sqldelight.db.SqlDriver
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
/**
* Describes contents of all tables in a database.
*/
data class DatabaseContents(
val tables: List<TableContents>,
@kirillzh
kirillzh / Bar.kt
Last active March 19, 2018 23:50
Kotlin Lint failing when Java accessing class, method or field annotated with "@VisibleForTesting(otherwise = VisibleForTesting.PACKAGE_PRIVATE)"
// Located in kotlin/com.example
package com.example
class Bar {
fun bar() {
Foo.doSomething()
// Lint complaining that "This method should only be accessed from tests or within package private scope" even though it's the same package
}
}
@kirillzh
kirillzh / README.md
Created September 28, 2016 23:57 — forked from polbins/README.md
Android Studio as default Git Diff Tool

Create Android Studio Command-line Launcher

  1. Open Android Studio
  2. Go to: Tools > Create Command-line Launcher
  3. Leave as default, Press OK

Configure Git to use Android Studio as default Diff Tool

  1. Add the following lines to your .gitconfig
-Xms1G
-Xmx4G
-XX:MaxPermSize=2G
-XX:ReservedCodeCacheSize=240m
-XX:+UseCompressedOops
-XX:MetaspaceSize=512m
@kirillzh
kirillzh / build-erlang-18.3.sh
Last active May 26, 2016 02:40 — forked from bryanhunter/build-erlang-17.0.sh
Build Erlang 18.3 on a fresh Ubuntu box
#!/bin/bash
# Pull this file down, make it executable and run it with sudo
# wget https://gist.githubusercontent.com/kirillzh/8f7cf870d3e67c8840f445a9fa2203b4/raw/c95e5bbdf3bed52dd4fcd4716de0e149be99f6b7/build-erlang-18.3.sh
# chmod u+x build-erlang-18.3.sh
# sudo ./build-erlang-18.3.sh
if [ $(id -u) != "0" ]; then
echo "You must be the superuser to run this script" >&2
exit 1
fi
@kirillzh
kirillzh / android_instructions.md
Created April 28, 2016 00:50 — forked from patrickhammond/android_instructions.md
Easily setup an Android development environment on a Mac

Here is a high level overview for what you need to do to get most of an Android environment setup and maintained.

Prerequisites (for Homebrew at a minimum, lots of other tools need these too):

  • XCode is installed (via the App Store)
  • XCode command line tools are installed (xcode-select --install will prompt up a dialog)
  • Java

Install Homebrew:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

require 'active_support/core_ext/object/deep_dup.rb'
class Object
def deep_reject!(*keys)
if is_a?(Hash)
keys.each { |k| delete(k) }
values.each { |v| v.deep_reject!(*keys) }
elsif is_a?(Array)
each { |x| x.deep_reject!(*keys) }
end
@kirillzh
kirillzh / google_trends.rb
Last active August 29, 2015 14:27
Hot trends
def deep_reject!(hash, keys)
if hash.is_a?(Hash)
Array(keys).each { |k| hash.delete(k) }
hash.values.each { |v| deep_reject!(v, keys) }
elsif hash.is_a?(Array)
hash.each { |x| deep_reject!(x, keys) }
end
hash
end
@kirillzh
kirillzh / files.rb
Last active August 29, 2015 14:25
Array of absolute file paths
# Recursively get absolute paths of the files with specified extension in specified directory
#
# @param ext [String] extension of the files to look for (default - any extension)
# @param pwd [String] absolute or relative path where to look for the files (default - current directory)
# @param list [Array<String>] used to recursively store absolute paths (default - [])
# @return [Array<String>] Array array of absolute paths of files in the directory with specified extension
def files(ext = '.*', pwd = Dir.pwd, list = [])
Dir[File.expand_path(File.join(pwd, '*'))].each do |path|
if File.directory?(path)
files(ext, path, list)