Skip to content

Instantly share code, notes, and snippets.

View nuno's full-sized avatar

Nuno Costa nuno

View GitHub Profile
@nuno
nuno / machine.js
Created June 16, 2021 16:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nuno
nuno / index.html
Created April 15, 2020 12:18
Geoquerying on Firestore Geoquerying on Firestore // source https://jsbin.com/qejohos
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Geoquerying on Firestore">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script defer async src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDefA6KLchy-KFDVkbFDFCzTvWW3ywcCyE"></script>
<script src="https://www.gstatic.com/firebasejs/4.7.0/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/4.7.0/firebase-firestore.js"></script>
<title>Geoquerying on Firestore</title>
@nuno
nuno / server.ts
Created May 13, 2019 12:02 — forked from ssatz/server.ts
AngularV5 + MaterializeCss(without Jquery) support for Server Side Rendering
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
import { enableProdMode } from '@angular/core';
import { ngExpressEngine } from '@nguniversal/express-engine';
import * as express from 'express';
import { join } from 'path';
import { readFileSync } from 'fs';
const domino = require('domino');
// Faster server renders w/ Prod mode (dev mode never needed)
enableProdMode();
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule KeyboardAvoidingScrollView
* @flow
* @format
*/
'use strict';
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="UTF-8">
<title>Ionic App</title>
<meta name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
@nuno
nuno / gridItem.js
Created December 13, 2016 11:49 — forked from swennemans/gridItem.js
simple infinite scroll gridView example
var React = require('react-native');
var {
Text,
View,
StyleSheet
} = React;
var styles = StyleSheet.create({
photo: {
@nuno
nuno / app.js
Last active March 14, 2017 22:01
iOS 10: Support iPhone 7 Haptic Engine API demo - docs revision
var dataStructure = ["FEEDBACK_GENERATOR_TYPE_SELECTION", "FEEDBACK_GENERATOR_TYPE_IMPACT", "FEEDBACK_GENERATOR_TYPE_NOTIFICATION"];
var win = Ti.UI.createWindow({
backgroundColor: "#fff",
title: "iOS 10 Haptic Engine",
translucent: false
});
var nav = Ti.UI.iOS.createNavigationWindow({
window: win
});
@nuno
nuno / app.js
Last active March 14, 2017 23:04
Workaround for, textField passwordMask toggle set incorrect fontFamily and fontSize. More info: https://jira.appcelerator.org/browse/TIMOB-16100 please see the comments. Based on http://stackoverflow.com/questions/35293379/uitextfield-securetextentry-toggle-set-incorrect-font
var win = Ti.UI.createWindow();
var view = Ti.UI.createView( {
width: ( Ti.Platform.displayCaps.platformWidth - 20 ),
top: 200,
layout: 'vertical'
} );
var button = Ti.UI.createButton( {
backgroundColor: 'gray',
title: 'Pass focus',
@nuno
nuno / cache.js
Created September 18, 2016 13:33 — forked from decklord/cache.js
This file is a cache module for Appcelerator Platform, now it works just with images but can be extended to support other stuff. Currently supports n number of retries and gets the image path on a callback, so you don't need to fake a dummy imageView if you want to precache some image.
exports.image = function(url, callback, directory) {
if (directory === undefined) {
var directory = 'cachedImages';
}
var filename = Ti.Utils.md5HexDigest(url);
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, directory, filename);
@nuno
nuno / conversation.js
Created September 8, 2016 14:09
Titanium - Smoothly animating an input field along with the iOS Keyboard.
function init() {
Titanium.App.addEventListener('keyboardframechanged', $.typingArea.animateKeyboard);
}
function scrollToBottom() {
$.listView.scrollToItem(0, $.section.items.length - 1, {
animated : true
});
}