Skip to content

Instantly share code, notes, and snippets.

@ixig
ixig / EE Review Links
Last active June 5, 2020 21:01
EE Review Links
@ixig
ixig / OOP Design Patterns
Last active August 21, 2018 02:42
OOP Design Patterns
1. Strategy Pattern
Define a family of algorithms, encapsulate each one and make them interchangeable
Lets algorithms vary independently for clients of that class
class List {
- Sorting sortType = new DefaultSort();
==============================
+ setSortType(Sorting newSort) { sortType = newSort; }
+ sort() { sortType.sort(this); }
}
>>> Execute something on UI Thread from Non-UI Thread <<<
runOnUIThread(new Runnable() ...);
# Recall a bash history entry without invoking
###:p /* then press <UP> key */
# GCC - expand pre-processing only
gcc -E -o foo.i foo.c
# test if file or directory exists
[ -f filename ] && ... /* substitute "||" for does NOT exist */
[ -d filename ] && ...
CC=g++
CFLAGS=-c -Wall -I/usr/local/opt/openssl/include
LDFLAGS=-L/usr/local/opt/openssl/lib
LIBS=-lcrypto
EXECUTABLE1=dh_test
EXECUTABLE2=udp-send-dh
SOURCES1=dh_test.cpp dh.cpp
SOURCES2=udp-send-dh.cpp dh.cpp
# initialize new local repo
git init
# add all files in *current* directory (and below) to staging area
git add .
# commit staged changes
git commit -m "<commit_msg>"
# checkout last commit on branch 'master'
package com.gopro;
import android.os.Handler;
import android.util.Log;
import junit.framework.Assert;
interface Events {
void onTimeout();
void onX();
>>> Convert InputStream to String <<<
String text = new Scanner(inputStream).useDelimiter("\\A").next();
OR
try (java.util.Scanner s = new java.util.Scanner(inputStream)) {
return s.useDelimiter("\\A").hasNext() ? s.next() : "";
}
1. STUDIO_JDK=/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
2. <CMD> + L.Click
Navigate to Declaration/Definition
3. <OPT> + <CMD> + Left/Right
Navigate Back/Forward
4. Click on Marker in Marker Bar
Navigate to code line
java.lang.System:
.out.format(String format, Object... args)
.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
.currentTimeMillis()
java.lang.String:
.charAt(int index)
.toCharArray()
.toUpperCase()
.toLowerCase()