Skip to content

Instantly share code, notes, and snippets.

@Qw4z1
Qw4z1 / SampleUsageView.kt
Last active September 28, 2023 03:45
Kotlin Compose Multiplatform currently doesn't support UIViewControllers with transparent background. Instead it defaults to white background. This creates problems when stacking UIViewControllers on top of each other. Mostly created by @cyberhenoch and @JeroenFlietstra.
package components
import androidx.compose.runtime.Composable
import platform.UIKit.UIColor
@Composable
fun SampleUsageView(
content: @Composable () -> Unit
): () -> Unit {
// Wraps the composable in a UIViewController and sets the background to .clearColor.
import { Field } from "formik";
import Label from "./Label";
import PlaceholderOption from "./PlaceholderOption";
type PickerProps<K> = {
placeHolder: string;
nameInForm: string;
label: string;
data?: K[];
mapper: (item: K) => PickerOption;
func betterLabel() -> ZSWTappableLabel {
let participantsLabel:ZSWTappableLabel = ZSWTappableLabel(frame: CGRect(x: 10, y: 5, width: self.view.bounds.size.width * 0.75, height: 43))
var par2 = participants
for i in 1...6 {
par2.append(User(id: "Dummy", name: "Test User"))
}
@Qw4z1
Qw4z1 / artifacts.gradle
Last active November 4, 2015 08:55
APK file naming. Put in base directory of the project and add 'apply from: 'artifacts.gradle'' to the apps build.gradle. All credit goes to Erik Ogenvik at Jayway for his blog post http://www.jayway.com/2015/03/13/producing-better-named-android-apks-with-gradle/
android.applicationVariants.all { variant ->
def appName
//Check if an applicationName property is supplied; if not use the name of the parent project.
if (project.hasProperty("applicationName")) {
appName = applicationName
} else {
appName = parent.name
}
variant.outputs.each {output ->
### Keybase proof
I hereby claim:
* I am qw4z1 on github.
* I am qw4z1 (https://keybase.io/qw4z1) on keybase.
* I have a public key whose fingerprint is BFD0 ADDC 8937 5EF6 5784 2A28 65FD C322 4A91 8FD3
To claim this, I am signing this object:
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.*;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.util.AttributeSet;
afterEvaluate { project ->
android.applicationVariants.each { variant ->
variant.javaCompile.dependsOn stripPlayServices
}
}
task stripPlayServices << {
def playServiceRootFolder = new File(rootProject.buildDir, "intermediates/exploded-aar/com.google.android.gms/play-services/")
playServiceRootFolder.list().each { versionName ->
def versionFolder = new File(playServiceRootFolder, versionName)
@Qw4z1
Qw4z1 / gist:8c1c056860f1e0d78ee4
Created June 11, 2014 09:50
Android gitignore
# built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@Qw4z1
Qw4z1 / gist:4586204
Created January 21, 2013 13:52
Optimized ImageView
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
*
@Qw4z1
Qw4z1 / gzip compression with http
Created November 22, 2012 03:49
Enable gzip compression with HttpClient. All code from the goole IOSched app.
private static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding";
private static final String ENCODING_GZIP = "gzip";
final DefaultHttpClient client = new DefaultHttpClient(manager, parameters);
client.addRequestInterceptor(new HttpRequestInterceptor() {
public void process(HttpRequest request, HttpContext context) {
// Add header to accept gzip content
if (!request.containsHeader(HEADER_ACCEPT_ENCODING)) {
request.addHeader(HEADER_ACCEPT_ENCODING, ENCODING_GZIP);