Skip to content

Instantly share code, notes, and snippets.

View puls's full-sized avatar

Jim Puls puls

View GitHub Profile
#if DEBUG
import ApolloAPI
<%_ for (const type of types.structs.filter(type => type.accessLevel === "public")) {
const packageName = "<YOUR PACKAGE NAME HERE>"
const filterFunc = variable => {
if (!variable.isComputed) return false
if (variable.isStatic) return false
if (typeof variable.type === 'undefined') return true
return variable.type.inheritedTypes.indexOf(`${packageName}.InlineFragment`) === -1
@puls
puls / ImagePickerApp.swift
Last active November 21, 2023 17:16
Crashing image picker
//
// ImagePickerApp.swift
// ImagePickerApp
//
// Created by Jim Puls on 1/29/21.
//
import SwiftUI
// MARK: - ImagePickerApp
@puls
puls / cgfloat.m
Last active August 29, 2015 14:12
Swift CGFloat
#import <UIKit/UIKit.h>
[NSString stringWithFormat:@"%.0f", 1.23]; // @"1"
[NSString stringWithFormat:@"%.0f", (double)1.23]; // @"1"
[NSString stringWithFormat:@"%.0f", (float)1.23]; // @"1"
[NSString stringWithFormat:@"%.0f", (CGFloat)1.23]; // @"1"
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ztc-eJ-ujb">
<objects>
<viewController id="mhR-QO-pIv" sceneMemberID="viewController">
- (void)viewDidLoad;
{
[super viewDidLoad];
self.button.enabled = NO;
[self.button setTitle:@"Foo" forState:UIControlStateNormal];
}
- (IBAction)changeTitle:(id)sender;
{
[self.button setTitle:@"Bar" forState:UIControlStateNormal];
@puls
puls / gist:6288634
Last active December 21, 2015 09:59
int main(int argc, const char * argv[])
{
int array[] = {1,2,3,4,5};
printf("array[1]: %d\n", array[1]);
printf("1[array]: %d\n", 1[array]);
printf("*(array + 1): %d\n", *(array + 1));
}
@puls
puls / main.m
Created April 17, 2013 15:16
Escaping a pattern doesn't do what you want
int main(int argc, const char * argv[])
{
@autoreleasepool {
NSString *patternFromFile = @"/path/to/(something|theotherthing)";
NSRegularExpression *regex1 = [NSRegularExpression regularExpressionWithPattern:patternFromFile options:NSRegularExpressionCaseInsensitive error:nil];
NSRegularExpression *regex2 = [NSRegularExpression regularExpressionWithPattern:[NSRegularExpression escapedPatternForString:patternFromFile] options:NSRegularExpressionCaseInsensitive error:nil];
NSString *string = @"/path/to/something";
for (NSRegularExpression *regex in @[regex1, regex2]) {
NSLog(@"matches: %ld", [regex numberOfMatchesInString:string options:0 range:NSMakeRange(0, string.length)]);
}
@puls
puls / gist:2390743
Created April 15, 2012 07:37
Glob pattern for loaded languages
exports.requireable = function () {
var extensions = Object.keys(require.extensions);
return '{' + extensions.join(',') + '}';
};
dryghost:~ puls$ brew install macruby
Error: No available formula for macruby
MacRuby works better when you install their package:
http://www.macruby.org/downloads.html
Although if you prefer, there is a formula in homebrew-alt.
dryghost:~ puls$ brew install npm
Error: No available formula for npm
npm can be installed thusly by following the instructions at
dryghost:Source puls$ git clone git://github.com/pivotal/cimonitor.git pivotal_cimonitor
Cloning into pivotal_cimonitor...
remote: Counting objects: 3568, done.
remote: Compressing objects: 100% (1593/1593), done.
remote: Total 3568 (delta 2197), reused 3131 (delta 1831)
Receiving objects: 100% (3568/3568), 40.02 MiB | 427 KiB/s, done.
Resolving deltas: 100% (2197/2197), done.
dryghost:Source puls$ cd pivotal_cimonitor
dryghost:pivotal_cimonitor puls (master)$ bundle install
-bash: bundle: command not found