Skip to content

Instantly share code, notes, and snippets.

View pjhjohn's full-sized avatar
☁️
Cloud

JoonHo Park pjhjohn

☁️
Cloud
View GitHub Profile
/* 1. Using this.props.children */
// containers/Post.js
<PostDetail key={this.props.post.id} {...this.props.post} >
{this.props.comments.map((comment) => <Comment key={comment.id} {...comment} />)}
</PostDetail>
// components/PostDetail.js
<div>
{this.props.children}
<div/>
/* 2. transfer using props */
@pjhjohn
pjhjohn / MainActivity.java
Created January 6, 2017 06:52
Minimal Permission Example
package ly.soundl.test.batterytester;
import android.Manifest;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
@pjhjohn
pjhjohn / gitget.py
Last active February 11, 2017 10:10
gitget allows you to get current git commit hash or tag name
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os, subprocess, shlex
# param 'short' for shortening hash (slice for commit hash, abbreviation for tag name)
# param 'tag and not commit' for returning tag name only
# param 'commit and not tag' for returning commit hash only
def gitget(short=False, tag=False, commit=False):
if tag and commit : tag, commit = False, False
# Cosntants
@pjhjohn
pjhjohn / _base.html
Created April 17, 2017 15:54
Bootstrap Material Design Setup in Django
{% load static %}
{% load string_filters %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>EPG Automator</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
package io.bitsound.apitestapp.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import java.util.Locale;
import io.bitsound.receiver.BitsoundContents;
07-09 02:23:02.901 29753-29753 D/BitsoundSmartOnReceiver: [onReceive] __INSTANCE__apitestapp.receivers.BitsoundSmartOnReceiver@ea1db58__LISTENER__apitestapp.MainActivity$$Lambda$18@9cf64b1__THIS__apitestapp.receivers.BitsoundSmartOnReceiver@e1a3056
07-09 02:23:14.855 29753-29753 D/BitsoundSmartOnReceiver: [onReceive] __INSTANCE__apitestapp.receivers.BitsoundSmartOnReceiver@ea1db58__LISTENER__apitestapp.MainActivity$$Lambda$18@9cf64b1__THIS__apitestapp.receivers.BitsoundSmartOnReceiver@a20fbe2
07-09 02:23:19.882 29753-29753 D/BitsoundSmartOnReceiver: [onReceive] __INSTANCE__apitestapp.receivers.BitsoundSmartOnReceiver@ea1db58__LISTENER__apitestapp.MainActivity$$Lambda$18@9cf64b1__THIS__apitestapp.receivers.BitsoundSmartOnReceiver@2d6f42e
07-09 02:23:26.895 29753-29753 D/BitsoundSmartOnReceiver: [onReceive] __INSTANCE__apitestapp.receivers.BitsoundSmartOnReceiver@ea1db58__LISTENER__apitestapp.MainActivity$$Lambda$18@9cf64b1__THIS__apitestapp.receivers.BitsoundSmartOnReceiver@6e2253a
07-09 02:23:38.8

Remote Debugging using wi-fi

We need remote debugger to get logs from the device through logcat. Both the device and PC should be under same wi-fi router : like mrl

  1. Connect the device to the PC using USB and establish an ADB connection
  2. adb tcpip 5555 # 5555 is the port number
  3. Disconnect your USB cable
  4. adb connect MOBILE_IP:port => adb connect 192.IP_REMAINING:5555
  5. Tern on AndroidStudio and check the logcat
@pjhjohn
pjhjohn / echo.kt
Last active August 25, 2017 14:32
Kotlin Infix suggestion : echo
infix fun <T> T.echo(activity: MainActivity): T {
when (this) {
is Int -> activity.logging(Stringify.result(this), TextLogData.Type.MESSAGE)
is String -> activity.logging(this, TextLogData.Type.MESSAGE)
else -> activity.logging("Unexpected arguments for $this.echo($activity)", TextLogData.Type.MESSAGE)
}
return this
}
fun foo() = this.let { activity ->
@pjhjohn
pjhjohn / Storage.kt
Last active November 22, 2017 09:14
Utility Object for Easy Use of SharedPreferences
package io.sample.utils
import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
import io.sample.App
import java.util.*
object Storage {
/* Package Inspection */
val manager = this.packageManager
manager.getInstalledPackages(0)
.map { manager.getApplicationInfo(it.packageName, 0) }
.forEach { Timber.d("${it.packageName} installed at ${it.publicSourceDir} is ${if (it.flags and ApplicationInfo.FLAG_SYSTEM != 0) "a system app" else "not a system app"}") }