Skip to content

Instantly share code, notes, and snippets.

View mschwartz's full-sized avatar

Michael Schwartz mschwartz

  • Southwestern USA
View GitHub Profile
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++) {
@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
@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 / 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 / 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',
/**
* 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 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',
@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) {