Skip to content

Instantly share code, notes, and snippets.

View pmark's full-sized avatar

P. Mark Anderson pmark

View GitHub Profile
@pmark
pmark / grid-surface-shader.metal
Last active December 30, 2020 14:45
Surface shader modifier: grid effect
float u = _surface.diffuseTexcoord.x;
float v = _surface.diffuseTexcoord.y;
int u100 = int(u * 100.0);
int v100 = int(v * 100.0);
if (u100 % 2 == 1 || v100 % 2 == 1) {
// do nothing
} else {
discard_fragment();

Keybase proof

I hereby claim:

  • I am pmark on github.
  • I am pmark (https://keybase.io/pmark) on keybase.
  • I have a public key whose fingerprint is 7CC0 475C 36C8 1053 9F08 8117 1BE3 1439 87A7 B197

To claim this, I am signing this object:

@pmark
pmark / gist:f59691962e7310e07676
Last active August 29, 2015 14:06
tokenize string
// [email protected] 0600646f49c0a8a05f584b5bbdff435a3ebe8900
// [email protected] 08cd3e9fff85b776622024387486160df467f2cf
require('./pii-store').tokenizeString('[email protected]', function(err, token){ console.log(err, token); });
@pmark
pmark / index.html
Last active December 31, 2015 21:09
D3 bubbles
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
margin: 0;
background: #222;
min-width: 960px;
cursor:crosshair;
}
@pmark
pmark / index.html
Last active December 31, 2015 01:49
Spiraly particles that respond to touch or mouse movement.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
margin: 0;
background: #222;
min-width: 960px;
cursor:crosshair;
}
@pmark
pmark / gist:4220147
Created December 5, 2012 22:38
Configuring a 3DAR callout view
@interface MainViewController ()
@property (nonatomic, strong) SM3DARCalloutView *calloutView;
@end
//
// This method should appear in your 3DAR delegate class.
//
- (SM3DARCalloutView*) sm3dar:(SM3DARController*)sm3dar calloutViewForPoint:(SM3DARPoint*)point
@pmark
pmark / gist:4219809
Created December 5, 2012 21:49
Make 3DAR fill the iPhone 5 screen
#define IS_WIDESCREEN ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
//
// Call this after starting the camera, which must happen after at or after viewDidAppear.
//
- (void)make3darFullscreen
{
[self.mapView.sm3dar setFrame:[UIScreen mainScreen].bounds];
[self.mapView.sm3dar.glView setFrame:[UIScreen mainScreen].bounds];
@pmark
pmark / gist:1479097
Created December 14, 2011 23:30
formattedDistanceFromCurrentLocationWithUnits
BOOL useMetricUnits = NO;
- (NSString *)formattedDistanceFromCurrentLocationWithUnits:(SM3DARPointOfInterest *)poi
{
NSString *formatted;
CGFloat distance;
if (useMetricUnits)
{
// Metric.
@pmark
pmark / gist:1372428
Created November 17, 2011 05:20
Post to Facebook wall
- (void)postMessageOnFacebook:(NSString*)message {
message = [NSString stringWithFormat:@"I just posted to %@ from %@.\n\n%@",
[AsyncEventHandler getCurrentCultName],
[AsyncEventHandler getCurrentMacro],
message];
[APP_DELEGATE.facebook requestWithGraphPath:@"me/feed"
andParams:[NSMutableDictionary dictionaryWithObjectsAndKeys:
message, @"message",
@pmark
pmark / gist:1207231
Created September 9, 2011 20:23
How to move a 3DAR POI to a new location.
//
// This functionality will be added to the 3DAR library in the future.
//
- (SM3DARPointOfInterest *) movePOI:(SM3DARPointOfInterest *)poi toLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude altitude:(CLLocationDistance)altitude
{
CLLocation *newLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
SM3DARPointOfInterest *newPOI = [[SM3DARPointOfInterest alloc] initWithLocation:newLocation