Skip to content

Instantly share code, notes, and snippets.

View zwliew's full-sized avatar
😊
:D

Zhao Wei Liew zwliew

😊
:D
View GitHub Profile
@zwliew
zwliew / mempbrk.c
Created January 7, 2022 09:51
mempbrk
#include <nmmintrin.h>
#include <string.h>
#define HAVE_SSE4_2
static const char ___m128i_shift_right[31] =
{
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
@zwliew
zwliew / template.cc
Created December 28, 2019 00:21
C++ competitive programming template
#include <bits/stdc++.h>
using namespace std;
#define s32 int32_t
#define s64 int64_t
#define u32 uint32_t
#define u64 uint64_t
#define f32 float
#define f64 double
#define vi vector<s32>
class IntroductionActivityTest {
@Before
public void setUp() {
Intents.init();
}
@After
public void tearDown() {
Intents.release();
}
class IntroductionActivityTest {
// Rest of the class
@Test
public void onClickButton_showsMainActivity() {
onView(withId(R.id.single_intro_end_button)).perform(click());
intended(hasComponent(MainActivity.class.getName()));
}
}
class IntroductionActivityTest {
// Rest of the class
@Test
public void onLaunch_displaysAllViews() {
onView(withId(R.id.single_intro_text)).check(matches(isDisplayed()));
onView(withId(R.id.single_intro_end_button)).check(matches(isDisplayed()));
}
}
public class IntroductionActivityTest {
@Rule
public final ActivityScenarioRule<IntroductionActivity> scenarioRule
= new ActivityScenarioRule<>(IntroductionActivity.class);
// ...Rest of the class...
}
@zwliew
zwliew / IntroductionActivityTest.java
Created February 26, 2019 08:07
UI Testing the Get Hacking Android App
import androidx.test.espresso.intent.Intents;
import androidx.test.ext.junit.rules.ActivityScenarioRule;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@zwliew
zwliew / espresso-intro.java
Created February 26, 2019 05:16
UI Testing the Get Hacking Android App
public class GreeterTest {
@Test
public void greeterSaysHello() {
onView(withId(R.id.name_field)).perform(typeText("Steve"));
onView(withId(R.id.greet_button)).perform(click());
onView(withText("Hello Steve!")).check(matches(isDisplayed()));
}
}
@zwliew
zwliew / ui-test-dependencies.groovy
Last active February 26, 2019 05:16
UI Testing the Get Hacking Android App
dependencies {
// ...Other app dependencies...
// Tests
def espresso_version = '3.1.1'
implementation "androidx.test.espresso:espresso-idling-resource:$espresso_version"
// On-device tests
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
androidTestImplementation "androidx.test.espresso:espresso-intents:$espresso_version"
@zwliew
zwliew / lesson-1-image-classification.md
Last active January 28, 2019 14:52
fast.ai Practical Deep Learning for Coders v3 (2019) Notes

Lesson 1 - Image Classification

Looking at data

  • It pays to think creatively. Specifically, can something be modelled as an image that can be fed into a neural network for training?
  • Create a Python PoxisPath from a filename via the prefix path/.
  • Each data set should comprise a training set and a validation set. The validation loss should usually be slightly higher than the training loss.
  • The fastai library supports loading data sets into ImageDataBunch's from DataFrames (from_df), CSVs (from_csv), file name regex (from_name_re), file name functions (from_name_func), from folder names (from_folder), and from Python lists (from_lists).
  • ImageDataBunch.classes can generally be thought of as the number of labels.
  • ImageDataBunch.show_batch gives us a quick look at the data. This is useful to get a feel of the data before training the model.