Skip to content

Instantly share code, notes, and snippets.

View mschwartz's full-sized avatar

Michael Schwartz mschwartz

  • Southwestern USA
View GitHub Profile
@mschwartz
mschwartz / gist:c2c22c5bfa314748a95f4c248c38a0f9
Last active August 13, 2023 18:12
Javascript cooperative threading
# cat ./threads.js&& node ./threads.js
const WAIT_TIME = 1000;
async function sleep(ms) {
await new Promise((resolve) => setTimeout(resolve, ms))
}
async function thread(n) {
@mschwartz
mschwartz / Application.js
Created June 28, 2017 15:23
Test for deferred: false
/**
* The main application class. An instance of this class is created by app.js when it
* calls Ext.application(). This is the ideal place to handle application launch and
* initialization details.
*/
Ext.define('test.Application', {
extend: 'Ext.app.Application',
name: 'test',
/**
* The main application class. An instance of this class is created by app.js when it
* calls Ext.application(). This is the ideal place to handle application launch and
* initialization details.
*/
Ext.define('test.Application', {
extend: 'Ext.app.Application',
name: 'test',
@mschwartz
mschwartz / Application.js
Created May 7, 2017 19:30
ComboBox Test App
/**
* The main application class. An instance of this class is created by app.js when it
* calls Ext.application(). This is the ideal place to handle application launch and
* initialization details.
*/
Ext.define('test.Application', {
extend: 'Ext.app.Application',
name: 'test',
@mschwartz
mschwartz / RCTWebSocketExecutor.m
Created November 20, 2015 18:48
Fix WebSocket URL to debug on target
- (instancetype)init
{
// return [self initWithURL:[RCTConvert NSURL:@"http://localhost:8081/debugger-proxy"]];
NSString *serverIP = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"SERVER_IP"];
NSString *debugUrlString = [NSString stringWithFormat:@"http://%@:8081/debugger-proxy", serverIP];
return [self initWithURL:[RCTConvert NSURL:debugUrlString]];
}
@mschwartz
mschwartz / AppDelegate.m
Last active January 7, 2018 18:53
AppDelegate.m fixed for DEBUG, DEVICE, and PRODUCTION builds
#if DEBUG
#if TARGET_OS_SIMULATOR
#warning "DEBUG SIMULATOR"
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
#else
#warning "DEBUG DEVICE"
NSString *serverIP = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"SERVER_IP"];
NSString *jsCodeUrlString = [NSString stringWithFormat:@"http://%@:8081/index.ios.bundle?platform=ios&dev=true", serverIP];
NSString *jsBundleUrlString = [jsCodeUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
jsCodeLocation = [NSURL URLWithString:jsBundleUrlString];
@mschwartz
mschwartz / Run Script.sh
Last active July 19, 2016 20:34
"Run Script" for React Native automatic IP configuration
INFOPLIST="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
echo "writing to $INFOPLIST"
PLISTCMD="Add :SERVER_IP string $(ifconfig | grep inet\ | tail -1 | cut -d " " -f 2)"
echo -n "$INFOPLIST" | xargs -0 /usr/libexec/PlistBuddy -c "$PLISTCMD" || true
PLISTCMD="Set :SERVER_IP $(ifconfig | grep inet\ | tail -1 | cut -d " " -f 2)"
echo -n "$INFOPLIST" | xargs -0 /usr/libexec/PlistBuddy -c "$PLISTCMD" || true
NODE JS VERSION
===============
~/src/tmp  cat async-fail.js
var async = require('async'),
http = require ('http');
var array = [];
for (var i=0; i<250; i++) {
var myObject = {
"foo": true,
"author": "simon",
"env": 123
}
var myProxy = new JavaAdapter(org.mozilla.javascript.NativeObject, {
// The "start" argument is here for setters and getters living
// on a prototype, so they know what to use as "this"-object.
put: function(name, start, value) {
@mschwartz
mschwartz / gist:6405201
Last active December 22, 2015 02:39
Not shared content
Schema.add({
name: 'Content',
fields: [
{ name: 'contentId', type: 'int', autoIncrement: true, defaultValue: 0 },
{ name: 'churchId', type: 'int' },
{ name: 'seoFriendly', type: 'varchar', size: 255 },
{ name: 'title', type: 'varchar', size: 255, defaultValue: 'Untitled' },
{ name: 'description', type: 'varchar', size: 255, defaultValue: 'No description' },
{ name: 'body', type: 'longtext' }
],