Skip to content

Instantly share code, notes, and snippets.

View CaptainN's full-sized avatar

Kevin Newman CaptainN

View GitHub Profile
@CaptainN
CaptainN / App.js
Created June 10, 2020 00:42
React Native Workshop
import React, { useState } from 'react';
import { StyleSheet, Text, View, Button, FlatList, CheckBox } from 'react-native';
/**
* A computer language has 3 main parts:
* 1. Syntax
* 2. A Static environment
* 3. A Dynamic environment
*
* The syntax the format of the input. The struction of the
@CaptainN
CaptainN / App.js
Last active June 10, 2020 00:45
React Native Workshop
import React, { useState } from 'react';
import { StyleSheet, Text, View, Button, FlatList, CheckBox } from 'react-native';
/**
* A computer language has 3 main parts:
* 1. Syntax
* 2. A Static environment
* 3. A Dynamic environment
*
* The syntax the format of the input. The struction of the
@CaptainN
CaptainN / App.js
Created June 17, 2020 00:54
React Native Example App.js
import React, { useState, useEffect } from 'react';
import { StyleSheet, Text, View, TextInput, Button, FlatList, Image } from 'react-native';
import { AsyncStorage } from 'react-native';
function uuidv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
@CaptainN
CaptainN / Meteor Hooks Kitchen Sink.jsx
Last active January 1, 2021 21:52
Meteor Hooks Kitchen Sink
import { useTracker } from 'meteor/react-meteor-data'
// Create a reusable subscribe hook
const usePageSubscription = (pageId) => useTracker(() => {
const subscription = Meteor.subscribe('page', pageId)
return !subscription.ready()
}, [pageId])
// Separate page hook
const usePage = (pageId) => useTracker(() => {
@CaptainN
CaptainN / Meteor Basic useTracker.jsx
Last active September 2, 2021 16:54
Meteor Basic useTracker
import { useTracker } from 'meteor/react-meteor-data'
// Hook, basic use, everything in one component
const MyPage = (pageId) => {
const { user, isLoggedIn, page } = useTracker(() => {
// The publication must also be secure
const subscription = Meteor.subscribe('page', pageId)
const page = Pages.findOne({ _id: pageId })
return {
page,
@CaptainN
CaptainN / jquery.mobile.just-touch.js
Created March 29, 2012 20:06
Just touch events for jQuery
// This is a combination of two modified files from jQuery Mobile,
// jquery.mobile.vmouse.js and jquery.mobile.event.js
// They were modified to only provide the touch event shortcuts, and
// avoid the rest of the jQuery Mobile framework.
// The normal jQuery Mobile license applies. http://jquery.org/license
//
// This plugin is an experiment for abstracting away the touch and mouse
// events so that developers don't have to worry about which method of input
// the device their document is loaded on supports.
//