Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working from home

nekocode nekocode

🏡
Working from home
View GitHub Profile
@josdejong
josdejong / merge.kt
Last active Aug 13, 2020
Merge two data classes in Kotlin
View merge.kt
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.primaryConstructor
/**
* Merge two data classes
*
* The resulting data class will contain:
* - all fields of `other` which are non null
* - the fields of `this` for the fields which are null in `other`
*
@Pulimet
Pulimet / AdbCommands
Last active Dec 1, 2020
Adb useful commands list
View AdbCommands
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@biezhi
biezhi / QRterminal.java
Last active Jun 6, 2019
Java二维码输出到控制台,需引入 zing 库,颜色代码见 https://gist.github.com/zfkun/9755885
View QRterminal.java
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import java.util.Hashtable;
View force_options_menu_in_actionbar.java
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
@SupaHam
SupaHam / DynamicProxies.kt
Last active Jul 7, 2020
Dynamic Proxies with Kotlin for accessing private classes.
View DynamicProxies.kt
/*
* Code by @vmironov on Kotlinlang slack.
*
* This code uses dynamic proxies in Java to make it easier to access inaccessible classes via an accessible representation.
*/
inline fun <reified T : Any> createMirror(value: Any) = createMirror(value, T::class.java)
fun <T> createMirror(value: Any, clazz: Class<T>): T {
val loader = clazz.classLoader
@lisawray
lisawray / MainActivity.java
Last active Jun 22, 2018
Vector drawables from XML with the Android support library 23.3.0
View MainActivity.java
package com.xwray.vectorbinding;
import android.databinding.BindingAdapter;
import android.databinding.DataBindingUtil;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.graphics.drawable.VectorDrawableCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
@neworld
neworld / howto.md
Last active Sep 15, 2020
How to make faster Android build without sacrificing new api lint check
View howto.md

Original solution sacrifices new api lint check.

Here my solution:

int minSdk = hasProperty('minSdk') ? minSdk.toInteger() : 16

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
@gokulkrishh
gokulkrishh / media-query.css
Last active Dec 1, 2020
CSS Media Queries for Desktop, Tablet, Mobile.
View media-query.css
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@jeromerobert
jeromerobert / pandoc-svg.py
Last active Jul 17, 2020
Pandoc filter to create PDF files from SVG
View pandoc-svg.py
#! /usr/bin/env python
"""
Pandoc filter to convert svg files to pdf as suggested at:
https://github.com/jgm/pandoc/issues/265#issuecomment-27317316
"""
__author__ = "Jerome Robert"
import mimetypes
import subprocess
You can’t perform that action at this time.