Skip to content

Instantly share code, notes, and snippets.

View b-adams's full-sized avatar

Prof. Bryant E Adams b-adams

  • Wells College
  • Aurora NY
View GitHub Profile
@b-adams
b-adams / generator.py
Created August 2, 2017 18:35
Linearizing 2-d indexing to 1-d indexing
xvals = [1,2,3]
yvals = [1,2,3,4]
for x in xvals:
for y in yvals:
# First, 0-indexing is better for the soul
i = x-1
j = y-1
# Next, the formula to linearize the 2-d indexing to 1-d indexing
x_extent = len(xvals)
k = x_extent*j + i
@b-adams
b-adams / slicing_visualizer.py
Last active January 20, 2017 14:22 — forked from anonymous/Visualize where Python slicing happens
Visualize where Python slicing happens
def show_slicing(text, start=0, stop=None, step=1):
if step<1:
print("Sorry, reverse stepping not supported in this visualization")
else:
sliced_text = text[start:stop:step]
lead_space = ' '*start+'|'
marker = '^' + (step-1)*' '
(marks, tail) = divmod(len(text)-start, step)
untruncated_markline = lead_space + marker*marks + 'x'*tail
@b-adams
b-adams / Converted_output.csv
Last active April 13, 2024 15:33
Converting SRT to XLSX
Entries Timecodes Subtitles
1 00:00:00,104 --> 00:00:02,669 Hi, I'm shell-scripting.
2 00:00:02,982 --> 00:00:04,965 I'm not sure if it would work,
but I'll try it!
3 00:00:05,085 --> 00:00:07,321 There must be a way to do it!
@b-adams
b-adams / Page110Listing1.m
Last active December 15, 2015 18:39
Sample Java -> Objective-C translation for CS132 pages 109-118
Duck* duck = [[MallardDuck alloc] init];
@b-adams
b-adams / CS345CoordinateInterface.h
Last active December 14, 2015 16:18
Interface for CS345 Pente Game's model
// CS345CoordinateInterface.h
#import <Foundation/Foundation.h>
@protocol CS345CoordinateInterface <NSObject>
@property (readonly, assign) int x;
@property (readonly, assign) int y;
-(id)initWithX:(int) initialX andY:(int) initialY;
+(id)coordinateWithX:(int) initialX andY:(int) initialY;
@end

In Sourcetree, click the "Terminal" button to open your working directory in the Terminal Type pico .gitignore Replace the line that says

xcuserdata

with

*.xcscheme

xcschememanagement.*

@b-adams
b-adams / DEAppDelegate.m
Created January 30, 2013 16:24
Crude way to tack http:// on to front of a text field, if it's not already present
#import "DEAppDelegate.h"
@implementation DEAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
}
- (IBAction)processURL:(id)sender {
@b-adams
b-adams / Calculator.h
Created January 30, 2013 02:09
Calculator (just entering numbers) class for Wells CS132
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT const char CLEAR_SCREEN_KEY; //The FOUNDATION_EXPORT part makes this truly global - available to all other files.
@interface Calculator : NSObject
@property (assign) int numberOnScreen;
-(void) clearScreen;
@b-adams
b-adams / Prog0.a.txt
Last active December 11, 2015 18:49
Wells CS132 Sp13 Program 0 sample output
2013-01-26 16:31:24.500 cs132_program_0_badams[66337:303] Hello, World!
@b-adams
b-adams / demo_Array.m
Created January 23, 2013 02:26
URL, Array, and string-input demonstrations for CS132
/**
@brief Demonstrate getting textual user input and adding it to an array, plus displaying array contents.
*/
void demo_Array(void);
void demo_Array(void)
{
//An array of "to do" items, which can be altered
NSMutableArray* todoList = nil;