Skip to content

Instantly share code, notes, and snippets.

View ayltai's full-sized avatar

Alan Tai ayltai

View GitHub Profile
@ayltai
ayltai / forbes.greasemonkey.js
Created January 27, 2020 09:44
Forbes Anti AdBlocker
// ==UserScript==
// @name Forbes
// @namespace https://www.forbes.com/
// @description Remove anti ad-blockers on Forbes websites
// @version 1
// @include https://www.forbes.com/*
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==
@ayltai
ayltai / History|-10fa58f1|entries.json
Last active May 23, 2023 08:47
An AppleScript to resize and move specific application window
{"version":1,"resource":"file:///Users/alta/Projects/WeatherBee/babel.config.js","entries":[{"id":"NtZk.js","timestamp":1649748629169},{"id":"C0fN.js","timestamp":1649748969744}]}
@ayltai
ayltai / vm_pageout.h
Created March 1, 2017 15:25
Extract of 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 February 24, 2017 13:23
The ultimate list of ad hosts (~15k hosts)
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
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);
@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);
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
}
<?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>
<?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 February 12, 2017 10:39
Empty view layout for native ads
<?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"