Skip to content

Instantly share code, notes, and snippets.

View MosheBerman's full-sized avatar

Moshe MosheBerman

View GitHub Profile
@MosheBerman
MosheBerman / gist:5645752
Created May 24, 2013 18:57
forkwait main
main(int argc, char* argv[])
{
// Generate a random number between MINFORKS and MAXFORKS
unsigned int seed = generateSeed(0);
int n = rand_r(&seed) % MAXFORKS + MINFORKS;
// Time elapsed
long time = 0;
time = elapsedTime((int)time);
@MosheBerman
MosheBerman / sum4.cpp
Created April 16, 2013 04:01
An example where we return the value received by the wrapper function.
/* Prototypes */
int sum(int, int);
int wrapper(int, int);
/* Main program */
int main()
{
int x = wrapper(1,1); // We pass in the two values instead.
@MosheBerman
MosheBerman / sum3.cpp
Last active December 16, 2015 06:39
An example where we wrap a sum(int, int) call in a wrapper function.
/* Prototypes */
int sum(int, int);
void wrapper(int, int);
/* Main program */
int main()
{
wrapper(1,1); // We pass in the two values instead.
@MosheBerman
MosheBerman / sum2
Created April 16, 2013 03:50
An example where we call a wrapper function from main.
/* Prototypes */
int sum(int, int);
void wrapper();
/* Main program */
int main()
{
wrapper();
@MosheBerman
MosheBerman / sum1.cpp
Created April 16, 2013 03:46
An example where we call a function called sum() from main();
// Prototypes:
int sum(int, int);
/* Main program */
int main()
{
int z = sum(1, 1); // z will become 2 here
@MosheBerman
MosheBerman / gist:5385650
Created April 15, 2013 04:08
Calendar Touch handling
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
if ([[self headerView] pointInside:point withEvent:event])
{
return YES;
}
else if([[self table] pointInside:point withEvent:event])
{
return YES;
@MosheBerman
MosheBerman / gist:5366396
Created April 11, 2013 19:20
Animation transitions...
- (void) flipInWithCompletion:(MBTransitionCompletion)completion
{
BOOL displayingPrimary = [self isDisplayingPrimaryView];
UIView *frontView = [self frontView];
UIView *backView = [self backView];
UIView *wrapperView = [self wrapperView];
[wrapperView addSubview:frontView];
@MosheBerman
MosheBerman / gist:5259848
Created March 28, 2013 01:52
display two spheres?
void display()
{
// Clear the previous frame
glClear(GL_COLOR_BUFFER_BIT);
{
glPushMatrix();
glTranslatef(0.5, 0.5, 0);
@MosheBerman
MosheBerman / Output 2
Created December 3, 2012 04:28
Output
Stocking 150 at $1 each.
Stocking 130 at $2 each.
(lldb) c
Process 6212 resuming
(lldb) p sales
(std::__1::vector<Sale, std::__1::allocator<Sale> > &) $0 = size=2: {
(Sale) [0] = {
(int) quantity = 0
(double) pricePerUnit = 0
}
@MosheBerman
MosheBerman / Widget.cpp
Created December 3, 2012 01:59
Linked List
//
// Widget.cpp
// 3-LinkedLists
//
// Created by Moshe Berman on 12/2/12.
// Copyright (c) 2012 Moshe Berman. All rights reserved.
//
#include "Widget.h"