text:
#include "mpg123lib_intern.h"

#include <sys/stat.h>
#include <fcntl.h>

#include "getbits.h"

#if defined (WANT_WIN32_SOCKETS)
#include <winsock2.h>
#include <ws2tcpip.h>
#endif

/* a limit for number of frames in a track; beyond that unsigned long may not be enough to hold byte addresses */
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#ifndef ULONG_MAX
/* hm, is this portable across preprocessors? */
#define ULONG_MAX ((unsigned long)-1)
#endif
#define TRACK_MAX_FRAMES ULONG_MAX/4/1152

#include "debug.h"

#define bsbufid(fr) (fr)->bsbuf==(fr)->bsspace[0] ? 0 : ((fr)->bsbuf==fr->bsspace[1] ? 1 : ( (fr)->bsbuf==(fr)->bsspace[0]+512 ? 2 : ((fr)->bsbuf==fr->bsspace[1]+512 ? 3 : -1) ) )

/*
	AAAAAAAA AAABBCCD EEEEFFGH IIJJKLMM
	A: sync
	B: mpeg version
	C: layer
	D: CRC
	E: bitrate
	F:sampling rate
	G: padding
	H: private
	I: channel mode
	J: mode ext
	K: copyright
	L: original
	M: emphasis

	old compare mask 0xfffffd00:
	11111111 11111111 11111101 00000000

	means: everything must match excluding padding and channel mode, ext mode, ...
	But a vbr stream's headers will differ in bitrate!
	We are already strict in allowing only frames of same type in stream, we should at least watch out for VBR while being strict.

	So a better mask is:
	11111111 11111111 00001101 00000000

	Even more, I'll allow varying crc bit.
	11111111 11111110 00001101 00000000

	(still unsure about this private bit)
*/
#define HDRCMPMASK 0xfffe0d00
#define HDRSAMPMASK 0xc00 /* 1100 00000000, FF bits (sample rate) */

