Skip to content

Instantly share code, notes, and snippets.

View joseph-montanez's full-sized avatar

Joseph Montanez joseph-montanez

View GitHub Profile
@joseph-montanez
joseph-montanez / NATIVESCRIPT_TIPS_TRICKS.md
Last active June 11, 2020 01:56
NativeScript Tips & Tricks

NativeScript Tips & Tricks

General

  • A <div> is the simular to <StackLayout>
  • Design Limits - Don't go in thinking every Native component is super configurable. They are not, either limit yourself to whats possible or fallback to using basic layouts / components. For example tabs on iOS are always at the bottom, cannot change it unless you do iOS specific JavaScript. Also being able to style the text color, tab color, active tab color, or borders may not be possible, depending on iOS or Android. You can go deep down into the rabbit hole and more times than not, it faster to program your own component based of simple native components.
  • Live Reload is basic at best, its better than nothing but the bigger issue is running multiple emulators at once the feature reloads one emulator at a time and if your doing JavaScript or TypeScript changes, then the reload time is too much. They have plans to improve this. Also on Windows there are live reload issues, not reloading, forcing you to stop
@joseph-montanez
joseph-montanez / main-page.rb
Created February 22, 2017 17:10
Unable to export Opal code as a node module
require 'native'
$$[:exports] = {
:pageLoaded => 123
}
@joseph-montanez
joseph-montanez / tilted-column-header.fo
Created January 7, 2017 08:52
How to add tilted header columns to Apache FOP 2.1
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
<fo:layout-master-set>
<fo:simple-page-master master-name="first"
margin-right="1.5cm"
margin-left="1.5cm"
margin-bottom="2cm"
margin-top="1cm"
page-width="21cm"
<?php
class Validator extends \Valitron\Validator {
public $default_require_message = 'Please enter the {field}';
public function mapRules($rules) {
//-- Map rules to \Valitron\Validator type of input
foreach ($rules as $field => $field_config) {
if (isset($field_config['rules']) && is_array($field_config)) {
$required = false;
@joseph-montanez
joseph-montanez / forms.py
Created September 1, 2016 11:11
How to set email as required, if from a model?
from django.contrib.auth.models import User
from django import forms
from django.core.exceptions import ValidationError
class UserForm(forms.ModelForm):
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
model = User
@joseph-montanez
joseph-montanez / checkboxfield.html
Last active July 26, 2016 09:48
How to sync data outside a riot component - https://youtu.be/QJPCsydn2Vo
<checkboxfield>
<label><input type="checkbox" name="{ name }" checked="{ checked }" value="">{ label }</label>
<br>
<script type="text/javascript">
var self = this;
this.name = opts.name || '';
this.label = opts.label || '';
this.checked = opts.checked || '';
</script>
@joseph-montanez
joseph-montanez / index.html
Created July 23, 2016 09:20
Riot Routing - Part 1
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="//cdn.muicss.com/mui-latest/css/mui.min.css" rel="stylesheet" type="text/css" />
<style>
/** Body CSS */ html, body { height: 100%; } html, body, input, textarea, buttons { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.004); } /** Sidebar CSS */ #sidebar { background-color: #E57373; padding: 15px; } #sidebar a:link, #sidebar a:visited { color: #fff } @media (min-width: 768px) { #sidebar { position: fixed; top: 0; bottom: 0; width: 180px; height: 100%; padding-top: 30px; } } /** Content CSS */ @media (min-width: 768px) { #content { margin-left: 180px; } }
</style>
@joseph-montanez
joseph-montanez / checkboxfield.html
Created July 21, 2016 19:46
RiotJS 04 - How To Share Data Between Components
<checkboxfield>
<label><input type="checkbox" name="{ name }" checked="{ checked }" value="">{ label }</label>
<br>
<script type="text/javascript">
this.name = opts.name || '';
this.label = opts.label || '';
this.checked = opts.checked || '';
</script>
</checkboxfield>
{"bug_type":"109","app_version":"","timestamp":"2016-03-29 14:31:21.21 -0700","os_version":"iPhone OS 9.3 (13E233)","slice_uuid":"76f0f5b5-69e2-3b33-b575-9390ee886c30","build_version":"","is_first_party":true,"share_with_app_devs":false,"name":"useractivityd","app_name":"useractivityd"}
Incident Identifier: 27AFEBB0-E81C-4B32-B033-CB6B369A3CEA
CrashReporter Key: 6620484fba67b09a99486f17d5088dd9dab46f90
Hardware Model: iPhone7,1
Process: useractivityd [3369]
Path: /System/Library/PrivateFrameworks/UserActivity.framework/Agents/useractivityd
Identifier: useractivityd
Version: ???
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
var zoomInOutComp = node.addComponent({
onUpdate: function (time) {
// console.trace();
if (_SceneTwo.paused) {
//-- The scene us paused
trans.pause();
} else {
//-- The scene is not pause
if (trans.isPaused()) {
//-- the scene was unpaused, so we should