Skip to content

Instantly share code, notes, and snippets.

var x = 3;
var y = 10;
var z = 100;
if (x != 3)
y = 30;
z = 50;
console.log(x); // 3
console.log(y); // 10 (not changed)
console.log(z); // 50 (changed!!!)
@chartsai
chartsai / gist:d359faf8ab065b4d7b291ce2d59e15c8
Created April 6, 2018 20:43
sealed doesn't work with reified QQ
package ninenine
sealed class NineNine {
abstract fun print99(formatter: String)
}
class Table(internal val width: Int, internal val height: Int, private val sections: Int = if (width >= 6) 2 else 1) : NineNine() {
private val lists = IntRange(1, width).map { Sheet(it, height) }.toList()
override fun print99(formatter: String) {
@chartsai
chartsai / NineNine.kt
Last active April 6, 2018 23:13
OO NineNine
package ninenine
interface NineNine {
fun print99(formatter: String)
}
class Table(internal val width: Int, internal val height: Int, private val sections: Int = if (width >= 6) 2 else 1) : NineNine {
private val lists = IntRange(1, width).map { Sheet(it, height) }.toList()
override fun print99(formatter: String) {
set-option -g default-shell /bin/zsh
set-option -g history-limit 30000
set -g mouse on
unbind-key %
unbind-key '"'
unbind-key c
bind-key - split-window -v -c "#{pane_current_path}"
public static void main(String[] args) {
String a = "Charlie123";
StringBuilder sb = new StringBuilder();
for (char c : a.toCharArray()) {
if ('a' <= c && c <= 'z') {
sb.append(String.valueOf(c).toUpperCase());
} else if ('A' <= c && c <= 'Z') {
sb.append(String.valueOf(c).toLowerCase());
} else {
sb.append(c);
# Basic Shell cmd:
ctrl + r
ctrl + a / ctrl + e
ctrl + c
ctrl + w
ctrl + p / ctrl + n
tab-tab
# Useful tool
grep
package idv.chatea.calendar;
import android.Manifest;
import android.content.ContentResolver;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.CalendarContract.Calendars;
import android.provider.CalendarContract.Events;
public class MyComparator implement Comparator<String> {
@Override
public int compare(String left, String right) {
return left.length() - right.length();
}
}
package com.datstudio.testproject;
import android.app.ActionBar;
import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v13.app.FragmentPagerAdapter;
@chartsai
chartsai / Main.java
Last active September 21, 2015 10:39
The example of mutable data issue
public class Main {
public static void main(String[] args) {
String name = "Charlie";
int money = 100;
int[] coordinate = {0, 0};
UserData data = new UserData();
data.name = name;
data.money = money;