Skip to content

Instantly share code, notes, and snippets.

View KentVu's full-sized avatar

Kiên T Vu KentVu

View GitHub Profile
@AWinterman
AWinterman / Datagate.py
Created May 30, 2012 21:01
Script to convert from csv to sqlite3
import csv
import sqlite3 as lite
import subprocess
from itertools import chain
from time import time
import sys
#import logging
#logging.basicConfig(level=logging.DEBUG)
#
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active July 24, 2024 17:56
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@JakeWharton
JakeWharton / dex.sh
Last active March 25, 2024 13:54
`classes.dex` method count helpers. Requires smali/baksmali from https://code.google.com/p/smali/ and dexdump from the build-tools in the Android SDK be on your PATH.
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
@santa4nt
santa4nt / HelloJNI.java
Last active June 2, 2024 17:19
Sample JNI/C++ HelloWorld
public class HelloJNI {
static {
System.loadLibrary("hello"); // loads libhello.so
}
private native void sayHello(String name);
public static void main(String[] args) {
new HelloJNI().sayHello("Dave");
}
@subfuzion
subfuzion / curl.md
Last active July 25, 2024 08:53
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@CodyEngel
CodyEngel / DisposableManager.java
Created April 15, 2017 00:12
A singleton wrapper for managing a CompositeDisposable.
public class DisposableManager {
private static CompositeDisposable compositeDisposable;
public static void add(Disposable disposable) {
getCompositeDisposable().add(disposable);
}
public static void dispose() {
getCompositeDisposable().dispose();
@magillus
magillus / LifecycleObservableTransformer.java
Last active March 29, 2018 05:54
Observable transformer that will act on event of the Lifecycle to auto dispose its subscriptions when the event occurs. By default ON_DESTROY
package com.example.playground;
import android.arch.lifecycle.Lifecycle;
import android.arch.lifecycle.LifecycleObserver;
import android.arch.lifecycle.OnLifecycleEvent;
import android.support.annotation.NonNull;
import android.util.Log;
import java.lang.ref.WeakReference;
import java.util.Map;
@gstraymond
gstraymond / Trie.kt
Created February 14, 2018 18:23
Kotlin Trie
package fr.gstraymond.search
data class Trie(private val char: Char,
private val indices: MutableList<Int> = mutableListOf(),
private val children: MutableList<Trie> = mutableListOf()) {
fun add(word: String,
index: Int) {
val first = word.first()
val trie = findOrCreate(first)
@bbqtd
bbqtd / macos-tmux-256color.md
Last active July 24, 2024 06:15
Installing tmux-256color for macOS

Installing tmux-256color for macOS

  • macOS 10.15.5
  • tmux 3.1b

macOS has ncurses version 5.7 which does not ship the terminfo description for tmux. There're two ways that can help you to solve this problem.

The Fast Blazing Solution

Instead of tmux-256color, use screen-256color which comes with system. Place this command into ~/.tmux.conf or ~/.config/tmux/tmux.conf(for version 3.1 and later):

@alexito4
alexito4 / Task.swift
Created October 12, 2022 21:21
SwiftUI View.task backwards compatibility
import Foundation
import SwiftUI
public extension View {
@available(iOS, obsoleted: 15.0, message: "SwiftUI.View.task is available on iOS 15.")
@_disfavoredOverload
@inlinable func task(
priority: _Concurrency.TaskPriority = .userInitiated,
@_inheritActorContext _ action: @escaping @Sendable () async -> Swift.Void
) -> some SwiftUI.View {