Linear congruential generator

Screen Shot 2014-10-25 at 12.57.39 PM

 

C

#include 
 
/* always assuming int is at least 32 bits */
int rand();
int rseed = 0;
 
inline void srand(int x)
{
	rseed = x;
}
 
#ifndef MS_RAND
#define RAND_MAX ((1U << 31) - 1)
 
inline int rand()
{
	return rseed = (rseed * 1103515245 + 12345) & RAND_MAX;
}
 
#else /* MS rand */
 
#define RAND_MAX_32 ((1U << 31) - 1)
#define RAND_MAX ((1U << 15) - 1)
 
inline int rand()
{
	return (rseed = (rseed * 214013 + 2531011) & RAND_MAX_32) >> 16;
}
 
#endif/* MS_RAND */
 
int main()
{
	int i;
	printf("rand max is %d\n", RAND_MAX);
 
	for (i = 0; i < 100; i++)
		printf("%d\n", rand());
 
	return 0;
}

C++

#include 
 
//--------------------------------------------------------------------------------------------------
using namespace std;
 
//--------------------------------------------------------------------------------------------------
class mRND
{
public:
    void seed( unsigned int s ) { _seed = s; }
 
protected:
    mRND() : _seed( 0 ), _a( 0 ), _c( 0 ), _m( 2147483648 ) {}
    int rnd() { return( _seed = ( _a * _seed + _c ) % _m ); }
 
    int _a, _c;
    unsigned int _m, _seed;
};
//--------------------------------------------------------------------------------------------------
class MS_RND : public mRND
{
public:
    MS_RND()  { _a = 214013; _c = 2531011; }
    int rnd() { return mRND::rnd() >> 16; }
};
//--------------------------------------------------------------------------------------------------
class BSD_RND : public mRND
{
public:
    BSD_RND() { _a = 1103515245; _c = 12345; }
    int rnd() { return mRND::rnd(); }
};
//--------------------------------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
    BSD_RND bsd_rnd;
    MS_RND ms_rnd;
 
    cout << "MS RAND:" << endl << "========" << endl;
    for( int x = 0; x < 10; x++ )
	cout << ms_rnd.rnd() << endl;
 
    cout << endl  << "BSD RAND:" << endl << "=========" << endl;
    for( int x = 0; x < 10; x++ )
	cout << bsd_rnd.rnd() << endl;
 
    cout << endl << endl;
    system( "pause" );
    return 0;
}

Output
MS RAND:
========
38
7719
21238
2437
8855
11797
8365
32285
10450
30612

BSD RAND:
=========
12345
1406932606
654583775
1449466924
229283573
1109335178
1051550459
1293799192
794471793
551188310

UNIX Shell

#! /bin/bash
 
function BSD() {
  SEED=$(((1103515245 * $SEED + 12345) % 2**31))
  echo "  $SEED"
}
 
function MS() {
  SEED=$(((214013 * $SEED + 2531011) % 2**31))
  echo "  $(($SEED / 2**16))"
}
 
function output() {
  SEED=0
  echo "$1"
 
  for i in {1..10}; do
    eval "$1"
  done
 
  echo ""
}

BSD
12345
1406932606
654583775
1449466924
229283573
1109335178
1051550459
1293799192
794471793
551188310

MS
38
7719
21238
2437
8855
11797
8365
32285
10450
30612

Gallbladder removal

Screen Shot 2014-10-25 at 12.23.16 PM

 

Cholecystectomy (koh-luh-sis-TEK-tuh-me) is a surgical procedure to remove your gallbladder — a pear-shaped organ that sits just below your liver on the upper right side of your abdomen. Your gallbladder collects and stores bile — a digestive fluid produced in your liver.

Cholecystectomy is most commonly performed by inserting a tiny video camera and special surgical tools through four small incisions to see inside your abdomen and remove the gallbladder. Doctors call this laparoscopic cholecystectomy. In some cases, one large incision may be used to remove the gallbladder. This is called an open cholecystectomy.

Lejos server at PHS

http://hs-242-lejos.internal/

To setup LeJOS on your computer, open terminal and enter the following command:

curl -s http://hs-242-lejos.internal/setup.sh | bash

LeJOS API Documentation in Java 7 Javadoc Format

http://hs-242-lejos.internal/api/
LeJOS Server Extension for BlueJ

(This is included in the setup script) http://hs-242-lejos.internal/bluejos.jar
Source:
git clone http://hs-242-lejos.internal/bluejos/

*********** Previous **********

 

Important to know: 10.30.10.94/setup.sh | bash

Screen Shot 2014-10-24 at 4.22.42 PM

 

 

Terminal:
hs-242-imac-t:~ userblah$ curl -s http://10.30.10.94/setup.sh | bash

smb://lejos@10.30.10.94

 

This installs the lejos files
create a java file in a folder: Lejos, get to it and

Lejos            ReadOutLoud eText    teachers1415
Lessons            Rosters            workspace
hs-242-imac-t:Documents userblah$ cd lejos
hs-242-imac-t:lejos userblah$ ls
MotorTutor1.class    MotorTutor1.java
hs-242-imac-t:lejos userblah$ nxjc MotorTutor1.java
hs-242-imac-t:lejos userblah$ nxjlink MotorTutor1
MotorTutor1.class                             100%  703     0.7KB/s   00:00
bring brick to pc, connect, search, and upload MotorTutor1