Skip to content

Instantly share code, notes, and snippets.

View yccheok's full-sized avatar

Yan Cheng Cheok yccheok

View GitHub Profile
{"earnings":["XOM","TWX","RDS-B","PG","RDS-A","MCO","FB","ISRG","WMT","SAN","BA","MDLZ","BABA","JNJ","GOOGL","EXPE","DPZ","BP","PCLN","WFC","IBM","SBUX","MSFT","SPGI","CMG","GOOG","GSK","NVDA","AMZN","KO","AAPL","BRK-B","DIS","MCD","MMM"],"insider_transactions":["XOM","TWX","RDS-B","PG","RDS-A","MCO","FB","ISRG","WMT","SAN","BA","MDLZ","BABA","JNJ","GOOGL","EXPE","DPZ","BP","PCLN","WFC","IBM","SBUX","MSFT","SPGI","CMG","GOOG","GSK","NVDA","AMZN","KO","AAPL","BRK-B","DIS","MCD","MMM"],"stock_prices":[{"code":"SBUX","fall_below":52.58,"rise_above":null},{"code":"NVDA","fall_below":165.32,"rise_above":null},{"code":"BRK-B","fall_below":160.0,"rise_above":null},{"code":"GOOGL","fall_below":950.0,"rise_above":null},{"code":"SAN","fall_below":null,"rise_above":7.0}],"token":"faIwbBfg5LY:APA91bGeWu3V4bUZk2D8KSW9k_pKl7QMKOXKKbBwwTEBx2WpEDMxjaO4pxeaTR0NGOYx-thOGW9riJfc14m0bb8ObLD0BeWkkrLroUIjoyfVOdWBBMeQK88eo6Dw58XuhFjY5GndxgLu"}
public static void delete(SQLiteOpenHelper helper, Set<String> codes) {
if (codes.isEmpty()) {
return;
}
final String selection = COLUMN_CODE + " in (" + new String(new char[codes.size()-1]).replace("\0", "?,") + "?)";
SQLiteDatabase writableDatabase = helper.getWritableDatabase();
try {
writableDatabase.delete(getTableName(), selection, codes.toArray(new String[codes.size()]));
/*
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
<FrameLayout
android:id="@+id/color_frame_layout"
android:clickable="true"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true">
public class NoteViewModel extends ViewModel {
private LiveData<List<Note>> notesLiveData;
private LiveData<List<Note>> trashedNotesLiveData;
private Note newNote;
public NoteViewModel() {
init();
}
public class SyncWorker extends Worker {
private static final Object object = new Object();
@NonNull
@Override
public WorkerResult doWork() {
synchronized (object) {
return _doWork();
}
}
/**
* Performs close operation on Closeable stream, without the need of
* writing cumbersome try...catch block.
*
* @param closeable The closeable stream.
*/
public static void close(Closeable closeable) {
// Instead of returning boolean, we will just simply swallow any
// exception silently. This is because this method will usually be
// invoked within finally block. If we are having control statement
>>> d = datetime.datetime.utcfromtimestamp(1535500800)
>>> time.mktime(d.timetuple())
1535500800.0
>>> kl_tz = timezone('Asia/Kuala_Lumpur')
>>> dd = d.astimezone(kl_tz)
>>> time.mktime(dd.timetuple())
1535529600.0
>>> dd.hour
8
private static String createNotificationChannel() {
final String default_notification_channel_id = getNotificationChannelId();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return default_notification_channel_id;
}
WeNoteApplication weNoteApplication = WeNoteApplication.instance();
NotificationManager notificationManager =
public static <T> void ready(LiveData<T> liveData, LifecycleOwner lifecycleOwner, Callable<T> callable) {
T t = liveData.getValue();
if (t != null) {
callable.call(t);
return;
}
liveData.observe(lifecycleOwner, new Observer<T>() {
@Override
public void onChanged(@Nullable T t) {