Skip to content

Instantly share code, notes, and snippets.

@willyliu
willyliu / main.dart
Created December 7, 2020 04:34
Flutter countdown stateful widget
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(title: 'Countdown Timer', home: FirstRoute()));
}
class FirstRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
@willyliu
willyliu / main.dart
Last active December 7, 2020 04:57
Flutter countdown widget in StatefulBuilder. Will receive exception if user go back before countdown finished.
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(MaterialApp(title: 'Timer in StatefulBuilder', home: FirstRoute()));
}
class FirstRoute extends StatelessWidget {
@override
Widget build(BuildContext context) {
@willyliu
willyliu / gist:a720e844aecee8f6f9ff9947a1051cc8
Created September 8, 2017 10:32
How to modify module's gradle file to include kotlin file manually for android.
// for compiling kotlin files
apply plugin: 'kotlin-android'
buildscript {
repositories {
jcenter()
}
ext.kotlin_version = '1.1.4-3'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
@willyliu
willyliu / gist:3003da52d699675630b917168e0fb46c
Created September 8, 2017 10:30
How to modify gradle file to use android aar file built with kotlin
// add this into the module's build.gradle to make sure the kotlin runtime is included
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.1.4-3"
}
@willyliu
willyliu / FixJenkinsDocumentCSSProblem.md
Created August 24, 2017 04:21
Fix the problem that document artifacts created by jenkins has no css.
@willyliu
willyliu / listProvisionProfiles.sh
Created March 22, 2017 04:32
Lists provision profiles' names
#!/bin/bash
SAVEIFS=$IFS
IFS=$'\n'
path="$HOME/Library/MobileDevice/Provisioning Profiles/*.provisionprofile"
for filename in $path; do
profileName=`/usr/libexec/plistbuddy -c Print:Name /dev/stdin <<< \
\`security cms -D -i $filename\``
echo $profileName
done
IFS=$SAVEIFS
@willyliu
willyliu / android_openssl_builder.sh
Created February 14, 2017 04:04
Build openssl for android, test with openssl-1.1.0c. Based on https://gist.github.com/cogwirrel/4a733b4138d1b35d4cfe69b4df110d0b.
#!/bin/bash
USAGE=$'Usage:
./android_openssl_builder <options>
Required:
-s <openssl_directory> The top level openssl directory
-n <ndk_directory> The top level ndk directory
-o <output_directory> The directory in which you would like the builds
@willyliu
willyliu / openssl-build.sh
Last active February 14, 2017 03:54 — forked from armadsen/openssl-build.sh
A shell script to build openssl for iOS and Mac. >>>>> It currently builds: Mac (i386, x86_64) >>>>> iOS (armv7, arm64) >>>>> iOS Simulator (i386, x86_64) >>>>> Updated to work with Xcode 7 and produce bitcode enabled binaries >>>>> Minimum deployment target can be easily configured
#!/bin/bash
# This script builds the iOS and Mac openSSL libraries with Bitcode enabled
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# Peter Steinberger, PSPDFKit GmbH, @steipete.
# Doron Adler, GlideTalk, @Norod78
@willyliu
willyliu / libcurl_builder.sh
Last active February 14, 2017 04:00 — forked from cogwirrel/libcurl_builder.sh
Build curl and openssl for all android architectures
#!/bin/bash
USAGE=$'Usage:
./libcurl_builder <options>
Required:
-c <curl_directory> The top level curl directory
-s <openssl_directory> The top level openssl directory
-n <ndk_directory> The top level ndk directory
@willyliu
willyliu / NSURLSessionDelegate+IgnoreCertirficateChecking.m
Last active December 30, 2015 18:19
Ignores SSL certificate checking.
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler
{
NSURLProtectionSpace * protectionSpace = challenge.protectionSpace;
if ([protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
SecTrustRef serverTrust = protectionSpace.serverTrust;
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust: serverTrust]);
}
else {
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
}