Skip to content

Instantly share code, notes, and snippets.

🇭🇰
Free HK

Alan Tai ayltai

🇭🇰
Free HK
Block or report user

Report or block ayltai

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ayltai
ayltai / move.scpt
Last active May 10, 2018
An AppleScript to resize and move specific application window
View move.scpt
on run argv
set theApp to item 1 of argv as string
set width to item 2 of argv as number
set height to item 3 of argv as number
set alignLeft to item 4 of argv as string
set alignTop to item 5 of argv as string
set x to 0 as number
set y to 0 as number
@ayltai
ayltai / vm_pageout.h
Created Mar 1, 2017
Extract of vm_pageout.h
View vm_pageout.h
#define VM_PAGER_DEFAULT 0x1 /* Use default pager. */
#define VM_PAGER_COMPRESSOR_NO_SWAP 0x2 /* In-core compressor only. */
#define VM_PAGER_COMPRESSOR_WITH_SWAP 0x4 /* In-core compressor + swap backend. */
#define VM_PAGER_FREEZER_DEFAULT 0x8 /* Freezer backed by default pager.*/
#define VM_PAGER_FREEZER_COMPRESSOR_NO_SWAP 0x10 /* Freezer backed by in-core compressor only i.e. frozen data remain in-core compressed.*/
#define VM_PAGER_FREEZER_COMPRESSOR_WITH_SWAP 0x20 /* Freezer backed by in-core compressor with swap support too.*/
@ayltai
ayltai / hosts.txt
Created Feb 24, 2017
The ultimate list of ad hosts (~15k hosts)
View hosts.txt
127.0.0.1 validation.sls.microsoft.com
127.0.0.1 licensing.ultraedit.com
127.0.0.1 licensing2.ultraedit.com
127.0.0.1 3dns.adobe.com
127.0.0.1 3dns-1.adobe.com
127.0.0.1 3dns-2.adobe.com
127.0.0.1 3dns-3.adobe.com
127.0.0.1 3dns-4.adobe.com
127.0.0.1 3dns-5.adobe.com
127.0.0.1 activate.adobe.com
View ResizeImageView.java
DisplayMetrics metrics = new DisplayMetrics();
((WindowManager)adContainerView.getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics);
ViewGroup.LayoutParams params = imageView.getLayoutParams();
params.width = metrics.widthPixels;
params.height = (int)(metrics.widthPixels / 1.91f + 0.5f);
imageView.setLayoutParams(params);
View SampleAdMobNativeAd.java
@Override
protected void prepare(@NonNull final NativeAppInstallAdView adView, @NonNull final NativeAppInstallAd nativeAd) {
final TextView adTitle = (TextView)adView.findViewById(R.id.ad_title);
final TextView adBody = (TextView)adView.findViewById(R.id.ad_body);
final ImageView adImage = (ImageView)adView.findViewById(R.id.ad_image);
final TextView adCallToAction = (TextView)adView.findViewById(R.id.ad_call_to_action);
adView.setHeadlineView(adTitle);
adView.setBodyView(adBody);
adView.setImageView(adImage);
View build.gradle
dependencies {
compile('com.mopub:mopub-sdk-native-static:4.12.0@aar') { transitive = true }
compile 'com.facebook.android:audience-network-sdk:4.19.0'
compile 'com.flurry.android:analytics:6.8.0'
compile 'com.flurry.android:ads:6.8.0'
compile 'com.google.android.gms:play-services-ads:10.0.1'
// Other dependencies
}
View view_content_ad.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.ads.formats.NativeContentAdView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/admob_content_ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/view_native_ad" />
</com.google.android.gms.ads.formats.NativeContentAdView>
View view_app_install_ad.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.ads.formats.NativeAppInstallAdView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/admob_app_install_ad_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/view_native_ad" />
</com.google.android.gms.ads.formats.NativeAppInstallAdView>
@ayltai
ayltai / view_native_ad_container.xml
Created Feb 12, 2017
Empty view layout for native ads
View view_native_ad_container.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/native_ad_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
View AdMobNativeAd.java
@Override
public void fetchAd() {
new AdLoader.Builder(this.getContext(), this.adUnitId)
.forAppInstallAd(AdMobNativeAd.this)
.forContentAd(AdMobNativeAd.this)
.withNativeAdOptions(this.getNativeAdOptionsBuilder().build())
.withAdListener(new AdListener() {
@Override
public void onAdOpened() {
AdMobNativeAd.this.notifyAdClicked();
You can’t perform that action at this time.