Skip to content

Instantly share code, notes, and snippets.

@alexfu
alexfu / FragmentObserver.java
Last active April 6, 2021 03:26
Observer pattern for notifying Fragments of a ViewPager to update their views. This will update the current Fragment, as well as the off screen Fragments that are retained.
public class FragmentObserver extends Observable {
@Override
public void notifyObservers() {
setChanged(); // Set the changed flag to true, otherwise observers won't be notified.
super.notifyObservers();
}
}
@firoze
firoze / jenkins_android_gradle_buildNum
Last active June 13, 2021 19:14
[Android Gradle] Auto-Increment version code/name in AndroidManifest/Gradle before Jenkins Build
import java.util.regex.Pattern
def versionMajor = 1
def versionMinor = 0
def versionPatch = 0
buildscript {
repositories {
mavenCentral()
}
@mosheduminer
mosheduminer / dropzone.dart
Created December 24, 2019 12:51
Implementation of a drag-and-drop zone for flutter web. Inspired by https://gist.github.com/PlugFox/ffe83a91ce50f9c78a5b1d6674e36d1b
import 'dart:async';
import 'dart:html';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
enum _DragState {
dragging,
notDragging,
}
@Hyperparticle
Hyperparticle / config.yml
Last active November 9, 2021 09:29
CircleCI 2.0 Jekyll build and Firebase deploy
### Taken from https://github.com/Hyperparticle/hyperparticle.github.io/blob/2365749469b1eea3e8c4b18af24a4865fc426fd3/.circleci/config.yml
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
@renatoathaydes
renatoathaydes / Dockerfile
Created July 6, 2019 11:28
Minimalistic Docker image from a simple Dart application - includes only the AOT-compiled app and dartaotruntime.
FROM google/dart AS dartc
WORKDIR /app
ADD pubspec.* /app/
RUN pub get
ADD bin/ /app/bin/
ADD lib/ /app/lib/
RUN pub get --offline
RUN dart2aot /app/bin/main.dart /app/main.aot
@joshskeen
joshskeen / android state codes string array
Created November 21, 2013 18:15
android state codes string array
<string-array name="states">
<item>AL</item>
<item>AR</item>
<item>AZ</item>
<item>CA</item>
<item>CO</item>
<item>CT</item>
<item>DE</item>
<item>DC</item>
<item>FL</item>
public Bitmap blurBitmap(Bitmap bitmap){
//Let's create an empty bitmap with the same size of the bitmap we want to blur
Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
//Instantiate a new Renderscript
RenderScript rs = RenderScript.create(getApplicationContext());
//Create an Intrinsic Blur Script using the Renderscript
ScriptIntrinsicBlur blurScript = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
@bergwerf
bergwerf / fix.py
Created November 2, 2019 00:39
Attempt at Dart 2.0 Three.js interop with js_facade_gen
#!/usr/bin/env python3
'''
Get ./js_facade_gen, and ./three.js
Comment out ./three.js/src/renderers/shaders/UniformsUtils.d.ts to avoid errors
Navigate to js_facade_gen
Under Zsh, run: node index.js --base-path=../three.js --destination=../dart-threejs ../three.js/src/**/*.ts
Navigate to ../dart-threejs
Add pubspec.yaml with package:js
Run this script twice to add the needed Dart SDK imports
@escamoteur
escamoteur / nextField.dart
Created September 13, 2019 12:22
So easy is it now to implement a next field behavior for forms, meaning that the focus is moved as soon the user tabs the next button on the keyboard
class _MyHomePageState extends State<MyHomePage>
with SingleTickerProviderStateMixin {
TabController _tabController;
FocusScopeNode _node = FocusScopeNode(); /// <-----------------
@override
void initState() {
_tabController = TabController(length: 3, vsync: this);
@moneal
moneal / firebase_pre-request_script.js
Created August 23, 2017 02:21
Postman pre-request script to create a Firebase authentication JWT header.
/**
* This script expects the global variables 'refresh_token' and 'firebase_api_key' to be set. 'firebase_api_key' can be found
* in the Firebase console under project settings then 'Web API Key'.
* 'refresh_token' as to be gathered from watching the network requests to https://securetoken.googleapis.com/v1/token from
* your Firebase app, look for the formdata values
*
* If all the data is found it makes a request to get a new token and sets a 'auth_jwt' environment variable and updates the
* global 'refresh_token'.
*
* Requests that need authentication should have a header with a key of 'Authentication' and value of '{{auth_jwt}}'