Skip to content

Instantly share code, notes, and snippets.

@JoseAlcerreca
JoseAlcerreca / ObservableViewModel.kt
Last active February 28, 2021 00:07
An Observable ViewModel for Data Binding and Architecture Components
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@SemanticallyNull
SemanticallyNull / SyslogFacilityPriorityMatrix.md
Last active February 5, 2024 00:29
Syslog Facility Priority Matrix

The Priority value is calculated by first multiplying the Facility number by 8 and then adding the numerical value of the Severity. For example, a kernel message (Facility=0) with a Severity of Emergency (Severity=0) would have a Priority value of 0. Also, a "local use 4" message (Facility=20) with a Severity of Notice (Severity=5) would have a Priority value of 165. In the PRI of a syslog message, these values would be placed between the angle brackets as <0> and <165> respectively. The only time a value of "0" follows the "<" is for the Priority value of "0". Otherwise, leading "0"s MUST NOT be used. – RFC 5424, Section 6.2.1

Severity ➡️ 0 1 2 3 4 5 6 7
Facilities ⤵️
kernel (0) 0 1 2 3 4 5 6 7
user (1) 8 9 10 11 12 13 14 15
mail (2) 16 17 18 19 20 21 22 23
system (3) 24 25 26 27 28 29 30
@chitacan
chitacan / README.md
Last active September 19, 2017 08:19
How Android Inspect Battery

How Android Inspect Battery

최종 업데이트 : 2014-07-14 15:44:18

기본 정보 확인하기

Intent.ACTION_BATTERY_CHANGEDBroadcast receiver에 등록해 변경사항이 있을때마다, 정보를 수신할 수 있음

아니면, dumpsys 를 통해 바로 확인할 수 있음

@robUx4
robUx4 / gist:7543300
Last active December 28, 2015 18:29
OrientationDrawable: a Drawable that handles orientation changes without allocating anything updated with a fix when a Matrix is already applied in the canvas
/*
* Copyright (C) 2013 LevelUp Studio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@benelog
benelog / AsyncTask-executor-problem.md
Last active August 27, 2021 16:15
AsyncTask 분석

변경이력

  • 2013/10/15: Dianne Hackborn의 언급에 대한 번역은 안세원님이 교정해주신 내용으로 교체합나디.

AsyncTask는 API Level 13이상 버전이 설치된 기기에서 android:targetSdkVersion가 13이상 일 때 여러 개의 AsyncTask가 동시에 실행되어도 순차적으로 호출됩니다.

기기의 버전뿐만 아니라 targetSDK 설정에도 영향을 받으므로 target SDK 설정을 변경할 때 유의해야 합니다. 그리고 가능하다면 목적별로 스레드풀을 분리하고, 스레드의 갯수가 늘어나는 것에 대비해 무작정 큰 최대값을 주는것보다는 Timeout과 RejectionPolicy로 관리를 하는 편이 바람직합니다.

@imminent
imminent / AndroidCookieStore.java
Last active December 14, 2015 06:38
Collection of code to use the Client interface of Retrofit to use HttpUrlConnection with SharedPreferences persistent cookies.
import android.annotation.TargetApi;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.PatternMatcher;
import com.keepandshare.android.utils.CryptographyUtil;
import com.keepandshare.android.utils.Ln;
import javax.inject.Singleton;
import java.net.CookieStore;
import java.net.HttpCookie;
@khernyo
khernyo / build.gradle
Created December 6, 2012 18:39
Gradle Android configuration with .so hack
// This hack works with com.android.tools.build:gradle:0.2, won't work in later version without modification
apply plugin: 'android'
targetCompatibility = 1.6
sourceCompatibility = 1.6
android {
target = 'android-14'
@comfuture
comfuture / DBStorageStream.php
Created May 23, 2011 06:14
using database as filesystem
<?php
class DBStorageStream
{
const DDL = <<<EOF
CREATE TABLE IF NOT EXISTS `table_dbfs` (
`path` VARCHAR(255) NOT NULL PRIMARY KEY,
`data` LONGTEXT,
`is_dir` CHAR(1) NOT NULL DEFAULT 'N',
`created_at` DATETIME,
@lifthrasiir
lifthrasiir / 2to10to7.c
Created April 18, 2011 20:37
2^(10^k)
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
typedef uint32_t digit; // should be able to represent 0..3*BASE-1
typedef uint64_t digit2; // should be as large as maxdigit + maxdigit * maxdigit
#define BASE 1000000000u