/* bitrates for [mpeg1/2][layer] */
static const int tabsel_123[2][3][16] =
{
	{
		{0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
		{0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
		{0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,}
	},
	{
		{0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
		{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
		{0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,}
	}
};

static const long freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 };

static int decode_header(mpg123_handle *fr,unsigned long newhead);

/* These two are to be replaced by one function that gives all the frame parameters (for outsiders).*/

int frame_bitrate(mpg123_handle *fr)
{
	return tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index];
}

long frame_freq(mpg123_handle *fr)
{
	return freqs[fr->sampling_frequency];
}

#define free_format_header(head) ( ((head & 0xffe00000) == 0xffe00000) && ((head>>17)&3) && (((head>>12)&0xf) == 0x0) && (((head>>10)&0x3) != 0x3 ))

/* compiler is smart enought to inline this one or should I really do it as macro...? */
static int head_check(unsigned long head)
{
	if
	(
		/* first 11 bits are set to 1 for frame sync */
		((head & 0xffe00000) != 0xffe00000)
		||
		/* layer: 01,10,11 is 1,2,3; 00 is reserved */
		(!((head>>17)&3))
		||
		/* 1111 means bad bitrate */
		(((head>>12)&0xf) == 0xf)
		||
		/* sampling freq: 11 is reserved */
		(((head>>10)&0x3) == 0x3 )
		/* here used to be a mpeg 2.5 check... re-enabled 2.5 decoding due to lack of evidence that it is really not good */
	)
	{
		return FALSE;
	}
	/* if no check failed, the header is valid (hopefully)*/
	else
	{
		return TRUE;
	}
}

static int check_lame_tag(mpg123_handle *fr)
{
	/*
		going to look for Xing or Info at some position after the header
		                                   MPEG 1  MPEG 2/2.5 (LSF)
		Stereo, Joint Stereo, Dual Channel  32      17
		Mono                                17       9

		Also, how to avoid false positives? I guess I should interpret more of the header to rule that out(?).
		I hope that ensuring all zeros until tag start is enough.
	*/
	int lame_offset = (fr->stereo == 2) ? (fr->lsf ? 17 : 32 ) : (fr->lsf ? 9 : 17);
	/* At least skip the decoder delay. */
#ifdef GAPLESS
	if(fr->p.flags & MPG123_GAPLESS)
	{
		if(fr->begin_s == 0) frame_gapless_init(fr, GAPLESS_DELAY, 0);
	}
#endif

	if(fr->framesize >= 120+lame_offset) /* traditional Xing header is 120 bytes */
	{
		int i;
		int lame_type = 0;
		debug("do we have lame tag?");
		/* only search for tag when all zero before it (apart from checksum) */
		for(i=2; i < lame_offset; ++i) if(fr->bsbuf[i] != 0) break;
		if(i == lame_offset)
		{
			debug("possibly...");
			if
			(
					   (fr->bsbuf[lame_offset] == 'I')
				&& (fr->bsbuf[lame_offset+1] == 'n')
				&& (fr->bsbuf[lame_offset+2] == 'f')
				&& (fr->bsbuf[lame_offset+3] == 'o')
			)
			{
				lame_type = 1; /* We still have to see what there is */
			}
			else if
			(
					   (fr->bsbuf[lame_offset] == 'X')
				&& (fr->bsbuf[lame_offset+1] == 'i')
				&& (fr->bsbuf[lame_offset+2] == 'n')
				&& (fr->bsbuf[lame_offset+3] == 'g')
			)
			{
				lame_type = 2;
				fr->vbr = MPG123_VBR; /* Xing header means always VBR */
			}
			if(lame_type)
			{
				unsigned long xing_flags;

				/* we have one of these headers... */
				if(VERBOSE2) fprintf(stderr, "Note: Xing/Lame/Info header detected\n");
				/* now interpret the Xing part, I have 120 bytes total for sure */
				/* there are 4 bytes for flags, but only the last byte contains known ones */
				lame_offset += 4; /* now first byte after Xing/Name */
				/* 4 bytes dword for flags */
				#define make_long(a, o) ((((unsigned long) a[o]) << 24) | (((unsigned long) a[o+1]) << 16) | (((unsigned long) a[o+2]) << 8) | ((unsigned long) a[o+3]))
				/* 16 bit */
				#define make_short(a,o) ((((unsigned short) a[o]) << 8) | ((unsigned short) a[o+1]))
				xing_flags = make_long(fr->bsbuf, lame_offset);
				lame_offset += 4;
				debug1("Xing: flags 0x%08lx", xing_flags);
				if(xing_flags & 1) /* frames */
				{
					if(fr->p.flags & MPG123_IGNORE_STREAMLENGTH)
					{
						if(VERBOSE3)
						fprintf(stderr, "Note: Ignoring Xing frames because of MPG123_IGNORE_STREAMLENGTH\n");
					}
					else
					{
						/*
							In theory, one should use that value for skipping...
							When I know the exact number of samples I could simply count in flush_output,
							but that's problematic with seeking and such.
							I still miss the real solution for detecting the end.
						*/
						fr->track_frames = (off_t) make_long(fr->bsbuf, lame_offset);
						if(fr->track_frames > TRACK_MAX_FRAMES) fr->track_frames = 0; /* endless stream? */
						#ifdef GAPLESS
						/* if no further info there, remove/add at least the decoder delay */
						if(fr->p.flags & MPG123_GAPLESS)
						{
							off_t length = fr->track_frames * spf(fr);
							if(length > 1)
							frame_gapless_init(fr, GAPLESS_DELAY, length+GAPLESS_DELAY);
						}
						#endif
						if(VERBOSE3) fprintf(stderr, "Note: Xing: %lu frames\n", (long unsigned)fr->track_frames);
					}

					lame_offset += 4;
				}
				if(xing_flags & 0x2) /* bytes */
				{
					if(fr->p.flags & MPG123_IGNORE_STREAMLENGTH)
					{
						if(VERBOSE3)
						fprintf(stderr, "Note: Ignoring Xing bytes because of MPG123_IGNORE_STREAMLENGTH\n");
					}
					else
					{
						unsigned long xing_bytes = make_long(fr->bsbuf, lame_offset);					/* We assume that this is the _total_ size of the file, including Xing frame ... and ID3 frames...
						   It's not that clearly documented... */
						if(fr->rdat.filelen < 1)
						fr->rdat.filelen = (off_t) xing_bytes; /* One could start caring for overflow here. */
						else
						{
							if((off_t) xing_bytes != fr->rdat.filelen && NOQUIET)
							{
								double diff = 1.0/fr->rdat.filelen * (fr->rdat.filelen - (off_t)xing_bytes);
								if(diff < 0.) diff = -diff;

								if(VERBOSE3)
								fprintf(stderr, "Note: Xing stream size %lu differs by %f%% from determined/given file size!\n", xing_bytes, diff);

								if(diff > 1.)
								fprintf(stderr, "Warning: Xing stream size off by more than 1%%, fuzzy seeking may be even more fuzzy than by design!\n");
							}
						}

						if(VERBOSE3)
						fprintf(stderr, "Note: Xing: %lu bytes\n", (long unsigned)xing_bytes);
					}

					lame_offset += 4;
				}
				if(xing_flags & 0x4) /* TOC */
				{
					frame_fill_toc(fr, fr->bsbuf+lame_offset);
					lame_offset += 100; /* just skip */
				}
				if(xing_flags & 0x8) /* VBR quality */
				{
					if(VERBOSE3)
					{
						unsigned long xing_quality = make_long(fr->bsbuf, lame_offset);
						fprintf(stderr, "Note: Xing: quality = %lu\n", (long unsigned)xing_quality);
					}
					lame_offset += 4;
				}
				/* I guess that either 0 or LAME extra data follows */
				/* there may this crc16 be floating around... (?) */
				if(fr->bsbuf[lame_offset] != 0)
				{
					unsigned char lame_vbr;
					float replay_gain[2] = {0,0};
					float peak = 0;
					float gain_offset = 0; /* going to be +6 for old lame that used 83dB */
					char nb[10];
					memcpy(nb, fr->bsbuf+lame_offset, 9);
					nb[9] = 0;
					if(VERBOSE3) fprintf(stderr, "Note: Info: Encoder: %s\n", nb);
					if(!strncmp("LAME", nb, 4))
					{
						gain_offset = 6;
						debug("TODO: finish lame detetcion...");
					}
					lame_offset += 9;
					/* the 4 big bits are tag revision, the small bits vbr method */
					lame_vbr = fr->bsbuf[lame_offset] & 15;
					if(VERBOSE3)
					{
						fprintf(stderr, "Note: Info: rev %u\n", fr->bsbuf[lame_offset] >> 4);
						fprintf(stderr, "Note: Info: vbr mode %u\n", lame_vbr);
					}
					lame_offset += 1;
					switch(lame_vbr)
					{
						/* from rev1 proposal... not sure if all good in practice */
						case 1:
						case 8: fr->vbr = MPG123_CBR; break;
						case 2:
						case 9: fr->vbr = MPG123_ABR; break;
						default: fr->vbr = MPG123_VBR; /* 00==unknown is taken as VBR */
					}
					/* skipping: lowpass filter value */
					lame_offset += 1;
					/* replaygain */
					/* 32bit float: peak amplitude -- why did I parse it as int before??*/
					/* Ah, yes, lame seems to store it as int since some day in 2003; I've only seen zeros anyway until now, bah! */
					if
					(
							 (fr->bsbuf[lame_offset] != 0)
						|| (fr->bsbuf[lame_offset+1] != 0)
						|| (fr->bsbuf[lame_offset+2] != 0)
						|| (fr->bsbuf[lame_offset+3] != 0)
					)
					{
						debug("Wow! Is there _really_ a non-zero peak value? Now is it stored as float or int - how should I know?");
						/* byte*peak_bytes = (byte*) &peak;
						... endianess ... just copy bytes to avoid floating point operation on unaligned memory?
						peak_bytes[0] = ...
						peak = *(float*) (fr->bsbuf+lame_offset); */
					}
					if(VERBOSE3) fprintf(stderr, "Note: Info: peak = %f (I won't use this)\n", peak);
					peak = 0; /* until better times arrived */
					lame_offset += 4;
					/*
						ReplayGain values - lame only writes radio mode gain...
						16bit gain, 3 bits name, 3 bits originator, sign (1=-, 0=+), dB value*10 in 9 bits (fixed point)
						ignore the setting if name or originator == 000!
						radio 0 0 1 0 1 1 1 0 0 1 1 1 1 1 0 1
						audiophile 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 0
					*/

					for(i =0; i < 2; ++i)
					{
						unsigned char origin = (fr->bsbuf[lame_offset] >> 2) & 0x7; /* the 3 bits after that... */
						if(origin != 0)
						{
							unsigned char gt = fr->bsbuf[lame_offset] >> 5; /* only first 3 bits */
							if(gt == 1) gt = 0; /* radio */
							else if(gt == 2) gt = 1; /* audiophile */
							else continue;
							/* get the 9 bits into a number, divide by 10, multiply sign... happy bit banging */
							replay_gain[0] = (float) ((fr->bsbuf[lame_offset] & 0x2) ? -0.1 : 0.1) * (make_short(fr->bsbuf, lame_offset) & 0x1f);
						}
						lame_offset += 2;
					}
					if(VERBOSE3)
					{
						fprintf(stderr, "Note: Info: Radio Gain = %03.1fdB\n", replay_gain[0]);
						fprintf(stderr, "Note: Info: Audiophile Gain = %03.1fdB\n", replay_gain[1]);
					}
					for(i=0; i < 2; ++i)
					{
						if(fr->rva.level[i] <= 0)
						{
							fr->rva.peak[i] = 0; /* at some time the parsed peak should be used */
							fr->rva.gain[i] = replay_gain[i];
							fr->rva.level[i] = 0;
						}
					}
					lame_offset += 1; /* skipping encoding flags byte */
					if(fr->vbr == MPG123_ABR)
					{
						fr->abr_rate = fr->bsbuf[lame_offset];
						if(VERBOSE3) fprintf(stderr, "Note: Info: ABR rate = %u\n", fr->abr_rate);
					}
					lame_offset += 1;
					/* encoder delay and padding, two 12 bit values... lame does write them from int ...*/
					if(VERBOSE3)
					fprintf(stderr, "Note: Encoder delay = %i; padding = %i\n",
					        ((((int) fr->bsbuf[lame_offset]) << 4) | (((int) fr->bsbuf[lame_offset+1]) >> 4)),
					        (((((int) fr->bsbuf[lame_offset+1]) << 8) | (((int) fr->bsbuf[lame_offset+2]))) & 0xfff) );
					#ifdef GAPLESS
					if(fr->p.flags & MPG123_GAPLESS)
					{
						off_t length = fr->track_frames * spf(fr);
						off_t skipbegin = GAPLESS_DELAY + ((((int) fr->bsbuf[lame_offset]) << 4) | (((int) fr->bsbuf[lame_offset+1]) >> 4));
						off_t skipend = -GAPLESS_DELAY + (((((int) fr->bsbuf[lame_offset+1]) << 8) | (((int) fr->bsbuf[lame_offset+2]))) & 0xfff);
						debug3("preparing gapless mode for layer3: length %lu, skipbegin %lu, skipend %lu",
								(long unsigned)length, (long unsigned)skipbegin, (long unsigned)skipend);
						if(length > 1)
						frame_gapless_init(fr, skipbegin, (skipend < length) ? length-skipend : length);
					}
					#endif
				}
				/* switch buffer back ... */
				fr->bsbuf = fr->bsspace[fr->bsnum]+512;
				fr->bsnum = (fr->bsnum + 1) & 1;
				return 1; /* got it! */
			}
		}
	}
	return 0; /* no lame tag */
}

/* Just tell if the header is some mono. */
static int header_mono(unsigned long newhead)
{
	return ((newhead>>6)&0x3) == MPG_MD_MONO ? TRUE : FALSE;
}

/*
	That's a big one: read the next frame. 1 is success, <= 0 is some error
	Special error READER_MORE means: Please feed more data and try again.
*/
int read_frame(mpg123_handle *fr)
{
	/* TODO: rework this thing */
	unsigned long newhead;
	off_t framepos;
	int ret;
	/* stuff that needs resetting if complete frame reading fails */
	int oldsize  = fr->framesize;
	int oldphase = fr->halfphase;

	/* The counter for the search-first-header loop.
	   It is persistent outside the loop to prevent seemingly endless loops
	   when repeatedly headers are found that do not have valid followup headers. */
	int headcount = 0;

	fr->fsizeold=fr->framesize;       /* for Layer3 */

	/* Speed-down hack: Play it again, Sam (the frame, I mean). */
	if (fr->p.halfspeed)
	{
		if(fr->halfphase) /* repeat last frame */
		{
			debug("repeat!");
			fr->to_decode = fr->to_ignore = TRUE;
			--fr->halfphase;
			fr->bitindex = 0;
			fr->wordpointer = (unsigned char *) fr->bsbuf;
			if(fr->lay == 3) memcpy (fr->bsbuf, fr->ssave, fr->ssize);
			if(fr->error_protection) fr->crc = getbits(fr, 16); /* skip crc */
			return 1;
		}
		else
		{
			fr->halfphase = fr->p.halfspeed - 1;
		}
	}

read_again:
	/* In case we are looping to find a valid frame, discard any buffered data before the current position.
	   This is essential to prevent endless looping, always going back to the beginning when feeder buffer is exhausted. */
	if(fr->rd->forget != NULL) fr->rd->forget(fr);

	debug2("trying to get frame %"OFF_P" at %"OFF_P, (off_p)fr->num+1, (off_p)fr->rd->tell(fr));
	if((ret = fr->rd->head_read(fr,&newhead)) <= 0){ debug("need more?"); goto read_frame_bad;}

init_resync:

	fr->header_change = 2; /* output format change is possible... */
	if(fr->oldhead)        /* check a following header for change */
	{
		if(fr->oldhead == newhead) fr->header_change = 0;
		else
		/* If they have the same sample rate. Note that only is _not_ the case for the first header, as we enforce sample rate match for following frames.
			 So, during one stream, only change of stereoness is possible and indicated by header_change == 2. */
		if((fr->oldhead & HDRSAMPMASK) == (newhead & HDRSAMPMASK))
		{
			/* Now if both channel modes are mono or both stereo, it's no big deal. */
			if( header_mono(fr->oldhead) == header_mono(newhead))
			fr->header_change = 1;
		}
	}

#ifdef SKIP_JUNK
	/* watch out for junk/tags on beginning of stream by invalid header */
	if(!fr->firsthead && !head_check(newhead)) {

		/* check for id3v2; first three bytes (of 4) are "ID3" */
		if((newhead & (unsigned long) 0xffffff00) == (unsigned long) 0x49443300)
		{
			int id3ret = 0;
			id3ret = parse_new_id3(fr, newhead);
			if     (id3ret < 0){ debug("need more?"); ret = id3ret; goto read_frame_bad; }
#ifndef NO_ID3V2
			else if(id3ret > 0){ debug("got ID3v2"); fr->metaflags  |= MPG123_NEW_ID3|MPG123_ID3; }
			else debug("no useful ID3v2");
#endif

			fr->oldhead = 0;
			goto read_again; /* Also in case of invalid ID3 tag (ret==0), try to get on track again. */
		}
		else if(VERBOSE2 && fr->silent_resync == 0) fprintf(stderr,"Note: Junk at the beginning (0x%08lx)\n",newhead);

		/* I even saw RIFF headers at the beginning of MPEG streams ;( */
		if(newhead == ('R'<<24)+('I'<<16)+('F'<<8)+'F') {
			if(VERBOSE2 && fr->silent_resync == 0) fprintf(stderr, "Note: Looks like a RIFF header.\n");

			if((ret=fr->rd->head_read(fr,&newhead))<=0){ debug("need more?"); goto read_frame_bad; }

			while(newhead != ('d'<<24)+('a'<<16)+('t'<<8)+'a')
			{
				if((ret=fr->rd->head_shift(fr,&newhead))<=0){ debug("need more?"); goto read_frame_bad; }
			}
			if((ret=fr->rd->head_read(fr,&newhead))<=0){ debug("need more?"); goto read_frame_bad; }

			if(VERBOSE2 && fr->silent_resync == 0) fprintf(stderr,"Note: Skipped RIFF header!\n");

			fr->oldhead = 0;
			goto read_again;
		}
		/* unhandled junk... just continue search for a header */
		/* step in byte steps through next 64K */
		debug("searching for header...");

		ret = 0; /* We will check the value after the loop. */
		for(; headcount<65536; headcount++)
		{
			if((ret=fr->rd->head_shift(fr,&newhead))<=0){ debug("need more?"); goto read_frame_bad; }
			/* if(head_check(newhead)) */
			if(head_check(newhead) && (ret=decode_header(fr, newhead)))
				break;
		}
		if(ret<0){ debug("need more?"); goto read_frame_bad; }

		if(headcount == 65536)
		{
			if(NOQUIET) error("Giving up searching valid MPEG header after (over) 64K of junk.");
			return 0;
		}
		else debug1("hopefully found one at %"OFF_P, (off_p)fr->rd->tell(fr));
		/*
		 * should we additionaly check, whether a new frame starts at
		 * the next expected position? (some kind of read ahead)
		 * We could implement this easily, at least for files.
		 */
	}
#endif

	/* first attempt of read ahead check to find the real first header; cannot believe what junk is out there! */
	if(!fr->firsthead && fr->rdat.flags & (READER_SEEKABLE|READER_BUFFERED) && head_check(newhead) && (ret=decode_header(fr, newhead)))
	{
		unsigned long nexthead = 0;
		int hd = 0;
		off_t start = fr->rd->tell(fr);
		if(ret<0){ debug("need more?"); goto read_frame_bad; }

		debug2("doing ahead check with BPF %d at %"OFF_P, fr->framesize+4, (off_p)start);
		/* step framesize bytes forward and read next possible header*/
		if((ret=fr->rd->skip_bytes(fr, fr->framesize))<0)
		{
			if(ret==READER_ERROR && NOQUIET) error("cannot seek!");
			goto read_frame_bad;
		}
		hd = fr->rd->head_read(fr,&nexthead);
		if(hd==MPG123_NEED_MORE){ debug("need more?"); ret = hd; goto read_frame_bad; }
		if((ret=fr->rd->back_bytes(fr, fr->rd->tell(fr)-start))<0)
		{
			if(ret==READER_ERROR && NOQUIET) error("cannot seek!");
			else debug("need more?");
			goto read_frame_bad;
		}
		debug1("After fetching next header, at %"OFF_P, (off_p)fr->rd->tell(fr));
		if(!hd)
		{
			if(NOQUIET) warning("cannot read next header, a one-frame stream? Duh...");
		}
		else
		{
			debug2("does next header 0x%08lx match first 0x%08lx?", nexthead, newhead);
			/* not allowing free format yet */
			if(!head_check(nexthead) || (nexthead & HDRCMPMASK) != (newhead & HDRCMPMASK))
			{
				debug("No, the header was not valid, start from beginning...");
				fr->oldhead = 0; /* start over */
				/* try next byte for valid header */
				if((ret=fr->rd->back_bytes(fr, 3))<0)
				{
					if(NOQUIET) error("cannot seek!");
					else debug("need more?");
					goto read_frame_bad;
				}
				goto read_again;
			}
		}
	}

	/* why has this head check been avoided here before? */
	if(!head_check(newhead))
	{
		/* and those ugly ID3 tags */
		if((newhead & 0xffffff00) == ('T'<<24)+('A'<<16)+('G'<<8))
		{
			fr->id3buf[0] = (unsigned char) ((newhead >> 24) & 0xff);
			fr->id3buf[1] = (unsigned char) ((newhead >> 16) & 0xff);
			fr->id3buf[2] = (unsigned char) ((newhead >> 8)  & 0xff);
			fr->id3buf[3] = (unsigned char) ( newhead        & 0xff);
			if((ret=fr->rd->fullread(fr,fr->id3buf+4,124)) < 0){ debug("need more?"); goto read_frame_bad; }
			fr->metaflags  |= MPG123_NEW_ID3|MPG123_ID3;
			fr->rdat.flags |= READER_ID3TAG; /* that marks id3v1 */
			if (VERBOSE3) fprintf(stderr,"Note: Skipped ID3v1 tag.\n");
			goto read_again;
		}
		/* duplicated code from above! */
		/* check for id3v2; first three bytes (of 4) are "ID3" */
		if((newhead & (unsigned long) 0xffffff00) == (unsigned long) 0x49443300)
		{
			int id3length = 0;
			id3length = parse_new_id3(fr, newhead);
			if(id3length < 0){ debug("need more?"); ret = id3length; goto read_frame_bad; }

			fr->metaflags  |= MPG123_NEW_ID3|MPG123_ID3;
			goto read_again;
		}
		else if(NOQUIET && fr->silent_resync == 0)
		{
			fprintf(stderr,"Note: Illegal Audio-MPEG-Header 0x%08lx at offset %"OFF_P".\n",
				newhead, (off_p)fr->rd->tell(fr)-4);
		}

		if(NOQUIET && (newhead & 0xffffff00) == ('b'<<24)+('m'<<16)+('p'<<8)) fprintf(stderr,"Note: Could be a BMP album art.\n");
		/* Do resync if not forbidden by flag.
		I used to have a check for not-icy-meta here, but concluded that the desync issues came from a reader bug, not the stream. */
		if( !(fr->p.flags & MPG123_NO_RESYNC) )
		{
			long try = 0;
			long limit = fr->p.resync_limit;

			/* If a resync is needed the bitreservoir of previous frames is no longer valid */
			fr->bitreservoir = 0;

			/* TODO: make this more robust, I'd like to cat two mp3 fragments together (in a dirty way) and still have mpg123 beign able to decode all it somehow. */
			if(NOQUIET && fr->silent_resync == 0) fprintf(stderr, "Note: Trying to resync...\n");
			/* Read more bytes until we find something that looks
			 reasonably like a valid header.  This is not a
			 perfect strategy, but it should get us back on the
			 track within a short time (and hopefully without
			 too much distortion in the audio output).  */
			do
			{
				++try;
				if(limit >= 0 && try >= limit) break;

				if((ret=fr->rd->head_shift(fr,&newhead)) <= 0)
				{
					debug("need more?");
					if(NOQUIET) fprintf (stderr, "Note: Hit end of (available) data during resync.\n");

					goto read_frame_bad;
				}
				if(VERBOSE3) debug3("resync try %li at %"OFF_P", got newhead 0x%08lx", try, (off_p)fr->rd->tell(fr),  newhead);

				if(!fr->oldhead)
				{
					debug("going to init_resync...");
					goto init_resync;       /* "considered harmful", eh? */
				}
				/* we should perhaps collect a list of valid headers that occured in file... there can be more */
				/* Michael's new resync routine seems to work better with the one frame readahead (and some input buffering?) */
			} while
			(
				!head_check(newhead) /* Simply check for any valid header... we have the readahead to get it straight now(?) */
				/*   (newhead & HDRCMPMASK) != (fr->oldhead & HDRCMPMASK)
				&& (newhead & HDRCMPMASK) != (fr->firsthead & HDRCMPMASK)*/
			);
			/* too many false positives
			}while (!(head_check(newhead) && decode_header(fr, newhead))); */
			if(NOQUIET && fr->silent_resync == 0) fprintf (stderr, "Note: Skipped %li bytes in input.\n", try);

			if(limit >= 0 && try >= limit)
			{
				if(NOQUIET)
				error1("Giving up resync after %li bytes - your stream is not nice... (maybe increasing resync limit could help).", try);

				fr->err = MPG123_RESYNC_FAIL;
				return READER_ERROR;
			}
			else
			{
				debug1("Found valid header 0x%lx... unsetting firsthead to reinit stream.", newhead);
				fr->firsthead = 0;
				goto init_resync;
			}
		}
		else
		{
			if(NOQUIET) error("not attempting to resync...");

			fr->err = MPG123_OUT_OF_SYNC;
			return READER_ERROR;
		}
	}

	/* Man, that code looks awfully redundant...
	   I need to untangle the spaghetti here in a future version. */
	if(!fr->firsthead)
	{
		ret=decode_header(fr,newhead);
		if(ret == 0)
		{
			if(NOQUIET) error("decode header failed before first valid one, going to read again");

			goto read_again;
		}
		else if(ret < 0){ debug("need more?"); goto read_frame_bad; }
	}
	else
	{
		ret=decode_header(fr,newhead);
		if(ret == 0)
		{
			if(NOQUIET) error("decode header failed - goto resync");
			/* return 0; */
			goto init_resync;
		}
		else if(ret < 0){ debug("need more?"); goto read_frame_bad; }
	}

	/* if filepos is invalid, so is framepos */
	framepos = fr->rd->tell(fr) - 4;
	/* flip/init buffer for Layer 3 */
	{
		unsigned char *newbuf = fr->bsspace[fr->bsnum]+512;
		/* read main data into memory */
		if((ret=fr->rd->read_frame_body(fr,newbuf,fr->framesize))<0)
		{
			/* if failed: flip back */
			debug("need more?");
			goto read_frame_bad;
		}
		fr->bsbufold = fr->bsbuf;
		fr->bsbuf = newbuf;
	}
	fr->bsnum = (fr->bsnum + 1) & 1;

	if(!fr->firsthead)
	{
		fr->firsthead = newhead; /* _now_ it's time to store it... the first real header */
		/* This is the first header of our current stream segment.
		   It is only the actual first header of the whole stream when fr->num is still below zero!
		   Think of resyncs where firsthead has been reset for format flexibility. */
		if(fr->num < 0)
		{
			fr->audio_start = framepos;
			/* Only check for LAME  tag at beginning of whole stream
			   ... when there indeed is one in between, it's the user's problem. */
			if(fr->lay == 3 && check_lame_tag(fr) == 1)
			{ /* ...in practice, Xing/LAME tags are layer 3 only. */
				if(fr->rd->forget != NULL) fr->rd->forget(fr);

				fr->oldhead = 0;
				goto read_again;
			}
			/* now adjust volume */
			do_rva(fr);
		}

		debug2("fr->firsthead: %08lx, audio_start: %li", fr->firsthead, (long int)fr->audio_start);
	}

  fr->bitindex = 0;
  fr->wordpointer = (unsigned char *) fr->bsbuf;
	/* Question: How bad does the floating point value get with repeated recomputation?
	   Also, considering that we can play the file or parts of many times. */
	if(++fr->mean_frames != 0)
	{
		fr->mean_framesize = ((fr->mean_frames-1)*fr->mean_framesize+compute_bpf(fr)) / fr->mean_frames ;
	}
	++fr->num; /* 0 for first frame! */
	debug4("Frame %"OFF_P" %08lx %i, next filepos=%"OFF_P,
	(off_p)fr->num, newhead, fr->framesize, (off_p)fr->rd->tell(fr));

	/* save for repetition */
	if(fr->p.halfspeed && fr->lay == 3)
	{
		debug("halfspeed - reusing old bsbuf ");
		memcpy (fr->ssave, fr->bsbuf, fr->ssize);
	}

	/* index the position */
#ifdef FRAME_INDEX
	/* Keep track of true frame positions in our frame index.
	   but only do so when we are sure that the frame number is accurate... */
	if(fr->accurate && FI_NEXT(fr->index, fr->num))
	fi_add(&fr->index, framepos);
#endif

	if(fr->silent_resync > 0) --fr->silent_resync;

	if(fr->rd->forget != NULL) fr->rd->forget(fr);

	fr->to_decode = fr->to_ignore = TRUE;
	if(fr->error_protection) fr->crc = getbits(fr, 16); /* skip crc */

	return 1;
read_frame_bad:
	/* Also if we searched for valid data in vain, we can forget skipped data.
	   Otherwise, the feeder would hold every dead old byte in memory until the first valid frame! */
	if(fr->rd->forget != NULL) fr->rd->forget(fr);

	fr->silent_resync = 0;
	if(fr->err == MPG123_OK) fr->err = MPG123_ERR_READER;
	fr->framesize = oldsize;
	fr->halfphase = oldphase;
	/* That return code might be inherited from some feeder action, or reader error. */
	return ret;
}

/*
 * read ahead and find the next MPEG header, to guess framesize
 * return value: success code
 *  1: found a valid frame size (stored in the handle).
 * <0: error codes, possibly from feeder buffer (NEED_MORE)
 *  0: cannot get the framesize for some reason and shall silentry try the next possible header (if this is no free format stream after all...)
 */
static int guess_freeformat_framesize(mpg123_handle *fr)
{
	long i;
	int ret;
	unsigned long head;
	if(!(fr->rdat.flags & (READER_SEEKABLE|READER_BUFFERED)))
	{
		if(NOQUIET) error("Cannot look for freeformat frame size with non-seekable and non-buffered stream!");

		return 0;
	}
	if((ret=fr->rd->head_read(fr,&head))<=0)
	return ret;

	/* We are already 4 bytes into it */
/* fix that limit to be absolute for the first header search! */
	for(i=4;i<65536;i++) {
		if((ret=fr->rd->head_shift(fr,&head))<=0)
		{
			return ret;
		}
		if(head_check(head))
		{
			int sampling_frequency,mpeg25,lsf;

			if(head & (1<<20))
			{
				lsf = (head & (1<<19)) ? 0x0 : 0x1;
				mpeg25 = 0;
			}
			else
			{
				lsf = 1;
				mpeg25 = 1;
			}

			if(mpeg25)
				sampling_frequency = 6 + ((head>>10)&0x3);
			else
				sampling_frequency = ((head>>10)&0x3) + (lsf*3);

			if((lsf==fr->lsf) && (mpeg25==fr->mpeg25) && (sampling_frequency == fr->sampling_frequency))
			{
				fr->rd->back_bytes(fr,i+1);
				fr->framesize = i-3;
				return 1; /* Success! */
			}
		}
	}
	fr->rd->back_bytes(fr,i);
	return 0;
}

/*
 * decode a header and write the information
 * into the frame structure
 * Return values are compatible with those of read_frame, namely:
 *  1: success
 *  0: no valid header
 * <0: some error
 */
static int decode_header(mpg123_handle *fr,unsigned long newhead)
{
	if(!head_check(newhead))
	{
		if(NOQUIET) error("tried to decode obviously invalid header");

		return 0;
	}
	if( newhead & (1<<20) )
	{
		fr->lsf = (newhead & (1<<19)) ? 0x0 : 0x1;
		fr->mpeg25 = 0;
	}
	else
	{
		fr->lsf = 1;
		fr->mpeg25 = 1;
	}

	if(   (fr->p.flags & MPG123_NO_RESYNC) || !fr->oldhead
	   || (((fr->oldhead>>19)&0x3) ^ ((newhead>>19)&0x3))  )
	{
		/* If "tryresync" is false, assume that certain
		parameters do not change within the stream!
		Force an update if lsf or mpeg25 settings
		have changed. */
		fr->lay = 4-((newhead>>17)&3);
		if( ((newhead>>10)&0x3) == 0x3)
		{
			if(NOQUIET) error("Stream error");

			return 0; /* exit() here really is too much, isn't it? */
		}
		if(fr->mpeg25)
		fr->sampling_frequency = 6 + ((newhead>>10)&0x3);
		else
		fr->sampling_frequency = ((newhead>>10)&0x3) + (fr->lsf*3);
	}

	#ifdef DEBUG
	if((((newhead>>16)&0x1)^0x1) != fr->error_protection) debug("changed crc bit!");
	#endif
	fr->error_protection = ((newhead>>16)&0x1)^0x1; /* seen a file where this varies (old lame tag without crc, track with crc) */
	fr->bitrate_index = ((newhead>>12)&0xf);
	fr->padding   = ((newhead>>9)&0x1);
	fr->extension = ((newhead>>8)&0x1);
	fr->mode      = ((newhead>>6)&0x3);
	fr->mode_ext  = ((newhead>>4)&0x3);
	fr->copyright = ((newhead>>3)&0x1);
	fr->original  = ((newhead>>2)&0x1);
	fr->emphasis  = newhead & 0x3;
	fr->freeformat = free_format_header(newhead);

	fr->stereo    = (fr->mode == MPG_MD_MONO) ? 1 : 2;

	fr->oldhead = newhead;

	/* we can't use tabsel_123 for freeformat, so trying to guess framesize... */
	if(fr->freeformat)
	{
		/* when we first encounter the frame with freeformat, guess framesize */
		if(fr->freeformat_framesize < 0)
		{
			int ret;
			ret = guess_freeformat_framesize(fr);
			if(ret>0)
			{
				fr->freeformat_framesize = fr->framesize - fr->padding;
				if(VERBOSE2)
				fprintf(stderr, "Note: free format frame size %li\n", fr->freeformat_framesize);
			}
			else
			{
				if(ret == MPG123_NEED_MORE)
				debug("Need more data to guess free format frame size.");
				else
				error("Encountered free format header, but failed to guess frame size.");
				return ret;
			}
		}
		/* freeformat should be CBR, so the same framesize can be used at the 2nd reading or later */
		else
		{
			fr->framesize = fr->freeformat_framesize + fr->padding;
		}
	}

	switch(fr->lay)
	{
#ifndef NO_LAYER1
		case 1:
			fr->do_layer = do_layer1;
			if(!fr->freeformat)
			{
				fr->framesize  = (long) tabsel_123[fr->lsf][0][fr->bitrate_index] * 12000;
				fr->framesize /= freqs[fr->sampling_frequency];
				fr->framesize  = ((fr->framesize+fr->padding)<<2)-4;
			}
		break;
#endif
#ifndef NO_LAYER2
		case 2:
			fr->do_layer = do_layer2;
			if(!fr->freeformat)
			{
				debug2("bitrate index: %i (%i)", fr->bitrate_index, tabsel_123[fr->lsf][1][fr->bitrate_index] );
				fr->framesize = (long) tabsel_123[fr->lsf][1][fr->bitrate_index] * 144000;
				fr->framesize /= freqs[fr->sampling_frequency];
				fr->framesize += fr->padding - 4;
			}
		break;
#endif
#ifndef NO_LAYER3
		case 3:
			fr->do_layer = do_layer3;
			if(fr->lsf)
			fr->ssize = (fr->stereo == 1) ? 9 : 17;
			else
			fr->ssize = (fr->stereo == 1) ? 17 : 32;

			if(fr->error_protection)
			fr->ssize += 2;

			if(!fr->freeformat)
			{
				fr->framesize  = (long) tabsel_123[fr->lsf][2][fr->bitrate_index] * 144000;
				fr->framesize /= freqs[fr->sampling_frequency]<<(fr->lsf);
				fr->framesize = fr->framesize + fr->padding - 4;
			}
		break;
#endif
		default:
			if(NOQUIET) error1("Layer type %i not supported in this build!", fr->lay);

			return 0;
	}
	if (fr->framesize > MAXFRAMESIZE)
	{
		if(NOQUIET) error1("Frame size too big: %d", fr->framesize+4-fr->padding);

		return (0);
	}
	return 1;
}

void set_pointer(mpg123_handle *fr, long backstep)
{
	fr->wordpointer = fr->bsbuf + fr->ssize - backstep;
	if (backstep)
	memcpy(fr->wordpointer,fr->bsbufold+fr->fsizeold-backstep,backstep);

	fr->bitindex = 0;
}

/********************************/

double compute_bpf(mpg123_handle *fr)
{
	double bpf;

	switch(fr->lay)
	{
		case 1:
			bpf = tabsel_123[fr->lsf][0][fr->bitrate_index];
			bpf *= 12000.0 * 4.0;
			bpf /= freqs[fr->sampling_frequency] <<(fr->lsf);
		break;
		case 2:
		case 3:
			bpf = tabsel_123[fr->lsf][fr->lay-1][fr->bitrate_index];
			bpf *= 144000;
			bpf /= freqs[fr->sampling_frequency] << (fr->lsf);
		break;
		default:
			bpf = 1.0;
	}

	return bpf;
}

double attribute_align_arg mpg123_tpf(mpg123_handle *fr)
{
	static int bs[4] = { 0,384,1152,1152 };
	double tpf;
	if(fr == NULL) return -1;

	tpf = (double) bs[fr->lay];
	tpf /= freqs[fr->sampling_frequency] << (fr->lsf);
	return tpf;
}

int attribute_align_arg mpg123_position(mpg123_handle *fr, off_t no, off_t buffsize,
	off_t  *current_frame,   off_t  *frames_left,
	double *current_seconds, double *seconds_left)
{
	double tpf;
	double dt = 0.0;
	off_t cur, left;
	double curs, lefts;

	if(!fr || !fr->rd) /* Isn't this too paranoid? */
	{
		debug("reader troubles!");
		return MPG123_ERR;
	}

	no += fr->num; /* no starts out as offset */
	cur = no;
	tpf = mpg123_tpf(fr);
	if(buffsize > 0 && fr->af.rate > 0 && fr->af.channels > 0)
	{
		dt = (double) buffsize / fr->af.rate / fr->af.channels;
		if(fr->af.encoding & MPG123_ENC_16) dt *= 0.5;
	}

	left = 0;

	if((fr->track_frames != 0) && (fr->track_frames >= fr->num)) left = no < fr->track_frames ? fr->track_frames - no : 0;
	else
	if(fr->rdat.filelen >= 0)
	{
		double bpf;
		off_t t = fr->rd->tell(fr);
		bpf = fr->mean_framesize ? fr->mean_framesize : compute_bpf(fr);
		left = (off_t)((double)(fr->rdat.filelen-t)/bpf);
		/* no can be different for prophetic purposes, file pointer is always associated with fr->num! */
		if(fr->num != no)
		{
			if(fr->num > no) left += fr->num - no;
			else
			{
				if(left >= (no - fr->num)) left -= no - fr->num;
				else left = 0; /* uh, oh! */
			}
		}
		/* I totally don't understand why we should re-estimate the given correct(?) value */
		/* fr->num = (unsigned long)((double)t/bpf); */
	}

	/* beginning with 0 or 1?*/
	curs = (double) no*tpf-dt;
	lefts = (double)left*tpf+dt;
#if 0
	curs = curs < 0 ? 0.0 : curs;
#endif
	if(left < 0 || lefts < 0)
	{ /* That is the case for non-seekable streams. */
		left  = 0;
		lefts = 0.0;
	}
	if(current_frame != NULL) *current_frame = cur;
	if(frames_left   != NULL) *frames_left   = left;
	if(current_seconds != NULL) *current_seconds = curs;
	if(seconds_left    != NULL) *seconds_left   = lefts;
	return MPG123_OK;
}

int get_songlen(mpg123_handle *fr,int no)
{
	double tpf;

	if(!fr)
		return 0;

	if(no < 0) {
		if(!fr->rd || fr->rdat.filelen < 0)
			return 0;
		no = (int) ((double) fr->rdat.filelen / compute_bpf(fr));
	}

	tpf = mpg123_tpf(fr);
	return (int) (no*tpf);
}

redpajama_set_name: RedPajamaGithub


text:
Черёмуха пенсильва́нская () — вид рода Слива семейства Розовые. Родина — Северная Америка.

Ботаническое описание

Небольшое лиственное дерево высотой от 1 до 6 метров, иногда вырастает до 12 метров.

Кора блестящего тёмно-вишневого цвета. Ветки тонкие и гибкие, крона воздушная.

Цветёт в конце мая, цветки белые, собраны в соцветия, практически не имеют запаха.

В августе созревают небольшие красные съедобные плоды. Вкус у них кисло-сладкий или кислый.

Хозяйственное значение и применение

Выращивание в культуре
Черёмуха пенсильванская светолюбива, нетребовательна к почве, зимостойка.

Примечания

Плодовые деревья
Сливовые
Ягодные растения

redpajama_set_name: RedPajamaWikipedia


text:
«Муромец», до 1999 года «Киевский комсомолец», (МПК-134) — малый противолодочный корабль проекта 1124М. (шифр «Альбатрос», кодовое обозначение НАТО — Grisha III class corvette).

Строительство
Корабль заложен (зав.№001) в 1980 году как «МПК-64» в Киеве на ССЗ «Ленинская кузница»  (завод №302). «МПК-64» стал первым кораблем проекта 1124М. Зачислен в списки 30 октября 1981 года. С 27 июля 1982 присвоено новое имя - «Киевский комсомолец». Включен в состав Краснознаменного Черноморского флота с 5 марта 1983 года. 15 февраля 1992 года вновь переименован в «МПК-134», а современное имя малый противолодочный корабль получил 5 апреля 1999 года.

История службы
МПК «Киевский комсомолец» в составе КПУГ в 1985, 1986 и 1989 годах становился обладателем приза ГК ВМФ по противолодочной подготовке.

27 июля 1997 года на «МПК-134» сменили Военно-морской флаг СССР на Андреевский.

5 апреля 1999 года в торжественной обстановке малый противолодочный корабль «МПК-134» противолодочного дивизиона был переименован в «Муромец». Командир — капитан 3 ранга В. П. Ромашов. В 1999 году МПК вновь стал обладателем приза ГК ВМФ по противолодочной подготовке, уже как МПК «Муромец».

В июле 2007 года МПК «Муромец» отработал совместные действия и мероприятия боевой подготовки с соединением надводных кораблей.

По итогам 2011 года МПК «Муромец» стал лучшим кораблем ЧФ РФ по противолодочной и радиотехнической подготовке.

В январе 2013 года МПК «Муромец» выполнил специальное задание по охране олимпийских объектов у побережья Сочи. Экипажу была поставлена задача по отработке приемов оборонительного боя при атаке противника с моря во время проведения Олимпийских игр в Сочи. Учебные маневры проходили вместе с экипажем морского тральщика «Вице-адмирал Захарьин». В июне 2013 года принял участие в российско-украинских учениях «Фарватер мира-2013».

По состоянию на 2015 год находится в боевом составе ВМФ РФ в составе 149-й тактической группы противолодочных кораблей 68-й бригады кораблей охраны водного района с базированием на Южную бухту Севастополя.

Командиры корабля
Этим кораблем в разное время командовали:
 капитан 3-го ранга В. М. Ромашов
 капитан 3-го ранга А. Михеев
 капитан 3-го ранга С. Ткач
 капитан 3-го ранга О. Григорьев
 капитан 3-го ранга В. Куртяков
 капитан 3-го ранга Д. Гамаюнов

Бортовые номера
 № 064

Галерея

Примечания

Литература

Ссылки
 Малый противолодочный корабль "МПК-134" ("Муромец")
 Малые противолодочные корабли проекта 1124М

Малые противолодочные корабли проекта 1124
Суда по алфавиту
Военные корабли Черноморского флота
Военные корабли и суда, построенные на заводе «Кузница на Рыбальском»


You can now order your replacement lenses on-line! It's safe and convenient. Take advantage of our on-line discounts when purchasing multiple boxes and have them delivered straight to your door.
Have one of our friendly associates do it for you at your next visit.


text:
'use strict';

describe('Test of featuredCarousel', function() {
  beforeEach(module('lappsApp'));

  var scope, $httpBackend, swagger, mockApps, platform;

  beforeEach(inject(function($rootScope, $controller, _$httpBackend_,
          swagger2HttpBackend, _karmaHelper_, _platform_) {
    scope = $rootScope.$new();
    $httpBackend = _$httpBackend_;
    $controller('featuredCarouselCtr', {
      '$scope': scope
    });
    swagger = swagger2HttpBackend;
    mockApps = _karmaHelper_.getMockApps();
    platform = _platform_;
  }));

  it('should make a request to show some apps', function() {
    var apiRequest = swagger.getRequest('apps.getAllApps', {
      page: 1,
      pageLength: 5,
      sortBy: 'random',
      filterBy: 'minrating;platform',
      filterValue: '3;' + platform.currentPlatform.name
    });
    $httpBackend.expectGET(apiRequest.url).respond([mockApps[0], mockApps[1]]);
    expect(scope.apps.length).toBe(0);
    $httpBackend.flush();
    expect(scope.apps.length).toBe(2);
    expect(scope.apps[0].thumbnail).toContain('.');
    expect(scope.apps[0].image).toContain('.');
    expect(scope.apps[0].platformObj).toBeDefined();
  });
});


If you have ever walked through a fitness center and wondered what those small, heavy balls were for, you are missing a valuable workout tool.
A medicine ball is about 14 inches in size and is weighted, often varying from 2 to 25 pounds in weight. The use of medicine balls has actually existed since ancient Greece, when the physician Hippocrates would have animal skins filled with sand and sewn shut. He would then have his patients hold and toss the balls to help injured muscles repair and heal.
Medicine balls have continued to be popular through time and are often used in strength training, specifically for the core abdominal muscles. Athletes can hold and lift the ball or move it in different directions while doing various exercises. The weight of the medicine ball acts like a free weight, stressing the muscles and forcing them to tear down so that they can rebuild and be bigger in size. When athletes hold the medicine ball further away from the body, the more the muscles are strained and thereby strengthened.
Most medicine balls are made out of vinyl or leather and filled with sand, steel shot or other material to add weight to the ball. Some medicine balls have handles or ropes attached, while others do not.
When it comes to medicine balls, one of the best kinds on the market is the Revgear leather medicine ball. This leather medicine ball is available in 9, 12, 15 and 20-pound sizes. Each ball is specifically designed to fit easily into hands of all sizes. The Revgear leather medicine ball is 100 percent leather and is triple stitched to ensure durability and functionality for a long time to come.
It is recommended that athletes purchase several sizes to incorporate into their workouts to prevent muscle boredom and growth plateaus. In addition, various weights work better with different workouts. For example, you can use the medicine ball to do weighted sit ups to increase your core strength, which will help in generating more power in your punches and kicks.


text:
You as an Organizational Leader
Value Creation and Building Enduring Relationships
Course 3 of 3 in the Principles of Leadership: Leading Technical Organizations Specialization
The most effective leaders in complex technical organizations are successful leading the performance of large-scale technical endeavors. These leaders have generally established a network of professional relationships, supporting them throughout their career. This third Leading Technical Organizations course, "Value Creation and Building Enduring Relationships", explores techniques for building relationships that have a multiplicative impact on business success. The course provides insight into how authentic leadership yields employee engagement that is critical to strategizing, planning and performing large scale technical endeavors. This course can be taken for academic credit as part of CU Boulder's Master of Engineering in Engineering Management (ME-EM) degree offered on the Coursera platform. The ME-EM is designed to help engineers, scientists, and technical professionals move into leadership and management roles in the engineering and technical sectors. With performance-based admissions and no application process, the ME-EM is ideal for individuals with a broad range of undergraduate education and/or professional experience. Learn more about the ME-EM program at https://www.coursera.org/degrees/me-engineering-management-boulder.
Envision you as a leader of a technical organization, Enhance employee engagement through authentic leadership, How to build an entrepreneurial culture in an incumbent organization, Learn The value of enduring relationships and their contribution to business success, Understand what different stakeholders value in your organization
This final module of the Leading Technical Organizations specialization brings the core concepts of what we have learned together to give a six-step framework for succeeding as a leader. The module also includes a presentation by Mike Gazarik, the Vice President of Engineering at Ball Aerospace. He tells his career story and highlights the leadership skills that served him best on his journey. Hope you enjoyed Leading Technical Organizations and thank you for investing your time in this specialization.
You as an Organizational Leader41:54
Kathryn Tobey
I am so pleased and honored to introduce to you our guest speaker tonight. Dr Mijke Gazarik, he is the Vice President of Engineering at Ball Aerospace, before that he had an illustrious career at NASA where he left that organization as the Associate Administrator for the Space Technology Mission Director. He has just a long history of leadership, technical leadership in various dimensions. And like I said, he is such an engaged leader and he of anyone would understand what it means to lead a technical organization and that the challenges and the opportunities, the surprises and the benefits of doing some advice. So with that I am going to turn it over to Mike. >> Hey and appreciate that really warm welcome, appreciate those kind words, very nice of you and really great to be here. Hello everyone, and it's kind of exciting and an honor to be in your last thoughts, I think you're done after this. So I do understand that I stand the last thing before you and when you're finished with of course, so I get that. So let's try to make it interesting and exciting and something worthwhile. And boy, that video is something else that's going to be hard to follow Kathryn. Jesus, that was pretty inspirational, so I'm not sure how to live up with that. But it's interesting, there's some teams in there that and I didn't of course know that video is going to be played, but I have them in my slides, I have 10 slides tonight. So not a lot really, and they're really just a framework for discussion, they're not meant to be this one after another story that I want to tell you. So let's use it as a framework and see if we can add some value on your last class. So with that, let's go to the next chart. I'm going to spend just a few minutes talking about me in my career, not because I think you'll find it interesting. But I think it maybe can services a context, here's a career path that some of you may relate to. There's some decisions along the way we can talk about, and it gives you some context, you can ask questions a little bit about my background. So that's the only reason I have it in here, and it's really a career on one slide or maybe 1.5 slides. So I will take you through the all the beginning, but basically for me, I grew up in Pittsburgh 1987 graduated Pittsburgh and Electrical Engineering. I went to the Universe, I grew up there and I went there, it was a local school for me was also the only place I got accepted, to be honest with you, so that's where I went. And from there and I kind of a funny story there, my parents, it's kind of on the lower side of growing up and at a time we always had enough, but not a lot. And actually my halfway through school actually [COUGH] my parents ran into financial difficulties and so I couldn't finish school. I didn't know how I was going to and I was lucky enough to get a general motors scholarship. And so the general motors truck and bus and I worked in Detroit for two summers. And so that's kind of how I finished school. When I graduated, my department chair and I did fairly well school recommended I came from Georgia Tech, which is kind of a connection there. I also had an offer to go to TRW out in Los Angeles and they could go to a master's program at USC. I really didn't know a lot about masters and advanced degrees, I really did. I was pretty naive back then, probably still him today, but especially when it came to graduate school. But my department chair and this is where networks and people like your professor for this course and the networks, you have said you really do gotta go to graduate school, whatever that is. I went to Georgia Tech in Atlanta and worked for Rockwell International. So for some of you who may be working full time and also going to school, I was one of those as well back in the 80s. because back then there was no zoom, was all in person and Rockwell was kind enough for me to take off time in the day run downtown to Atlanta and take some courses. Eventually that was really hard. So for those of you doing it, it was the hardest thing I think I've ever done. Eventually left Rockwell to finish full time and got my degree, got married and I went up to New Jersey outside of New York city. My wife worked as a chemical engineer for Merck, so I followed her. And I worked for a small company doing navy work. It's what's shown there, very technical doing, making submarines not be heard if you will. And we did a lot of work for general dynamics in the Navy and that was a picture of us. We were on the island of a Lutheran when hurricane Andrew hit actually, we were trying to get off the island. So very exciting got the right around submarines, installed sensors and accelerometers. Very technical began there to do some team leadership, kind of, I was on the third shift. We were running 24/7 and that kind of informal team. But then I kind of had the itch when I was my master's program at Georgia Tech, one of the professors. Again, another connection said Mike, you really need to go for your PhD. Again, I was like I was not ready at that time to go do that, four years later though I was. And so we had our first child and we moved back to Atlanta and I did four years and actually my department chair at the University of Pittsburgh who sent me to Georgia Tech had come back to Georgia Tech. So again that connection is strong and I did my PhD thesis there with Ed came in and very wordy. After 97, it was a really hot area for engineering, lots of opportunities and I really didn't know what I wanted to do. And this comes in later when we talk about careers a bit, so I had a lot of offers, lots of opportunity. I ended up choosing MIT Lincoln laboratory. I was lucky enough to be entertained an offer and I thought that was one of the best places one could go turns out. Georgia tech is actually the number two supplier of talent to Lincoln lab after after MIT. Had a great career guided electro optics in aerospace and I built a center there for NASA which shown there that looks at the atmosphere, we can get a remote sensing, looking at temperature and community profiles. But then, so that was for NASA Langley in Virginia, but then you can see this is the journey part. I wasn't sure this is two thousand's, a lot of people was the .com era very bubbly kind of little similar to what we see today anyway. But I went off and did some commercial work for DSL and high speed internet and I did that like that company for a while. But then I thought wow, DSL I'm not sure that's the technology of the day. So I joined Texas instruments and I just bought a startup in Boston and they were doing 3G at the time. So at this point I'm in software, I'm a team lead but it was a huge mistake, huge mistake. The year I had at that Texas instruments startup I hated and I think they hated me, it was a horrible culture fit. I went for the technology thinking 3G not DSL, I didn't do due diligence on culture and fit and we can talk about that in a bit later. So, I'm stuck at Texas instruments of what I do. Well, on the next slide I got a call every year from NASA because I built that instrument and Steve Jersey at the time kept calling me up. And so I finally said what we're going to go to NASA. And this is where I really learned that for me, I loved aerospace, I love working for something bigger than myself, whether it would be the government or defense or whether making more than just making high speed Internet, that was me. And it took me a long time, I'm probably late thirties now, early forties to figure that out, I wish I had figured it out earlier. For their long story at NASA Program Manager build a camera for the shuttle that's kind of buried between all those pictures. That's what shown the astronaut crew that were there. This is after the Columbia accident. So that was just an exciting opportunity in the bottom kind of buried was the heat shield for the curiosity rover. I got in the entry descent landing and worked a lot with JPL and so it got amazing experiences and program management. It was also what's called like a department head of branch, head of the engineering directorate. Eventually then applied for the senior executive service, it's called SES in the government to be a deputy director for engineering. Eventually then engineering director at NASA Langley and then I got a call that really makes no sense. This is the long linear part of the whole thing to say do you want to come to NASA headquarters in Washington, DC. And this is during the Obama administration and we wanted the chief technologist, time Bobby Braun wanted to set up a cross cutting technology organization, so it did not exist. And this is I wasn't sure I was ready, I'm just a knuckle dragging engineer and that was involved in technology. But it's one of those decisions that you're ready or you're not and you want to give it a go. And so I did so for four years I went to move to Washington DC with the family back in to Virginia and led the creation of what's now called the space technician directorate. So NASA at the time had three main focuses aeronautics, human spaceflight and science. So I led the creation of the fourth which is now called space technology and I'm happy to say 11 years later that exists. But there I had to learn how to work on the hill, how to meet congressman and senators. How do I convince them to make an appropriation to create an organization to appropriate funds for a cross cutting technology organization. And so it was quite a learning experience and very political working both with the White House and the Hill, the Congress is and learning about appropriation and authorizations. And how do you do that, how do you make those relationships so much to say there, but quite a journey. After four years of that it was really hard and the hardest thing I've ever done in terms of career and then came the Ball. So I've been to Ball seven years where I lead the engineering directorate. So that's just a quick snapshot with a few little decisions that maybe we can provide a framework as we go forward and talk a little bit about leading a technical organization. So let's go to the next chart, so that's it for career. Let me shift a little bit on these next couple of charts and talk about at least my journey through leadership. So a couple of things that I'd offer to all of you and I kind of give this talk in pieces to different audiences. So look, if you haven't started your leadership journey, a couple of things to think about, I think from leadership if you haven't started it already. I think and it's leading technical organizations clearly you want to move it from being any accidental team leads. Project leads kind of in the video it showed many examples of where you could lead in your life to intention, right? You now have an organization that you're responsible for that presumably is going to try to accomplish something and go do something. And so now it really shifts, so for me I'm a lifelong, I wanted to learn about it, there's a bunch of books and I've showed some of my favorites here. There are many out there, mine would be pick a model for me and it's funny, I saw in the video the servant style model. It's not about you, it's about the team and you're there to help the team move forward, help that or move forward. And we'll talk a little about that in the next couple kind of minutes about what does that mean, what does that look like? But for me, first and foremost it's a servant style where you're there to help others move forward. There's a lot of framework of leadership, mine I favor his emotional intelligence by Daniel Goleman. He wrote a couple books, social intelligence, emotional intelligence, it's been around for quite a while. But I really just I guess being an engineer that goes into the physiological of the brain and the functions and it's really tied to that. And you'll see that and actually a number of concept, the whole understanding of the brain and spending a little bit of time, at least through books. I don't think you need formal training to be a neurologist, but it really does help understand where that comes from. I think Bernie Brown, one of my favorite leading authors podcast, many of you may know her, she does a weekly on dare to Lead. Talks about we, I think think of ourselves as rational rational beings that have occasionally have emotions. When in reality we're probably all emotional beatings on occasion, have a rational thought. And if you can kind of shift that thinking to the fact that now you have people to think about. That's in a very intentional framework and I think the emotional intelligence can kind of help process that. A few other things conflict comes up, especially if you're a change agent and so we can talk about that. There's certainly an art to it and the books by John E Kotter talk a little, a lot about change management. I think I have a leading change, I knew I had one of them, he has a bunch but boy, I tell you, I think that really helps often when you're in ignoring it is about change. You're trying to do something right to accomplish something, we can talk about that. And a little bit also in the bottom, basic leadership stuff, you've all heard this before, right? Finding mentors that really help whether they be at your company, your organ, the community, other highlights on this page that I wanted to hit where at the bottom. Bernet Brown again did a podcast about how to complete the stress cycle. It turns out right if you all of us, if you have an emotional reaction could be at work, could be at home. But something that really kind of sticks with you, whereas they use are you have a pinch or something that really bothers you. It turns out it's probably in your emotional system and you need to process it and there's only seven ways that you can process that emotional reaction. And if you don't you will live with it and then you can pick one of the seven, some people have different, that's one of the seven one has to do. And I say all that because you're going to be dealing with people and emotions and organizations. And if you can stay in that rational part of your thinking it really will help you and help the team move forward. And so that's a big part of it is understanding our emotional cycles, you're going to lead organizations. We'll talk about the technology and your acumen and street cred but the really, I think emphasis needs to be on the people's side and on the emotional side. And really getting comfortable with who you are and your ability to process emotions and then understanding others. If you can do that and begin to see it in people and teams, it will change your life and your ability to lead a technical organization. Okay, let's go to the next one. >> Yeah, I want to ask you about your managing conflict statement and how important it is to let your teams have that conflict in a positive way. But yet still sort of control a little bit, not necessarily the outcome but how they go about it. >> Yeah, great question, yeah and I think I have this on upcoming chart, but one if you can get to an environment. What the best way I think is through something called radical candor where you can challenge each other's ideas, thoughts, plans, schedules, but it's not personal. And so this involves relationships and understanding and trusting each other where you can debate each other to get better. And debate each other's ideas, but that it's not personal and I think that's the ultimate goal. If you can ever find that environment on your teams, on your project, on your classes and your organization. Then you really can get to that point where you really have an effective change and the other aspects of change out O'Connor would be a lot of things. One, most change the reason why it becomes emotional, right is because people feel like they're losing something, whether they're comfortable with, whether they're valued. And then you want to change and or gore process or the way to do things you can often hit accidentally unless you really understand change. It's taking away people's comfort It's taking away where people feel valued and you can imagine that emotion that comes with that. So understanding that is really key and kind of maybe recognizing when that happens. Okay, yeah, let's move on, so speaking of leaders and taking on roles, I found these personally and I see it in other people. But the most difficult transition is when we become from a technical performer where you've been proving your acumen pretty much since you were a little kid, right? Proving through high school, middle school, get into college, you're trying to prove yourself, you get into those first couple of jobs, maybe you're doing an analysis or writing code, doing it. It's technical and you're trying to prove, right? You're good, that's great when you move into the leadership there's nothing worse. I think I've seen that a leader still trying to prove themselves, it never goes well, right? You think about it what do you want that in your leader? You want, they're trying to prove themselves that's never good, right? They have to shift the leader needs to shift from them improving themselves to helping the team. And that focus on people and not just the result. And I remember that being very explicit struggle and you can lose the value of who you are. Think of all these years, you've been able to contribute, you can point to your value that you add. And all of a sudden now your leave, I can't write that letter code anymore, you wouldn't want me to, and I can't write C code anymore and you probably don't want me doing any kind of technical analysis, and you can quickly become, well, what value do I add? And you got all the deal with cartoons about leadership and management, right? [LAUGH] You might want to. So that could be a real pitfall and it can really trip you. And I've seen a trip people. So something to be conscious about when you make that transition. And yes, there's value added, there's this funny on that little chart of the army did, what's the best attributes of a leader, lazy, energetic, smart or dumb? Hopefully you didn't dumb and lazy, probably not the best quadrant to be in, but it turns out you might think energetic and smart. But it turns out [LAUGH] actually lazy and smart actually tends to be the best combination and that understanding of what needs to get done, but not on the energetic side, it can actually add more churning chaos into leadership. And you think about and we'll get to that what's the vision where you're trying to accomplish and then you're really trying to empowering people. And there's a certain element of being laid back and just being involved enough, it's a balance that I still try to achieve, that actually turns out to be often some of the best leaders. So there's some thoughts on the transition in aerospace, the other part of this becomes system engineering is a big part of what we do. It all started from there is a great book by the way, The Secrets of Apollo, which laid out kind of the basics of system engineering. Because most, at least in aerospace, what we do is so team oriented, complicated multi discipline. And so often leaders can fall into that, it doesn't have to but come out of the system engineering just because the overall system, it can be a natural lead to being a leader of a team lead or department. Not always, but often that's where it comes from. And then the other leadership aspect that we have to talk about in aerospace and I know you have this captain knows a lot about this isn't the program and project management. If you have an interesting process and schedule that becomes that of course, and typically in aerospace often where our leaders come from is from the program management area. Often in least an industry that's where profit and loss responsibility lies, which then generally tends to be often a career path with following the project and program management. So that's a few thoughts on kind of making that transition from technical performer into the different aspects, at least in aerospace of leadership. Let's get more broad in a second and let's go to the next chart. I mentioned before and you'll see a lot of this talk has a lot to do with people and emotions. Things we don't talk about technically, but it turns out you're going to lead an organization that is who you are leading. And that gets into the idea of culture and I mentioned before I made a poor choice not due diligence about a culture of a company or a team. And so I'm sure all of you and see you management engineering won't be cultural killers, and I'm sure you're good on the technical scale. But let's just talk about this to make sure [LAUGH] so there's lots of books and studies on this. You often see in a technical order someone who's really good technically p performers but no one wants to work with them. There's actually a book on this and you may know called the no **** role, and all studies will show you that that box three, the value that people take away because their cultural killers, because they're hard to work with, does not add enough value for their technical performance. So don't fall into that trap. It turns out if you don't find people in there and I'm sure none of you will be there. But if you find people in your or exit are there, you gotta coach them or move them out. It turns out that the value they detract is way more than the value they had. And so again, I say that because the technical you often will find that technical superstar. But, at least in aerospace you got, it's a team sport. And so what you really want to be of course is a p performer and a culture champion. Someone who people rally around, people who make the whole team better, who make the or better and our p performers in that box for where we all want to be, and we want to look for those and identify those. And that's the other thing in the organization that you joined trying to find out who those people are, who you can really around. You can really bring the team forward to bring the order forward. Those are key, and if you're new to the role, those also are key champions and advocates for support as you try to move the organization forward. Often if you're moving change, those people can also be your change advocates. Those are the people that people trust and can go to if you're trying to change a process or an order a vision or direction. The other kind of trap that I see is in the bottom represent, especially when you have projects and programs, aerospace is generally organized that ways and I found this, I did this, I did this and I see other people as well. But what happens you get on a project or program, you're trying to build an infrared camera for the astronauts to use to save the shuttle, right? It's pretty powerful and pretty important. And you're really faced against cost and schedule, and you're trying to rally the team to really build that camera. And you can fall into an us and them and then as the rest of the organization supply chain contracting people, human resources, basically anyone is not on your team is them. And so you kind of get this island mentality, it's us against the world. And you see that because you're just so driven, it's almost a natural tendency. And I would offer you after doing that, don't do that. If you can enlist advocates and all those organizations, but they all have a different charter than you. You're trying to do a certain thing for your project and program, but they do to. There are things they're trying to do just to help the organization, whether they be how to buy things and supply chain or on the human resources side. And so if you can get advocates and actually get them and embrace them, be that box forward to bring them in with you, you'll have so much more success. It'll be so much more graceful than just trying to pioneer it as your own, your own band of pirates as you try to implement what you're trying to do. And so you can bring, and I see it larger corporations, especially a ball even at this point those successful project managers and program managers are those that can embrace and get everyone to work for you, everyone that wants to support you. And they will, yeah, they got their own roles and constraints. And so it's often a balance, but if you can get them on your side, and get them into your vision, and get them to buy in, you'll have, I think just so much more graceful success. Okay, so, here's one of my favorite concepts of the book by Kim Scott. She was at Google and Facebook and a bunch of the high tech companies and I mentioned it earlier, but just to kind of dive into it a little deeper. It's called Radical Candor. And again, if you've ever experienced it on your project teams or maybe some of your group work, it's fantastic. And there you can challenge each other again, ideas, your plans, your schedules, your concepts and all that to get to get better. And it can be often, I know when I was a space tech with Bobby Braun and the team we had, if you walk by our office yelling, yelling was just intensity because we wanted to get better, but it wasn't personal. We'd go to dinner and have beer everywhere. There was nothing to do with personal. We were just trying to get better and that can lead to growth and making the company better every day or your or department every day. A lot of places fall into ruin sympathy where I really don't think your idea is too great for your plan. I don't think it's good, but I don't want to say anything, I want to be nice. We're just going to be nice and that's ruinous empathy, which is really, we're not attacking each other personally. So, that's good. But it's really not getting us any better. If you find yourself in an org where in the bottom two, it's probably not going to be very healthy for you because it's manipulative or it's just downright obnoxious aggression. And it's interesting and some of the work that's being done by companies and some of the high tech companies we see in our industry that are often viewed as innovative, kind of have some of that. If you see their attrition data and you look at some of the reports, it tends to fall into those bottom two categories and I offer you doesn't have to be that way. You can still be innovative and aggressive in your technology, but you can be in the radical candor space. So, you as future leaders, I would say to try to generate environment and what I think about is an org. Yeah, how do I make an environment? I've 2300 people in engineering here Paul, how do I make an environment where we can achieve radical candor? I'm not naive to think it's everywhere and it is not. But it is something we talk about. And how do we get there at all? Again, when you think about it, the base of it is you got to care about each other personally, which gets back to those earlier charts on leadership. Do you care about people? What is your interest right now on people? Do you have interested in the people in your class? You have interesting people in your own organization? How much do you really care and how much do you really study about them and their emotions and where they came from? That in the end is the understanding that allows you to achieve profound change. Well, let's go to the next chart. We'll dive into a few more concepts. Okay, so, [LAUGH] I got a couple of things about, okay, I think about this, if you're in engineering and ball aerospace rating, you're in this 2300 person or what do you want from your leader? I don't know that answer. I'm still working on it, right? But one I think a vision of the org and confidence and we know where we're going, we know where we're headed. We're moving people get better every day. Were world class, I always say we're world class engineering organization. Here, it was my vision when I took the job, my boss is Rob Strain and I said, one, we got to maintain our world class technical chops so I got to make moves whatever I can to make sure we remain world class. Two, we've got to be externally community. We want to have a presence in our aerospace community, AI AA and other organizations such as that. And then three, we got to care about the people, right? We got to be a home, in the matrix system in aerospace,, people are assigned projects and programs and they're off with a big bad program managers, right? We got to make sure we're engineering, we're a home for those people if it's not working out career moves. Sometimes it's just a style match for whatever leadership or culture there in, let's make sure they got another move to make those are the three things. And so, I talked a lot about that vision. And it still remains today after seven years, even with the growth we've had, I think I would add, and we've had the scale is part of it, but I talked a lot about the vision of the order. And a lot about thought leadership and do that in a variety of ways. Again, how effective it is, I don't know. And part of that is also making sure we have an inclusive environment. Again, not naive to think it is inclusive everywhere, but I do think we talk about it in the leadership team. And you think about, from an engineering view, my team is a series of very senior level directors and senior directors. So, that's you work up to different levels of leadership, what do they need? They don't need a lot, they know what to do. So for me, right, it's about, here's a vision, here's what I want to go, commander's intent, often that word. And then what do they need each of them? And I think about them each individually what they need, where they are, their leadership journey, where they are and their experience, where they are with their group and department. What challenges do they face and how can I help, right. And certainly staying out of the way. And it's trying not to micromanage but yet give direction and vision about where we're going. So, a couple quotes, you've all heard that before without vision people are impaired. So, again, as a leader, I think having that vision of being articulate about it is really key and getting people to buy into that the inclusive environment that gets to the culture. And again, you can have all the strategy and vision you want, but you probably heard that phrase before as well in the end, the culture and the environment you have will dictate the progress you make. And then the other thing that's taken me a while is on this last point, you can have a strategy and here's what we want to do and how to go, how do you translate that into specific actions? Otherwise it is kind of just hallucination, right? And so, that was taking me a while. I have a game plan, I've used it for years, it's kind of like a one trick pony for me, but it worked. I usually come up with initiatives for the year, for example, for the organization, things that we want to go do that abroad, sign of owners, okay. Provide resources is what we want to do and I use that series of initiatives to try to accomplish the strategy. So we have something we could tangible think about, to make it real to make a difference and then we can look back at, after a year or whatever quarter by quarter, how're we doing? Are we moving the needle? Is it overtaken by events? This is what we want to focus on, are we getting any better in execution? Are we getting any better in, some of our environments that aren't very inclusive, having made a difference? And I'll talk about that in just a second. One of the books, extreme ownership I think was on the one of the books is Choco Will Linky, he and his counterpart of seals wrote a book on leadership if you're interested. I thought was really interesting, very storytelling format, but he has just this incredible story about, there are no bad teams, only leaders. And if you don't believe me read the book and he has examples of that in the still training. Taking teams that were bad performing teams and all they did was change the leadership and the worst team in all the competitions that they do and their training became the best. How can that be? It's really illustrated. So, think about that, the leadership does matter and that gets me to the strategy and things you want to change. What moves does one make when you're running the 2300 person organization? What moves do you have? And I think about it this way, there's kind of three moves that I get to make. If there's something I want to go do, I can change the organization. Maybe you don't have the right reporting structure. We're not organized the right way, we're organized by disciplines, maybe that's not the right idea. Maybe we should have an organization focused on ground systems because we never had one before. Maybe we should have an organization focused on spacecraft development because we didn't have one. Maybe that's the move, maybe it's the right order but you have to change the leadership. Maybe if things aren't working out well, maybe you don't have the right person in the lead role. Or maybe the third one is well, maybe that's all both of those are good, but you don't have the right groups talking to each other. You're missing things because in our ground support development for example, we We don't have the people who write the requirements from the ground support and the people who implement them, they're not even talking to each other. Those are the three moves you get to make, you can change the leadership, you can change the Oregon, you can change kind of economics, it's about all I get to do. The challenge of course, is figuring out what move is to make. And if you've ever seen an org where and this is the everything I found right. If you see if there's drama or people are unhappy and there's a lot of churn. It's generally because one of these isn't right and if you make a move and you guess wrong, and for example, you change the leader, but the org is still not right, you'll still end up in turn. So it's hard I find to find which move is it to make? Once you figure that out making the move is it's hard. I mean, changing things is hard, but the real hard part is the assessment piece and that's what I found we had a problem in one of our areas, we were just turning on this particular area, we weren't delivered for cost and schedule, it was continually not good. And in the end it was, well, it was actually all three, but first was changing the leader because the leader didn't have a rate vision or the construct that even get us to be better. Once I changed the leader, it took nine months to change actually the person, the new leader changed the org, divided it differently and develop new products, new roles, responsibilities. And it just took now over a year and a half where we're finally beginning to see results since moved out. So that's the other thing is the timeframe for these kinds of things in these orgs is often slow. Now, it is a start up for smaller company maybe not so much, you can move a lot quicker. But I think that the principles kind of still remain and that's something I think to kind of think about and that assessment is really key to figure out which one to make the other thing got off. >> Yeah, quick question. So as a leader you have a vision mission in terms of where you want to grow in the next few years or for a long time. Is it fair to have a financial vision, let's say you're doing maybe 15 million now. You want to grow in three years, 100 million. How do you, is that fair to have and if you do, how do you communicate and translate to all your team? What are your thoughts on that? >> I said yeah, It's a really good question and certainly many companies do and almost everybody has a growth plan, right, grow or die. However, I think I have seen, I know at our company and there's books by Simon Sinek and others will tell you. It's good to have those goals, those are outcomes. And what I've seen on the good leadership would be, you can set the outcomes where you want to be. But at the end, what you have to work on is how to get there and that's the internal, that's the machinery, that's the people, that's the processes, that's the why we do what we do and really that it's like a team that focuses on the score. They want to win the game. How do you win the game you score more points? Okay. That does not help me, you figure out how to score more points. That's what I amounted to, John Hayes, our corporate COO often says he hardly ever talks about the outcomes. The outcomes will come from the result of what you want to do in your org and your vision, your strategy, that's what you got, that's what you can change. That's what you can make and the outcomes will be what they will be. So they're important. But I don't think they can be the driving force. And many Simon Sinek will say any companies whose mission and vision is to make more money, you can hardly, it hardly ever works. There has to be something more than that. Yeah, good question. Let's go to my last, I think it's my last one two again, a couple more comments. >> second last one, yeah, this is D and I. >> Okay, D and I Alright. Yeah. Okay, so one thing is the technical organization I wanted to hit on is technical acumen, right? You get this question a lot. You have street cred can you be what if you don't have subject matter expertise, can you lead that organization? And again, I would suggest the answer is yes. Although if you have a good understanding of whatever the technical or you're in, it does help with your assessments, your intuition, you need less data. I don't get a lot of data at this level, so you have to kind of into it and if you've been there before, you can kind of go, okay, I know what this means or I've seen this before, or I'm pretty sure I know what this means. That's part of it. And it does help for many leaders if you, establish your street credibility. Whether you're an expert in that field can help, advocates can go help, if you're new to that or to establish that street credibility and it is, I think more of an art than a science in terms of leading technical organizations. However, I don't think it's absolutely mandatory and there's certainly, you don't need a PhD in these technical fields. There's many leaders at my level who do not, it's not a requirement by any stretch. The other topic I get is, Authenticity and trying to be off and this is where if you've been through, especially if you have street credit or you've been through that experience. You can speak to it from kind of an authentic point of view because, you can kind of basically understand where people are coming from. And that's where I think about it. I mean I built and developed systems. I think I know what that means to be on the program team. And I think I'm trying to relate to people from that kind of level thinking about it from their lens, thinking about it from their angle. So that's a few words a little bit on authenticity. Both of these are, kind of hard and you can't just turn it on to make it happen. But it is something to think about in your career, to establishing both. And let me get to this last chart and and my last one, I didn't want it to be last because it's one of the most important, is diversity and inclusion. And it's a topic and there's a maturity model if you want to measure it. Deloitte and Touche, I think put this together, kind of really like it. You can measure it as an org where you're at. I think it's absolutely essential, especially on the inclusion part. And again, we talked about all the opinions and make an inclusive environment. Why would you want people to feel they can bring their whole self to work everyday. Wouldn't that make for a better organized team? And there's lots of thoughts and lots of work on this. I would say the following, for everybody here. This is the number one question. I use the screen out candidates for leadership in the engineering orange. You won't believe how much this question tells me everything I need to know. I just asked as the leader of this organ in this new role, what's your D and I gameplan? I can tell within about 15 seconds whether they have one, whether they've ever thought about it, whether they had any game plan at all about what they're going to do because it's important value for us in most companies it is now. And if the person hasn't thought about what that means, what they're going to do to make it more inclusive and it can't just be while I'm diverse, that's my game plan. That's not a game plan. That's interesting and it's probably good, but it's not. And so I would offer all of you to think about, what is your game, what's your move be articulate about D and I. What would you do, what are the actions you would take? How would you be a thought leader? There are things that you can go do to make that better for the organization, at least I know it's a goal that would be key. But my other comment on this is and I just heard this talk. So I put it here because I, this guy Steve Robbins. If you ever heard of, you can find him on, I put a link in but you can find him on. Hope you guys know how to do that on. Just amazing. I heard him two weeks ago and he talks about inclusion and he gets back to the brain and the vision, it's actually right. Just like we talked about for emotional intelligence. It's the reptilian brain and the contextual brain. And while we want to be with our tribe, why that's more comfortable for all of us? It's a natural thing of evolution about why that is and the things that we can do to be open minded and curious right to open up the aperture and not resort to our natural bias about I want to be with people like me. I want to be with my tribe lots there to talk about. I won't have time tonight. But if you get a chance, one of the best things I've ever seen in terms of specifically on the inclusion piece and I think that any leaders and are going forward in today's world this while we didn't have a lot of time on it is essential. >> So how do you hold individuals accountable? Especially leaders accountable to have a D E I Strategy. Because it is, it's personal and I've seen multiple things that say, you know you can tell me your strategy, you can tell me what you want to do. But numbers, retention, demographics tell the story. >> Yeah that's a really good thing. I think we all wrestle with that. So we measure too, we look at data but you gotta be careful with that too. We talk about that right? It's not quotas, it's a nuanced thing when you think about diversity at least for us. So holding people accountable in a way that, I think we measure to see how we're doing, we don't use it for rewards or system like that. I think the studies have shown that leads to unintentional consequences that are not good. So, what we talk about, what you can talk about is people's actions. Are they intentional about it or they articulate about it? Do they message it? I think not necessarily a numbers game as much as it is a person's approach to the topic? And really it folds right into our inclusive environment? So the diversity pieces, one piece of it. But are they curious, are they open minded, are they bringing an inclusive, are they working to make an inclusive environment or their department. That's where some of the things that we look for. And so, you got to give everybody a chance to continue to grow. >> AlI right, Mike, we're going to let you go back to your event, and I can't believe that you gave us this time. Thank you so much. >> Congratulations everyone.

redpajama_set_name: RedPajamaCommonCrawl


text:
Exports reached $2.3 billion for the first time in a decade
Modified date: April 2, 2021
Pakistan's exports totaled a decade of $ 2.3 billion in March, with monthly figures showing year-over-year growth, trade advisers said Thursday.
"The Commerce Department is proud to announce that preliminary figures show that our exports rose to $ 2.345 billion in March 2021. This is an increase of 13.4% from February 2021. This is the highest monthly figure in the last 10 years.", Razak Dowd, wrote on Twitter.
"It is also the first time since 2011 that exports have surpassed the $ 2 billion mark for the sixth consecutive month."
However, trade advisers called the annual growth misleading because last year's blockade made the industry's wheels very slow. "The 29.3% export growth from March 2020 should not be considered misleading because there was a deadlock last year," said Dowd.
Read More: According to Abbasi, Imran Khan will no longer be Prime Minister because the cabinet refuses the summary
For the nine-month period from July to March of the current fiscal year, exports rose 7% to $ 18.6 billion, compared with $ 17.4 billion in the same period last year, according to the Commerce Department.
Exports are expected to be disrupted by a shortage of cotton, the textile industry's main industrial import, which accounts for more than 60 percent of total exports.
The government is unsure whether to give the green light to imports of cotton and yarn from India, the world's largest cotton producer. Analysts said the growth of the textile industry was linked to cotton imports from India to offset the country's textile exports.
Read more: SHC approves the distribution of the Sputnik V vaccine in Pakistan


text:
Jon Edney
(President/CEO)
Mr. Edney is a founding member of the bank. He has served on the Board of Directors since the bank's inception and previously served as Chairman of the Board. Mr. Edney has had a 30 year career in asset management and sales. He has previously served the community as Grand Jury Foreman, member of the El Centro Regional Medical Center Board of Trustees, member of the El Centro Elementary School Board, and as Mayor and council member for the city of El Centro.
Toni Umphreyville
(Chief Financial Officer)
Ms. Umphreyville's operations and financial management resume spans over thirty years in banking. For over twenty years she has served as both a Chief Financial Officer (CFO) and Chief Operating Officer (COO) specifically in the Community Banking industry. She has performed the duties of CFO and COO in Orange County, San Diego County and now in the Imperial Valley. She also spent six years of her banking career in the data processing field that provided software systems to financial institutions. Ms. Umphreyville has been with Community Valley Bank (CVB) since April 2010. She began her career at CVB as a Consultant in April 2010 and became the CFO in September 2010. Her responsibilities at CVB include the oversight of; Accounting, Operations, Information Technology, BSA, Compliance and Human Resource Departments.
Kevin Ardolf
(Chief Credit Officer)
Mr. Ardolf has over 30 years of experience in community banking. Most recently Mr. Ardolf was the President/CEO of Sutter Community Bank in Yuba City CA. He previously was the Chief Credit Officer at Seacoast Commerce Bank in Chula Vista CA; Gold Country Bank in Marysville CA; and Woodland Bank in Remer MN. He has also been a bank auditor, bank regulator, and loan officer. In addition, Mr. Ardolf served active duty with the United States Marine Corps and received his Bachelor's degree from National University in San Diego, and his MBA degree from the University of Minnesota, Minneapolis.
© 2010 Community Valley Bank. Member FDIC. Equal Housing Lender. Contact Us | Locations | Privacy Policy | 2015 Schedule of Fees


text:
MallPosts
which series are on the program for the 2022 edition?
September 15, 2022 by Dana Florian
Netflix has just shared the program for its TUDUM, a conference for fans around the world.
For the second consecutive year, Netflix invites its subscribers around the world for a special conference. The TUDUM, in reference to the iconic introduction of the original programs, will bring together many actors from your favorite series and films. There will be a lot of people to believe the trailer shared yesterday by the firm of Reed Hastings.
We should thus have news of The Witcher, the series worn by Henry Cavill. The British actor also invites himself into the trailer. We also meet the cast of Shadow & Bonethe teenage saga adapted from the novels Grisha. Enola Holmes 2 as well as Red Notice 2 should also give their news.
Lupine, Bridgerton and Stranger Things …
Netflix has many projects on the go. As the year 2022 slowly comes to an end, the platform is already tackling the 2023 program. Netflix TUDUM should therefore be full of announcements for fans of original series and films. We can also see some of the platform's flagship licenses, starting with Stranger Things which prepares its conclusion.
David Harbour, Joe Keery, Finn Wolfhard, Sadie Sink and Gaten Matarazzo will be in the game, they should briefly address the fifth and final season of the Duffer brothers' series. On the other hand, they could be stingy with details, the release not being definitively for now.
It should also be noted that Rian Johnson, the director ofAt Knives Out, will present the continuation of the adventures of Benoit Blanc before the release scheduled for the end of year celebrations. If not, we should have news of The Bridgerton Chronicle. While filming is in full swing, the actors should give us some clues about the plot that will unfold during this third season.
And on the side of France, Omar Sy is visibly preparing his next move. The actor starring in Lupine concludes the presentation video. The French series has established itself across the globe as one of the most viewed, it's a safe bet that season 3 occupies a good place in this program of celebrations. Remember that it does not yet have a release date.
Where and when ?
The TUDUM event will be available on Netflix YouTube channels and in 29 languages. This year, not one, but 5 events are on the program. We should thus be entitled to conferences entirely dedicated to South Korean, Indian and Japanese productions. Europe and the United States will share the most important event, broadcast at 7:00 p.m. in France.
It's trash war between humans and cockatoos every day in Australia
Scientists are looking into the question of cheat meals
all about this project that is revolutionizing the connected home
the editing of RAW files will soon be managed… by another app
the brand is reinventing itself (finally)
a new reference saga? 🔎
© 2023 MallPosts • Built with GeneratePress


Facebook declared a new version of its Messenger chat app builds for children ages six to twelve. The app is named Messenger Kids. The new app does not need facebook account due to federal law, users under the age of 13 cannot legally signup for Facebook. Facebook is introducing the app today in preview with a limited rollout of iOS.
Facebook mentions that it going to take great measures to make sure the app does not come off as exploitative. "There are no ads in Messenger Kids and your child's information isn't used for ads. It is free to download and there are no in-app purchases," the company said.
Messenger Kids is a free video calling and messaging app designed for kids to connect with close friends and family from their tablet or smartphone. Kids can only connect with parent-approved contacts, which creates a more controlled environment.
Parents fully control the contact list and decide who can connect with their children. Messages don't disappear and can't be hidden in case parents would like to check in.
Kid-appropriate masks, frames, stickers, and GIFs spark conversation and laughter. With the feature-filled camera, kids can create fun videos and decorate photos to share moments with loved ones. Playful masks, emojis, and sound effects bring conversations to life.
Download the Messenger Kids app on your child's iPad, iPod touch, or iPhone from the App Store.
Secondly, authenticate your child's device using your own Facebook username and password. This will not create a Facebook account for your child or give them access to your Facebook account.
Thirdly, finish the setup process by creating an account for your child, where all you'll need to do is provide their name.
Finally, add people to your child's approved contact list, go to the Messenger Kids parental controls panel on your main Facebook app. To get there, click on "More" in the bottom right corner in your main Facebook app, and click "Messenger Kids" in the Explore section.


text:
Q: Has every set a universal map with respect to the "squaring functor"? Exercise $26C$ of Herrlich & Strecker Category theory asks to show the following:

Show that every set has a universal map with respect to the "squaring functor".

Recall that a universal map with respect to an object $B\in \mathcal B$ and a functor $F:\mathcal A\rightarrow \mathcal B$ is a pair $(\eta_B,A_B)$ where $\eta_B:B\rightarrow F(A_B)$ and $A_B$ is an object of $\mathcal A$ such that for any object $A'$ of $\mathcal A$ and any morphism $f:B\rightarrow F(A')$, there exists a unique $\overline{f}:A_B\rightarrow A$ such that $f=F(\overline{f})\circ \eta_B$.
The squaring functor, $()^2:$Set$\rightarrow$ Set, is defined by $(A)^2=A\times A$ and $(f)^2=f\times f$.
I tried to do this with $A_B=B$ and $\eta_B:B\rightarrow B\times B$ given by $\eta_B(b)=(b,b)$, where $B$ is any set, but with no success.
I would like to get hints to prove this exercise.
Thanks

A: Hint: Try to understand what happens in the case where B is a singleton.
Answer: You should take $A_B=B\sqcup B$ and $\eta_B(b)=((b,1),(b,2))$.
Let X be a set, $f\colon B\to X\times X$ - mapping, such that $f(b)=(f_1(b),f_2(b))$. Then $\overline f\colon B\sqcup B\to X$ defined by $\overline f(b,i)=f_i(b)$ for $i=1,2$. It's easy to check that $(\overline f\times\overline f)\circ\eta_B=f$ and $\overline f$ is a unique map with this property.
Actually, it works in arbitrary category with finite products and coproducts. The main idea is that two morphisms $f_1,f_2\colon a\to b$ determine morphism $a\to b\times b$ as well as morphism $a\sqcup a\to b$.

redpajama_set_name: RedPajamaStackExchange