Skip to content

Instantly share code, notes, and snippets.

View trevorwang's full-sized avatar
:octocat:
Focusing

Trevor Wang trevorwang

:octocat:
Focusing
View GitHub Profile
@sjindel-google
sjindel-google / BUILDSTEPS
Last active May 19, 2023 04:46
Passing strings between Go and Dart (via FFI)
go build -o godart.so -buildmode=c-shared
dart godart.dart
import 'dart:math' show max;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:webview_flutter/webview_flutter.dart';
class ExpandableWebView extends StatefulWidget {
final String url;
final EdgeInsets padding;
@ponnamkarthik
ponnamkarthik / auto_resize_webview.dart
Created June 5, 2019 04:07
Flutter auto resize webview based on its content
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@AndiMiko
AndiMiko / migrateAndroidX.py
Created February 8, 2019 02:16
Replaces the pairs in androidx-class-mapping.csv (get it here: https://developer.android.com/jetpack/androidx/migrate) to migrate Android support to AndroidX
import glob
import csv
dictCSV = "C:/path/to/androidx-class-mapping.csv"
projectPath = "C:/path/to/project/src/"
def replace_all(text, dic):
for i, j in dic.items():
text = text.replace(i, j)
return text
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
import 'dart:async';
import 'package:simple_auth/simple_auth.dart';
import "package:http/http.dart" as http;
import 'dart:convert' as convert;
enum AzureADEasyAuthType { aad, microsoftAccount, facebook, google, twitter }
class AzureADEasyAuthApi extends OAuthApi {
String siteUrl;
AzureADEasyAuthType authType;
import 'package:flutter/material.dart';
import 'dart:math' as math;
import 'dart:async';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
@xynova
xynova / openssl-create-CA.sh
Last active July 19, 2018 15:31
Create Root CA certs with openssl
# Create the Root CA private key
## ref> https://www.openssl.org/docs/manmaster/apps/genrsa.html
openssl genrsa -out myRootCA.key 4096
# Generate the Root CA certificate signed with the private key
## ref> https://www.openssl.org/docs/manmaster/apps/req.html
openssl req -x509 -new -nodes -key myRootCA.key -days 3650 -out myRootCA.pem
# Country Name (2 letter code) [AU]:AU
# State or Province Name (full name) [Some-State]:NSW
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active June 17, 2024 15:05
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@benvium
benvium / retrofit-custom-error-handling.java
Created August 29, 2014 19:45
Fairly simply Retrofit custom error handling example. Is set up so that you don't need to do much work in the 'failure' handler of a retrofit call to get the user-visible error message to show. Works on all endpoints. There's lots of exception handling as our server folks like to keep us on our toes by sending all kinds of random stuff..!
// on error the server sends JSON
/*
{ "error": { "data": { "message":"A thing went wrong" } } }
*/
// create model classes..
public class ErrorResponse {
Error error;