text:
#include "tm_stm32f4_pwm.h"

/* Private functions */
void TM_PWM_INT_EnableClock(TIM_TypeDef* TIMx);
TM_PWM_Result_t TM_PWM_INT_GetTimerProperties(TIM_TypeDef* TIMx, uint32_t* frequency, uint32_t* period);

TM_PWM_Result_t TM_PWM_INT_InitTIM1Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM2Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM3Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM4Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM5Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM8Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM9Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM10Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM11Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM12Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM13Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);
TM_PWM_Result_t TM_PWM_INT_InitTIM14Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack);

TM_PWM_Result_t TM_PWM_InitTimer(TIM_TypeDef* TIMx, TM_PWM_TIM_t* TIM_Data, double PWMFrequency) {
	TIM_TimeBaseInitTypeDef TIM_BaseStruct;
	TM_TIMER_PROPERTIES_t Timer_Data;

	/* Check valid timer */
	if (0
#ifdef TIM6
		|| TIMx == TIM6
#endif
#ifdef TIM7
		|| TIMx == TIM7
#endif
	) {
		/* Timers TIM6 and TIM7 can not provide PWM feature */
		return TM_PWM_Result_TimerNotValid;
	}

	/* Save timer */
	TIM_Data->TIM = TIMx;

	/* Get timer properties */
	TM_TIMER_PROPERTIES_GetTimerProperties(TIMx, &Timer_Data);

	/* Check for maximum timer frequency */
	if (PWMFrequency > Timer_Data.TimerFrequency) {
		/* Frequency too high */
		return TM_PWM_Result_FrequencyTooHigh;
	} else if (PWMFrequency == 0) {
		/* Not valid frequency */
		return TM_PWM_Result_FrequencyTooLow;
	}

	/* Generate settings */
	TM_TIMER_PROPERTIES_GenerateDataForWorkingFrequency(&Timer_Data, PWMFrequency);

	/* Check valid data */
	if (Timer_Data.Period == 0) {
		/* Too high frequency */
		return TM_PWM_Result_FrequencyTooHigh;
	}

	/* Tests are OK */
	TIM_Data->Frequency = PWMFrequency;
	TIM_Data->Micros = 1000000 / PWMFrequency;
	TIM_Data->Period = Timer_Data.Period;
	TIM_Data->Prescaler = Timer_Data.Prescaler;

	/* Enable clock for Timer */
	TM_TIMER_PROPERTIES_EnableClock(TIMx);

	/* Set timer options */
	TIM_BaseStruct.TIM_Prescaler = Timer_Data.Prescaler - 1;
	TIM_BaseStruct.TIM_CounterMode = TIM_CounterMode_Up;
	TIM_BaseStruct.TIM_Period = Timer_Data.Period - 1;
	TIM_BaseStruct.TIM_ClockDivision = TIM_CKD_DIV1;
	TIM_BaseStruct.TIM_RepetitionCounter = 0;

	/* Initialize timer */
	TIM_TimeBaseInit(TIMx, &TIM_BaseStruct);

	/* Preload enable */
	TIM_ARRPreloadConfig(TIMx, ENABLE);

	if (0
#ifdef TIM1
		|| TIMx == TIM1
#endif
#ifdef TIM8
		|| TIMx == TIM8
#endif
	) {
		/* Enable PWM outputs */
		TIM_CtrlPWMOutputs(TIMx, ENABLE);
	}

	/* Start timer */
	TIMx->CR1 |= TIM_CR1_CEN;

	/* Set default values */
	TIM_Data->CH_Init = 0;

	/* Return OK */
	return TM_PWM_Result_Ok;
}

TM_PWM_Result_t TM_PWM_InitChannel(TM_PWM_TIM_t* TIM_Data, TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
#ifdef TIM1
	if (TIM_Data->TIM == TIM1) {
		return TM_PWM_INT_InitTIM1Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM2
	if (TIM_Data->TIM == TIM2) {
		return TM_PWM_INT_InitTIM2Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM3
	if (TIM_Data->TIM == TIM3) {
		return TM_PWM_INT_InitTIM3Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM4
	if (TIM_Data->TIM == TIM4) {
		return TM_PWM_INT_InitTIM4Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM5
	if (TIM_Data->TIM == TIM5) {
		return TM_PWM_INT_InitTIM5Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM8
	if (TIM_Data->TIM == TIM8) {
		return TM_PWM_INT_InitTIM8Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM9
	if (TIM_Data->TIM == TIM9) {
		return TM_PWM_INT_InitTIM9Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM10
	if (TIM_Data->TIM == TIM10) {
		return TM_PWM_INT_InitTIM10Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM11
	if (TIM_Data->TIM == TIM11) {
		return TM_PWM_INT_InitTIM11Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM12
	if (TIM_Data->TIM == TIM12) {
		return TM_PWM_INT_InitTIM12Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM13
	if (TIM_Data->TIM == TIM13) {
		return TM_PWM_INT_InitTIM13Pins(Channel, PinsPack);
	}
#endif
#ifdef TIM14
	if (TIM_Data->TIM == TIM14) {
		return TM_PWM_INT_InitTIM14Pins(Channel, PinsPack);
	}
#endif

	/* Timer is not valid */
	return TM_PWM_Result_TimerNotValid;
}

TM_PWM_Result_t TM_PWM_SetChannel(TM_PWM_TIM_t* TIM_Data, TM_PWM_Channel_t Channel, uint32_t Pulse) {
	TIM_OCInitTypeDef TIM_OCStruct;
	uint8_t ch = (uint8_t)Channel;

	/* Check pulse length */
	if (Pulse >= TIM_Data->Period) {
		/* Pulse too high */
		return TM_PWM_Result_PulseTooHigh;
	}

	/* Common settings */
	TIM_OCStruct.TIM_Pulse = Pulse;
	TIM_OCStruct.TIM_OCMode = TIM_OCMode_PWM2;
	TIM_OCStruct.TIM_OutputState = TIM_OutputState_Enable;
	TIM_OCStruct.TIM_OCPolarity = TIM_OCPolarity_Low;

	/* Save pulse value */
	TIM_Data->CH_Periods[ch] = Pulse;

	/* Go to bits */
	ch = 1 << ch;

	/* Select proper channel */
	switch (Channel) {
		case TM_PWM_Channel_1:
			/* Check if initialized */
			if (!(TIM_Data->CH_Init & ch)) {
				TIM_Data->CH_Init |= ch;

				/* Init channel */
				TIM_OC1Init(TIM_Data->TIM, &TIM_OCStruct);
				TIM_OC1PreloadConfig(TIM_Data->TIM, TIM_OCPreload_Enable);
			}

			/* Set pulse */
			TIM_Data->TIM->CCR1 = Pulse;
			break;
		case TM_PWM_Channel_2:
			/* Check if initialized */
			if (!(TIM_Data->CH_Init & ch)) {
				TIM_Data->CH_Init |= ch;

				/* Init channel */
				TIM_OC2Init(TIM_Data->TIM, &TIM_OCStruct);
				TIM_OC2PreloadConfig(TIM_Data->TIM, TIM_OCPreload_Enable);
			}

			/* Set pulse */
			TIM_Data->TIM->CCR2 = Pulse;
			break;
		case TM_PWM_Channel_3:
			/* Check if initialized */
			if (!(TIM_Data->CH_Init & ch)) {
				TIM_Data->CH_Init |= ch;

				/* Init channel */
				TIM_OC3Init(TIM_Data->TIM, &TIM_OCStruct);
				TIM_OC3PreloadConfig(TIM_Data->TIM, TIM_OCPreload_Enable);
			}

			/* Set pulse */
			TIM_Data->TIM->CCR3 = Pulse;
			break;
		case TM_PWM_Channel_4:
			/* Check if initialized */
			if (!(TIM_Data->CH_Init & ch)) {
				TIM_Data->CH_Init |= ch;

				/* Init channel */
				TIM_OC4Init(TIM_Data->TIM, &TIM_OCStruct);
				TIM_OC4PreloadConfig(TIM_Data->TIM, TIM_OCPreload_Enable);
			}

			/* Set pulse */
			TIM_Data->TIM->CCR4 = Pulse;
			break;
		default:
			break;
	}

	/* Return everything OK */
	return TM_PWM_Result_Ok;
}

TM_PWM_Result_t TM_PWM_SetChannelPercent(TM_PWM_TIM_t* TIM_Data, TM_PWM_Channel_t Channel, float percent) {
	/* Check input value */
	if (percent > 100) {
		return TM_PWM_SetChannel(TIM_Data, Channel, TIM_Data->Period);
	} else if (percent <= 0) {
		return TM_PWM_SetChannel(TIM_Data, Channel, 0);
	}

	/* Set channel value */
	return TM_PWM_SetChannel(TIM_Data, Channel, (uint32_t)((float)(TIM_Data->Period - 1) * percent) / 100);
}

TM_PWM_Result_t TM_PWM_SetChannelMicros(TM_PWM_TIM_t* TIM_Data, TM_PWM_Channel_t Channel, uint32_t micros) {
	/* If we choose too much micro seconds that we have valid */
	if (micros > TIM_Data->Micros) {
		/* Too high pulse */
		return TM_PWM_Result_PulseTooHigh;
	}

	/* Set PWM channel */
	return TM_PWM_SetChannel(TIM_Data, Channel, (uint32_t)((TIM_Data->Period - 1) * micros) / TIM_Data->Micros);
}

/* Private functions */
TM_PWM_Result_t TM_PWM_INT_InitTIM1Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_8, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOE
					TM_GPIO_InitAlternate(GPIOE, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOE
					TM_GPIO_InitAlternate(GPIOE, GPIO_PIN_10, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_3:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_10, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOE
					TM_GPIO_InitAlternate(GPIOE, GPIO_PIN_13, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_4:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_11, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOE
					TM_GPIO_InitAlternate(GPIOE, GPIO_PIN_14, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM1);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM2Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_0, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_5, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_3:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_15, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_1, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_3, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_3:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_2, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_10, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_4:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_3, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_11, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM2);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM3Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_6, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_4, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_3:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_10, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_5, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_3:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_3:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_0, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_8, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_4:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_1, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM3);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM4Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_6, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOD
					TM_GPIO_InitAlternate(GPIOD, GPIO_PIN_12, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOD
					TM_GPIO_InitAlternate(GPIOD, GPIO_PIN_13, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_3:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_8, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOD
					TM_GPIO_InitAlternate(GPIOD, GPIO_PIN_14, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_4:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOD
					TM_GPIO_InitAlternate(GPIOD, GPIO_PIN_15, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM4);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM5Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_0, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOH
					TM_GPIO_InitAlternate(GPIOH, GPIO_PIN_10, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_1, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOH
					TM_GPIO_InitAlternate(GPIOH, GPIO_PIN_11, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_3:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_2, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOH
					TM_GPIO_InitAlternate(GPIOH, GPIO_PIN_12, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_4:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_3, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOI
					TM_GPIO_InitAlternate(GPIOI, GPIO_PIN_0, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM5);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM8Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_6, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOI
					TM_GPIO_InitAlternate(GPIOI, GPIO_PIN_5, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOI
					TM_GPIO_InitAlternate(GPIOI, GPIO_PIN_6, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_3:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_8, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOI
					TM_GPIO_InitAlternate(GPIOI, GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_4:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOC
					TM_GPIO_InitAlternate(GPIOC, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOI
					TM_GPIO_InitAlternate(GPIOI, GPIO_PIN_8, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM8);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM9Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_2, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM9);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOE
					TM_GPIO_InitAlternate(GPIOE, GPIO_PIN_5, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM9);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_3, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM9);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOE
					TM_GPIO_InitAlternate(GPIOE, GPIO_PIN_6, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM9);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM10Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_8, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM10);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOF
					TM_GPIO_InitAlternate(GPIOF, GPIO_PIN_6, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM10);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM11Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM11);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOF
					TM_GPIO_InitAlternate(GPIOF, GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM11);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM12Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_14, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM12);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOH
					TM_GPIO_InitAlternate(GPIOH, GPIO_PIN_6, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM12);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		case TM_PWM_Channel_2:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOB
					TM_GPIO_InitAlternate(GPIOB, GPIO_PIN_15, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM12);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOH
					TM_GPIO_InitAlternate(GPIOH, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM12);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM13Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_1, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM13);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOF
					TM_GPIO_InitAlternate(GPIOF, GPIO_PIN_8, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM13);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}

TM_PWM_Result_t TM_PWM_INT_InitTIM14Pins(TM_PWM_Channel_t Channel, TM_PWM_PinsPack_t PinsPack) {
	TM_PWM_Result_t result = TM_PWM_Result_PinNotValid;

	switch (Channel) {
		case TM_PWM_Channel_1:
			switch (PinsPack) {
				case TM_PWM_PinsPack_1:
#ifdef GPIOA
					TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM14);
					result = TM_PWM_Result_Ok;
#endif
					break;
				case TM_PWM_PinsPack_2:
#ifdef GPIOF
					TM_GPIO_InitAlternate(GPIOF, GPIO_PIN_9, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AF_TIM14);
					result = TM_PWM_Result_Ok;
#endif
					break;
				default:
					result = TM_PWM_Result_PinNotValid;
					break;
			}
			break;
		default:
			result = TM_PWM_Result_ChannelNotValid;
			break;
	}

	return result;
}


text:
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('scenario',{
    name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    status: {
       type:   DataTypes.ENUM,
       values: ['Passed', 'Failed', 'Skipped']
    },
    feature: {
         type: DataTypes.STRING(2000)
    },
  },{
      tableName: 'scenarios',
    classMethods: {

    },
    instanceMethods: {
    }
  });
};

redpajama_set_name: RedPajamaGithub


text:
(function($) {

    'use strict';

    var pInstance = 'Flexcomplete.instance',
        pData = 'Flexcomplete.data',
        KEY_DO_SEARCH = 11111,
        KEY_ENTER = 13,
        KEY_TO_LEFT = 37,
        KEY_TO_RIGHT = 39,
        KEY_TO_UP = 38,
        KEY_TO_DOWN = 40,
        KEY_BACKSPACE = 8,
        KEY_INSERT = 45,
        KEY_DELETE = 46,
        KEY_SHIFT = 16,
        KEY_CTRL = 17,
        KEY_PAGE_UP = 33,
        KEY_PAGE_DOWN = 34,
        KEY_ESC = 27,
        KEY_TAB = 9,
        KEY_HOME = 36,
        KEY_END = 35,
        choosingClick = function(event) {

            var $el = $(createEvent(event).target),
                inst = $el.closest('.flexcomplete-parent').data(pInstance);

            if (typeof inst !== 'undefined') {

                inst.onSelect($el.data(pData), inst.$input.get(0));

                if (inst.isOpened()) {
                    inst.close();
                }
            }
        },
        mouseOver = function(event) {

            var $el = $(event.target);
            ($el.is('.flexcomplete-line') ? $el : $el.find('.flexcomplete-line:first')).addClass("active");
        },
        mouseOut = function(event) {

            var $el = $(event.target);
            ($el.is('.flexcomplete-line') ? $el : $el.find('.flexcomplete-line:first')).removeClass("active");
        },
        gainFocus = function(inst, event) {

            schedule(inst, createEvent(event));
        },
        looseFocus = function(inst, event) {

            if (inst.isOpened()) {
                if (inst._debug !== true) {
                    inst.close(createEvent(event));
                }
            }
        },
        isNavigation = function(e) {

            var k = e.ascii;
            return k === KEY_TO_UP || k === KEY_TO_DOWN || k === KEY_TO_LEFT ||
                k === KEY_TO_RIGHT || k === KEY_ENTER || k === KEY_PAGE_UP ||
                k === KEY_PAGE_DOWN || k === KEY_ESC || k === KEY_HOME || k === KEY_END;
        },
        drawChildren = function(inst, filteredDataArray) {

            var i = 0,
                leni = filteredDataArray.length;

            inst.parentEl.empty();

            for (; i < leni; i++) {

                var data = filteredDataArray[i],
                    line = inst.getLine(data),
                    divLine = $("

").append(line);

                inst.children[i] = divLine
                    .data(pData, data)
                    .append(divLine)
                    .mousedown(choosingClick)
                    .mouseover(mouseOver)
                    .mouseout(mouseOut);

                inst.parentEl.append(inst.children[i]);
            }

            return inst;
        },
        drawParent = function(inst, filteredDataArray) {

            var position = inst.$input.offset(),
                altura = inst.$input.outerHeight();

            inst.children = [];
            inst.parentIndex = -1;

            if (typeof inst.parentEl !== 'undefined') {
                inst.parentEl.remove();
            }

            inst.parentEl = $('

')
                .css({
                    display: 'none',
                    top: (position.top + altura) + 'px',
                    left: position.left + 'px',
                    width: inst.width + 'px'
                })
                .data(pInstance, inst);

            $('body').append(inst.parentEl);

            if (filteredDataArray && filteredDataArray.length) {

                for (var i = 0, leni = filteredDataArray.length; i < leni; i++) {
                    inst.children.push(filteredDataArray[i]);
                }

                inst.parentEl.show();

                drawChildren(inst, filteredDataArray).open();

            } else {

                inst.parentEl.hide();
            }

            if (inst.children.length === 1 && inst.selectIfOneResult === true) {

                inst.onSelect(inst.children[0].data(pData), inst.$input.get(0));

                if (inst.isOpened()) {
                    inst.close();
                }
            }
        },
        search = function(inst, value) {

            if (typeof inst.interval !== 'undefined') {
                clearInterval(inst.interval);
            }

            if (typeof value !== 'string') {
                return;
            }

            if ((inst.scheduler || {}).executed === true) {
                return;
            }

            if (value.length < inst.startIn) {

                if (inst.isOpened()) {
                    inst.close();
                }

                return;
            }

            var deferred = $.Deferred(),
                _params = {},
                _headers = {};

            _params[inst.queryVar] = inst.processInput(value);

            if (typeof inst.params === 'object') {

                $.each(inst.params, function(key, param) {
                    _params[key] = $.isFunction(param) ? param() : param;
                });

            } else if (typeof inst.params === 'function') {

                $.each(inst.params(inst), function(key, param) {
                    _params[key] = $.isFunction(param) ? param() : param;
                });

            } else if (typeof inst.params !== 'undefined') {

                deferred.reject("Extra params should be an object, function or undefined");
                return deferred.promise();
            }

            if (typeof inst.headers === 'object') {

                $.each(inst.headers, function(key, param) {
                    _headers[key] = $.isFunction(param) ? param() : param;
                });

            } else if (typeof inst.headers === 'function') {

                $.each(inst.headers(inst), function(key, param) {
                    _headers[key] = $.isFunction(param) ? param() : param;
                });

            } else if (typeof inst.headers !== 'undefined') {

                deferred.reject("Headers should be an object, function or undefined");
                return deferred.promise();
            }

            if (inst.staticDataSearch === true) {

                deferred.resolve(inst.filter(inst.data, value));

            } else {

                $.ajax({
                    type: (inst.httpMethod || inst.method),
                    dataType: inst.dataType,
                    url: inst.url,
                    async: true,
                    data: _params,
                    headers: _headers,
                    success: function(data, status) {
                        deferred.resolve(data);
                    },
                    error: function(jqXHR, textStatus, errorThrown) {
                        deferred.reject(textStatus + ": " + errorThrown);
                    }
                });
            }

            deferred.then(function(data) {

                if (typeof inst.scheduler === 'object') {
                    inst.scheduler.executed = true;
                }

                drawParent(inst, data);

            }, function(result) {
                if (typeof console !== 'undefined') {
                    console.error(result);
                }
            });

            return deferred.promise();
        },
        navigate = function(inst, event) {

            var key = event.ascii;

            if (key === KEY_ESC) {
                inst.close();
                return;
            }

            var oldIx = inst.parentIndex;

            if (inst.children.length >= 1) {

                if (key === KEY_TO_UP || key === KEY_TO_DOWN || key === KEY_PAGE_UP || key === KEY_PAGE_DOWN) {

                    if (key === KEY_TO_UP) {

                        inst.parentIndex = (inst.parentIndex >= 1) ? inst.parentIndex - 1 : inst.children.length - 1;

                    } else if (key === KEY_TO_DOWN) {

                        inst.parentIndex = (inst.parentIndex < inst.children.length - 1) ? inst.parentIndex + 1 : 0;

                    } else if (key === KEY_PAGE_UP) {

                        inst.parentIndex = ((inst.parentIndex - inst.jump) >= 0) ? inst.parentIndex - inst.jump : 0;

                    } else if (key === KEY_PAGE_DOWN) {

                        inst.parentIndex = ((inst.parentIndex + inst.jump) < inst.children.length) ? inst.parentIndex + inst.jump : (inst.children.length - 1);
                    }

                    hover(inst, oldIx, inst.parentIndex);

                } else if (key === KEY_ENTER) {

                    if (inst.parentIndex >= 0) {
                        inst.onSelect(inst.children[inst.parentIndex].data(pData), inst.$input.get(0));
                    }
                    if (inst.isOpened()) {
                        inst.close();
                    }

                    return;
                }
            }

            if (inst.autoReplacing === true && inst.parentIndex >= 0 && inst.children.length >= 1) {
                inst.$input.val(inst.getAutoreplacingInputValue(inst.children[inst.parentIndex].data(pData)));
            }

            inst.open();
        },
        forwardNavigation = function(inst, event) {

            event = createEvent(event);

            if (isNavigation(event) !== false) {
                navigate(inst, event);
            }
        },
        hover = function(inst, oldIx, newIx) {

            if (oldIx >= 0) {
                inst.children[oldIx]
                    .removeClass('active');
            }

            if (newIx >= 0) {
                inst.children[newIx]
                    .addClass('active');
            }
        },
        schedule = function(inst, event) {

            if (typeof event === 'undefined') {
                return false;
            }

            event = createEvent(event);

            if (isNavigation(event) !== false) {
                return false;
            }

            var value = inst.$input.val(),
                now = (new Date()).getTime();

            if (inst.scheduler && inst.scheduler.executed === true && inst.scheduler.timestamp + inst.delay < now) {

                inst.scheduler.executed = false;
                inst.scheduler.timestamp = now;

            } else {

                inst.scheduler = {
                    executed: false,
                    timestamp: now
                };
            }

            /** se for um evento de foco nao esperar tempo nenhum */
            if (event.type.toLowerCase() === "focus") {
                return search(inst, value);
            }

            if (inst.interval) {
                clearInterval(inst.interval);
            }

            inst.interval = setInterval(function() {
                search(inst, value);
            }, inst.delay);

            return true;
        },
        createEvent = function(event) {

            if (event.ascii) {
                return event;
            }

            event = $.event.fix(event || window.event);

            return {
                type: event.type,
                ascii: (event.keyCode ? event.keyCode : event.which),
                target: $(event.target).get(0)
            };
        };

    function Flexcomplete() {
        return this;
    }

    $.extend(Flexcomplete.prototype, {

        extend: function() {

            $.extend.apply(this, [].prototype.slice.call(arguments));
        },

        load: function(o) {

            var inst = this;

            o = $.extend({}, $.flexcomplete.options, o);

            for (var i in o) {
                this[i] = o[i] || null;
            }

            this._debug = false;
            this.staticDataSearch = typeof this.data !== 'undefined';

            if (!this.staticDataSearch && (!this.url || $.trim(this.url) === '')) {
                throw new Error("No database set. Please, set the offline data or an url");
            }

            this.width = typeof this.width !== 'undefined' && this.width !== null ? this.width : this.$input.outerWidth();

            this.children = [];
            this.parentIndex = -1;
            this.params = this.params || this.extraParams;

            // if (typeof this.$input.data(pInstance) === 'undefined') {
            //     this.$input.data(pInstance, this);
            // }

            this.$input.attr('autocomplete', 'off');

            this.$input
                .bind('keyup.Flexcomplete', function(e) {
                    schedule(inst, e);
                })
                .bind('keydown.Flexcomplete', function(e) {
                    forwardNavigation(inst, e);
                })
                .bind('focus.Flexcomplete', function(e) {
                    gainFocus(inst, e);
                })
                .bind('blur.Flexcomplete', function(e) {
                    looseFocus(inst, e);
                });

            return this;
        },

        select: function(index) {

            if (typeof index === 'undefined') {
                return;
            }

            var object = (this.children || [])[index];

            if (typeof object === 'undefined') {
                return;
            }

            this.onSelect(object, this.$input.get(0));
        },

        close: function(event) {

            if (typeof this.parentEl !== 'undefined') {
                this.parentEl.hide();
            }

            this.opened = false;
        },

        open: function() {

            this.opened = true;

            if (typeof this.parentEl !== 'undefined') {
                this.parentEl.show();
            }
        },

        isOpened: function() {

            return this.opened;
        },

        search: function(searchQuery) {

            if (typeof searchQuery === 'string' && $.trim(searchQuery) !== '') {

                return search(this, searchQuery);

            } else {

                return schedule(this, {
                    type: 'keyup',
                    target: this.$input,
                    ascii: KEY_DO_SEARCH
                });
            }
        },

        staticData: function(d) {

            if (typeof d !== 'undefined') {
                this.data = d;
            }

            return this.data;
        },

        sdata: function(d) {
            return this.staticData(d);
        },

        debug: function(enable) {
            this._debug = enable;
        },

        unload: function() {

            this.close();
            this.$input.unbind('keyup.Flexcomplete', schedule);
            this.$input.unbind('keydown.Flexcomplete', forwardNavigation);
            this.$input.unbind('focus.Flexcomplete', gainFocus);
            this.$input.unbind('blur.Flexcomplete', looseFocus);

            if (typeof this.parentEl !== 'undefined') {
                this.parentEl.empty();
                this.parentEl.remove();
            }

            this.$input.removeData(pInstance);
        }
    });

    $.fn.flexcomplete = function(options) {

        //this.reReplace = /([\]^\${}|!@#\*\-+()\'.\[\\])/g;

        var inst = $(this).data(pInstance),
            opt, flex;

        var args = Array.prototype.slice.call(arguments, 1);

        if (typeof options === 'string') {

            if (/open|close|search|select|unload|staticData|extend|sdata|debug/.test(options)) {

                return inst[options].apply(inst, args);

            } else {

                if (console) {
                    console.warn('No such ' + options + ' command found');
                }
            }
        } else {

            return this.each(function(i, item) {

                if (typeof $(this).data(pInstance) === 'undefined') {

                    if (typeof options === 'object') {

                        flex = new Flexcomplete();
                        opt = {};

                        $.each(options, function(i, item) {
                            opt[i] = item;
                        });
                        opt.$input = $(this);

                        flex.load(opt);
                        $(this).data(pInstance, flex);
                    }
                }

                return this;
            });
        }
    };

    $.fn.unflexcomplete = function() {

        return this.each(function() {

            var instance = $(this).data(pInstance);

            if (typeof instance === 'object') {
                instance.unload();
            }

            return this;
        });
    };

    // Static method.
    $.flexcomplete = function(options) {
        // Override default options with passed-in options.
        options = $.extend({}, $.flexcomplete.options, options);
        // Return something awesome.
        return 'awesome' + options.punctuation;
    };

    // Static method default options.
    $.flexcomplete.options = {
        queryVar: "q",
        dataType: "json",
        httpMethod: "GET",
        processInput: function(value) {
            return value;
        },
        onSelect: function(value, input) {
            input.value = value;
        },
        getLine: function(value) {
            return value;
        },
        getAutoreplacingInputValue: function(value) {
            return value;
        },
        matches: function(value, userSearch, re) {

            if (typeof re === 'undefined') {
                re = new RegExp(userSearch.replace($.fn.flexcomplete.reReplace, ''), "i");
            }

            return re.test(value);
        },
        filter: function(arr, userSearch) {

            var inst = this;
            userSearch = userSearch.tagName === 'INPUT' ? $(userSearch).val() : userSearch;

            var re = new RegExp(userSearch.replace($.fn.flexcomplete.reReplace, ''), "i");

            return arr.filter(function(item) {
                return this.matches(item, userSearch, re);
            }, this);
        },
        delay: 100,
        jump: 6,
        startIn: 1,
        width: null,
        selectIfOneResult: false,
        params: {},
        headers: {},
        autoReplacing: false
    };

    // Custom selector.
    $.expr[':'].flexcomplete = function(elem) {
        // Is this element awesome?
        return $(elem).text().indexOf('awesome') !== -1;
    };

}(jQuery));


text:
package Nov2020_UberPrep;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class _009ReconstuctItinerary {

	public static void main(String[] args) {

		System.out.println(findItinerary(new ArrayList<List<String>>(Arrays.asList(
				new ArrayList<String>(Arrays.asList("MUC", "LHR")), new ArrayList<String>(Arrays.asList("JFK", "MUC")),
				new ArrayList<String>(Arrays.asList("SFO", "SJC")),
				new ArrayList<String>(Arrays.asList("LHR", "SFO"))))));

		System.out.println(findItinerary(new ArrayList<List<String>>(Arrays.asList(
				new ArrayList<String>(Arrays.asList("JFK", "SFO")), new ArrayList<String>(Arrays.asList("JFK", "ATL")),
				new ArrayList<String>(Arrays.asList("SFO", "ATL")), new ArrayList<String>(Arrays.asList("ATL", "JFK")),
				new ArrayList<String>(Arrays.asList("ATL", "SFO"))))));

		System.out.println(findItinerary(new ArrayList<List<String>>(Arrays.asList(
				new ArrayList<String>(Arrays.asList("JFK", "KUL")), new ArrayList<String>(Arrays.asList("JFK", "NRT")),
				new ArrayList<String>(Arrays.asList("NRT", "JFK"))))));

	}

	public static List<String> findItinerary(List<List<String>> tickets) {
		HashMap<String, List<String>> map = new HashMap<String, List<String>>();
		for (List<String> pair : tickets) {
			String source = pair.get(0);
			String destination = pair.get(1);
			if (map.containsKey(source)) {
				map.get(source).add(destination);
			} else {
				List<String> list = new ArrayList<String>();
				list.add(destination);
				map.put(source, list);
			}
		}

		List<List<String>> output = new ArrayList<List<String>>();
		List<String> list = new ArrayList<String>();
		list.add("JFK");
		dfs("JFK", 1, map, list, output, tickets.size() + 1, new HashSet<List<String>>());
		Collections.sort(output, new Comparator<List<String>>() {

			@Override
			public int compare(List<String> o1, List<String> o2) {
				for (int i = 0; i < o1.size(); i++) {
					if (o1.get(i).compareTo(o2.get(i)) != 0)
						return o1.get(i).compareTo(o2.get(i));
				}

				return 0;
			}
		});
		return output.get(0);
	}

	public static void dfs(String startPoint, int currcount, HashMap<String, List<String>> map, List<String> list,
			List<List<String>> output, int maxCount, Set<List<String>> set) {
		if (list.size() == maxCount) {
			if (!set.contains(list)) {
				output.add(new ArrayList<String>(list));
				set.add(list);
			}
			return;
		}

		List<String> neighbors = map.get(startPoint);
		if (neighbors != null)
			for (int i = 0; i < neighbors.size(); i++) {
				String nextDestination = neighbors.get(i);
				map.get(startPoint).remove(String.valueOf(nextDestination));
				list.add(nextDestination);
				dfs(nextDestination, currcount + 1, map, list, output, maxCount, set);
				list.remove(list.size() - 1);
				map.get(startPoint).add(i, String.valueOf(nextDestination));
			}
	}

}


text:
<?php

class Google_Service_ToolResults_NonSdkApiUsageViolationReport extends Google_Collection
{
  protected $collection_key = 'exampleApis';
  protected $exampleApisType = 'Google_Service_ToolResults_NonSdkApi';
  protected $exampleApisDataType = 'array';
  public $minSdkVersion;
  public $targetSdkVersion;
  public $uniqueApis;

  /**
   * @param Google_Service_ToolResults_NonSdkApi[]
   */
  public function setExampleApis($exampleApis)
  {
    $this->exampleApis = $exampleApis;
  }
  /**
   * @return Google_Service_ToolResults_NonSdkApi[]
   */
  public function getExampleApis()
  {
    return $this->exampleApis;
  }
  public function setMinSdkVersion($minSdkVersion)
  {
    $this->minSdkVersion = $minSdkVersion;
  }
  public function getMinSdkVersion()
  {
    return $this->minSdkVersion;
  }
  public function setTargetSdkVersion($targetSdkVersion)
  {
    $this->targetSdkVersion = $targetSdkVersion;
  }
  public function getTargetSdkVersion()
  {
    return $this->targetSdkVersion;
  }
  public function setUniqueApis($uniqueApis)
  {
    $this->uniqueApis = $uniqueApis;
  }
  public function getUniqueApis()
  {
    return $this->uniqueApis;
  }
}


text:
layout: post
title:  "Incendiary Cloud"
date:   2015-01-10
source: PHB.253
tags:   [sorcerer, wizard, level8, conjuration]
---

**8th-level conjuration**

**Casting Time**: 1 action

**Range**: 150 feet

**Components**: V, S

**Duration**: Concentration, up to 1 minute

A swirling cloud of smoke shot through with white-hot embers appears in a 20-foot-range. The cloud spreads around corners and is heavily obscured. It lasts for the duration or until a wind of moderate or greater speed (at least 10 miles per hour) disperses it.

When the cloud appears, each creature in it must make a Dexterity saving throw. A creature takes 10d8 fire damage on a failed save, or half as much damage on a successful one. A creature must also make this saving throw when it enters the spell's area for the first time on a turn or ends its turn there.

The cloud moves 10 feet directly away from you in a direction that you choose at the start of each of your turns.


text:
"""
==========================
Testing automatic examples
==========================

This will produce a simple image.
"""

import numpy as np
import matplotlib.pyplot as plt

np.random.seed(42)

plt.plot(np.random.randn(1000))
plt.show()


text:
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"

#include <memory>

#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/graphics/bitmap_image.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_canvas.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record.h"
#include "third_party/blink/renderer/platform/graphics/path.h"
#include "third_party/blink/renderer/platform/testing/font_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/text/text_run.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkShader.h"

namespace blink {
namespace {

#define EXPECT_EQ_RECT(a, b)       \
  EXPECT_EQ(a.x(), b.x());         \
  EXPECT_EQ(a.y(), b.y());         \
  EXPECT_EQ(a.width(), b.width()); \
  EXPECT_EQ(a.height(), b.height());

#define EXPECT_OPAQUE_PIXELS_IN_RECT(bitmap, opaqueRect)          \
  {                                                               \
    for (int y = opaqueRect.y(); y < opaqueRect.bottom(); ++y)    \
      for (int x = opaqueRect.x(); x < opaqueRect.right(); ++x) { \
        int alpha = *bitmap.getAddr32(x, y) >> 24;                \
        EXPECT_EQ(255, alpha);                                    \
      }                                                           \
  }

#define EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, opaqueRect) \
  {                                                           \
    for (int y = 0; y < bitmap.height(); ++y)                 \
      for (int x = 0; x < bitmap.width(); ++x) {              \
        int alpha = *bitmap.getAddr32(x, y) >> 24;            \
        bool is_opaque = opaqueRect.Contains(x, y);           \
        EXPECT_EQ(is_opaque, alpha == 255);                   \
      }                                                       \
  }

AutoDarkMode AutoDarkModeDisabled() {
  return AutoDarkMode(DarkModeFilter::ElementRole::kBackground, false);
}

TEST(GraphicsContextTest, Recording) {
  SkBitmap bitmap;
  bitmap.allocN32Pixels(100, 100);
  bitmap.eraseColor(0);
  SkiaPaintCanvas canvas(bitmap);

  auto paint_controller = std::make_unique<PaintController>();
  GraphicsContext context(*paint_controller);

  Color opaque = Color::FromRGBA(255, 0, 0, 255);

  context.BeginRecording();
  context.FillRect(gfx::RectF(0, 0, 50, 50), opaque, AutoDarkModeDisabled(),
                   SkBlendMode::kSrcOver);
  canvas.drawPicture(context.EndRecording());
  EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, gfx::Rect(0, 0, 50, 50))

  context.BeginRecording();
  context.FillRect(gfx::RectF(0, 0, 100, 100), opaque, AutoDarkModeDisabled(),
                   SkBlendMode::kSrcOver);
  // Make sure the opaque region was unaffected by the rect drawn during
  // recording.
  EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, gfx::Rect(0, 0, 50, 50))

  canvas.drawPicture(context.EndRecording());
  EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, gfx::Rect(0, 0, 100, 100))
}

TEST(GraphicsContextTest, UnboundedDrawsAreClipped) {
  SkBitmap bitmap;
  bitmap.allocN32Pixels(400, 400);
  bitmap.eraseColor(0);
  SkiaPaintCanvas canvas(bitmap);

  Color opaque = Color::FromRGBA(255, 0, 0, 255);
  Color transparent = Color::kTransparent;

  auto paint_controller = std::make_unique<PaintController>();
  GraphicsContext context(*paint_controller);
  context.BeginRecording();

  context.SetShouldAntialias(false);
  context.SetMiterLimit(1);
  context.SetStrokeThickness(5);
  context.SetLineCap(kSquareCap);
  context.SetStrokeStyle(kSolidStroke);

  // Make skia unable to compute fast bounds for our paths.
  DashArray dash_array;
  dash_array.push_back(1);
  dash_array.push_back(0);
  context.SetLineDash(dash_array, 0);

  // Make the device opaque in 10,10 40x40.
  context.FillRect(gfx::RectF(10, 10, 40, 40), opaque, AutoDarkModeDisabled(),
                   SkBlendMode::kSrcOver);
  canvas.drawPicture(context.EndRecording());
  EXPECT_OPAQUE_PIXELS_ONLY_IN_RECT(bitmap, gfx::Rect(10, 10, 40, 40));

  context.BeginRecording();
  // Clip to the left edge of the opaque area.
  context.Clip(gfx::Rect(10, 10, 10, 40));

  // Draw a path that gets clipped. This should destroy the opaque area, but
  // only inside the clip.
  Path path;
  path.MoveTo(gfx::PointF(10, 10));
  path.AddLineTo(gfx::PointF(40, 40));
  cc::PaintFlags flags;
  flags.setColor(transparent.Rgb());
  flags.setBlendMode(SkBlendMode::kSrcOut);
  context.DrawPath(path.GetSkPath(), flags, AutoDarkModeDisabled());

  canvas.drawPicture(context.EndRecording());
  EXPECT_OPAQUE_PIXELS_IN_RECT(bitmap, gfx::Rect(20, 10, 30, 40));
}

class GraphicsContextDarkModeTest : public testing::Test {
 protected:
  void SetUp() override {
    bitmap_.allocN32Pixels(4, 1);
    bitmap_.eraseColor(0);
    canvas_ = std::make_unique<SkiaPaintCanvas>(bitmap_);
    paint_controller_ = std::make_unique<PaintController>();
  }

  void DrawColorsToContext(bool is_dark_mode_on,
                           const DarkModeSettings& settings) {
    GraphicsContext context(*paint_controller_);
    if (is_dark_mode_on)
      context.UpdateDarkModeSettingsForTest(settings);
    context.BeginRecording();
    context.FillRect(gfx::RectF(0, 0, 1, 1), Color::kBlack,
                     AutoDarkMode(DarkModeFilter::ElementRole::kBackground,
                                  is_dark_mode_on));
    context.FillRect(gfx::RectF(1, 0, 1, 1), Color::kWhite,
                     AutoDarkMode(DarkModeFilter::ElementRole::kBackground,
                                  is_dark_mode_on));
    context.FillRect(gfx::RectF(2, 0, 1, 1), Color::FromSkColor(SK_ColorRED),
                     AutoDarkMode(DarkModeFilter::ElementRole::kBackground,
                                  is_dark_mode_on));
    context.FillRect(gfx::RectF(3, 0, 1, 1), Color::FromSkColor(SK_ColorGRAY),
                     AutoDarkMode(DarkModeFilter::ElementRole::kBackground,
                                  is_dark_mode_on));
    // Capture the result in the bitmap.
    canvas_->drawPicture(context.EndRecording());
  }

  SkBitmap bitmap_;
  std::unique_ptr<SkiaPaintCanvas> canvas_;
  std::unique_ptr<PaintController> paint_controller_;
};

// This is a baseline test where dark mode is turned off. Compare other variants
// of the test where dark mode is enabled.
TEST_F(GraphicsContextDarkModeTest, DarkModeOff) {
  DarkModeSettings settings;

  DrawColorsToContext(false, settings);

  EXPECT_EQ(SK_ColorBLACK, bitmap_.getColor(0, 0));
  EXPECT_EQ(SK_ColorWHITE, bitmap_.getColor(1, 0));
  EXPECT_EQ(SK_ColorRED, bitmap_.getColor(2, 0));
  EXPECT_EQ(SK_ColorGRAY, bitmap_.getColor(3, 0));
}

// Simple invert for testing. Each color component |c|
// is replaced with |255 - c| for easy testing.
TEST_F(GraphicsContextDarkModeTest, SimpleInvertForTesting) {
  DarkModeSettings settings;
  settings.mode = DarkModeInversionAlgorithm::kSimpleInvertForTesting;
  settings.contrast = 0;

  DrawColorsToContext(true, settings);

  EXPECT_EQ(SK_ColorWHITE, bitmap_.getColor(0, 0));
  EXPECT_EQ(SK_ColorBLACK, bitmap_.getColor(1, 0));
  EXPECT_EQ(SK_ColorCYAN, bitmap_.getColor(2, 0));
  EXPECT_EQ(0xff777777, bitmap_.getColor(3, 0));
}

// Invert brightness (with gamma correction).
TEST_F(GraphicsContextDarkModeTest, InvertBrightness) {
  DarkModeSettings settings;
  settings.mode = DarkModeInversionAlgorithm::kInvertBrightness;
  settings.contrast = 0;

  DrawColorsToContext(true, settings);

  EXPECT_EQ(SK_ColorWHITE, bitmap_.getColor(0, 0));
  EXPECT_EQ(SK_ColorBLACK, bitmap_.getColor(1, 0));
  EXPECT_EQ(SK_ColorCYAN, bitmap_.getColor(2, 0));
  EXPECT_EQ(0xffe1e1e1, bitmap_.getColor(3, 0));
}

// Invert lightness (in HSL space).
TEST_F(GraphicsContextDarkModeTest, InvertLightness) {
  DarkModeSettings settings;
  settings.mode = DarkModeInversionAlgorithm::kInvertLightness;
  settings.contrast = 0;

  DrawColorsToContext(true, settings);

  EXPECT_EQ(SK_ColorWHITE, bitmap_.getColor(0, 0));
  EXPECT_EQ(SK_ColorBLACK, bitmap_.getColor(1, 0));
  EXPECT_EQ(SK_ColorRED, bitmap_.getColor(2, 0));
  EXPECT_EQ(0xffe1e1e1, bitmap_.getColor(3, 0));
}

TEST_F(GraphicsContextDarkModeTest, InvertLightnessPlusContrast) {
  DarkModeSettings settings;
  settings.mode = DarkModeInversionAlgorithm::kInvertLightness;
  settings.contrast = 0.2;

  DrawColorsToContext(true, settings);

  EXPECT_EQ(SK_ColorWHITE, bitmap_.getColor(0, 0));
  EXPECT_EQ(SK_ColorBLACK, bitmap_.getColor(1, 0));
  EXPECT_EQ(SK_ColorRED, bitmap_.getColor(2, 0));
  EXPECT_EQ(0xfff1f1f1, bitmap_.getColor(3, 0));
}

}  // namespace
}  // namespace blink


text:
require 'twilio-ruby'

# Get your Account Sid and Auth Token from https://www.twilio.com/console
api_key_sid = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
api_key_secret = 'your_api_key_secret'

client = Twilio::REST::Client.new api_key_sid, api_key_secret

participant_recordings = client.video.recordings
                               .list(grouping_sid: 'ParticipantSid')

participant_recordings.each do |recording|
  puts recording.sid
end


text:
from django.contrib import admin
from myblog.models import Entry, Tag
from django.db.models import TextField
from django_markdown.admin import MarkdownModelAdmin
from django_markdown.widgets import AdminMarkdownWidget

class EntryAdmin(MarkdownModelAdmin):
    # ref:https://github.com/arocks/qblog
    list_display = ('title', 'created')
    prepopulated_fields = {'slug': ('title',)}
    # http://arunrocks.com/recreating-the-building-a-blog-in-django-screencast/
    # python2.x should add this
    formfield_overrides = {TextField: {'widget': AdminMarkdownWidget}}

# this is interesting, sync slug with title, when inputting in title
# by javascript
admin.site.register(Entry, EntryAdmin)
admin.site.register(Tag)


text:
package org.apache.nifi.remote.protocol;

import java.io.IOException;
import java.io.InputStream;

public interface CommunicationsInput {

    /**
     * Reads all data currently on the socket and throws it away
     *
     * @throws IOException if unable to consume
     */
    void consume() throws IOException;

    InputStream getInputStream() throws IOException;

    long getBytesRead();
}


text:
package resumeonline.jfx.core.ui.component.splashscreen;

import javafx.concurrent.Task;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import resumeonline.jfx.core.JFXFramework;

public final class SplashScreenPane
    extends
    VBox {

    public SplashScreenPane(
        final Stage stage,
        final ImageView img,
        final Stage next,
        final Task<?> task) {
        VBox root = new VBox();
        root.setFillWidth(true);
        Label text = new Label("Carregando...");
        JFXFramework.set(text).centerAlignment();
        setFillWidth(true);

        VBox centerLine = new VBox();
        centerLine.setAlignment(Pos.CENTER);
        centerLine.getStyleClass().add("box-border-red");
        centerLine.setFillWidth(true);
        ProgressBar bar = new ProgressBar();
        bar.prefWidthProperty().bind(root.widthProperty().subtract(20));
        centerLine.getChildren().add(bar);

        root.getChildren().addAll(img, centerLine, text);
        JFXFramework.set(this).addAllChildren(root).style(getLabelStyle()).dropShowEffect();
        if (task != null) {
            bar.progressProperty().bind(task.progressProperty());
            task.stateProperty().addListener(new StageChangeListener(this, stage, bar, next));
        }
    }

    private String getLabelStyle() {
        StringBuilder builder = new StringBuilder();
        builder.append(" -fx-padding: 5; ");
        builder.append(" -fx-background-color: cornsilk; ");
        builder.append(" -fx-border-width:5; ");
        builder.append(" -fx-border-color: ");
        builder.append(" linear-gradient(to bottom, chocolate, derive(chocolate, 50%));");
        return builder.toString();
    }
}


text:
package com.byteslounge.slickrepo.test.sqlserver

import com.byteslounge.slickrepo.test.{LocalDateTimeVersionedRepositoryTest, SQLServerConfig}

class SQLServerLocalDateTimeVersionedRepositoryTest extends LocalDateTimeVersionedRepositoryTest(SQLServerConfig.config)


text:
static unsigned int solutions_found = 0;

static bool print_solution(const struct il_solution *s, void *thunk) {
  char buf[IL_SOLUTION_PRINT_MAX];
  if (!il_solution_print(s, buf, sizeof(buf))) {
    fprintf(stderr, "Failed to print solution\n");
    exit(1);
  }
  printf("-- SOLUTION --\n%s\n", buf);
  ++solutions_found;
  return true;
}

int main(void) {
  char buf[1024];
  size_t len = fread(buf, 1, sizeof(buf) - 1, stdin);
  buf[len] = '\0';

  struct il_problem p;
  if (!il_problem_parse(buf, &p)) {
    fprintf(stderr, "Failed to parse input\n");
    return 1;
  }

  il_problem_solve(&p, print_solution, NULL);

  printf("-- FOUND %u SOLUTIONS --\n", solutions_found);
  return 0;
}


text:
import datetime

from google.cloud import storage
import pandas as pd
import torch
from torch.utils.data import Dataset
from torch.utils.data import DataLoader
from torch.utils.data import random_split
from torch.utils.data.sampler import SubsetRandomSampler

import metadata

class CSVDataset(Dataset):
    def __init__(self, args, csv_files, device, transform=None):
        """
        Args:
            args: arguments passed to the python script
            csv_files (list): Path to the list of csv files with annotations.
            transform (callable, optional): Optional transform to be applied
                on a sample.
        """
        self.dataframe = None
        for csv_file in csv_files:
            if self.dataframe is None:
                self.dataframe = pd.read_csv(csv_file, header=0)
            else:
                self.dataframe = pd.concat(
                    [self.dataframe, pd.read_csv(csv_file, header=0)])
        self.device = device
        self.transform = transform

        # Convert the categorical columns in place to a numerical category
        # Example: Payment_Type =
        #       ['Credit Card' 'Cash' 'No Charge' 'Dispute' 'Unknown']
        # Converted: Payment_Type = [0, 1, 2, 3, 4]
        if args.embed_categorical_columns:
            for category in metadata.CATEGORICAL_COLUMNS:
                self.dataframe[category].replace(
                    {val: i for i, val in enumerate(
                        self.dataframe[category].unique())},
                    inplace=True)

    def __len__(self):
        return len(self.dataframe)

    def __getitem__(self, idx):
        # When retrieving an item from the dataset, get the features and the
        # target. In this template, the target is 0th column and the features
        # are all the other columns.
        features = self.dataframe.iloc[idx, 1:].values
        target = self.dataframe.iloc[idx, :1].values

        # Load the data as a tensor
        item = {
            'features': torch.from_numpy(features).to(self.device),
            'target': torch.from_numpy(target).to(self.device)
        }

        if self.transform:
            item = self.transform(item)

        return item

def load_data(args, device):
    """Loads the data into three different data loaders. (Train, Test, Evaluation)
        Split the training dataset into a train / test dataset.

        Args:
            args: arguments passed to the python script
    """
    train_dataset = CSVDataset(args, args.train_files, device)
    eval_dataset = CSVDataset(args, args.eval_files, device)
    # Determine the size of the dataset and the train/test sets
    dataset_size = len(train_dataset)
    test_size = int(args.test_split * dataset_size)
    train_size = dataset_size - test_size

    # Use random_split to get the split indices for the train/test set
    train_dataset, test_dataset = random_split(train_dataset,
                                               [train_size, test_size])

    # Use the subset random sampler for the dataloader to know which
    # parts of the dataset belong to the train/test set
    # Note: use `tolist()` to convert the indices tensor to a list or
    # enumerating over the DataLoader will fail.
    train_sampler = SubsetRandomSampler(train_dataset.indices)
    test_sampler = SubsetRandomSampler(test_dataset.indices)

    # Create the data loaders with the train/test sets.
    train_loader = DataLoader(
        train_dataset.dataset,
        batch_size=args.batch_size,
        sampler=train_sampler)
    test_loader = DataLoader(
        test_dataset.dataset,
        batch_size=args.batch_size,
        sampler=test_sampler)
    # Create data loader with the eval set
    eval_loader = DataLoader(
        eval_dataset,
        batch_size=args.batch_size)

    return train_loader, test_loader, eval_loader

def save_model(args):
    """Saves the model to Google Cloud Storage

    Args:
      args: contains name for saved model.
    """
    scheme = 'gs://'
    bucket_name = args.job_dir[len(scheme):].split('/')[0]

    prefix = '{}{}/'.format(scheme, bucket_name)
    bucket_path = args.job_dir[len(prefix):].rstrip('/')

    datetime_ = datetime.datetime.now().strftime('model_%Y%m%d_%H%M%S')

    if bucket_path:
        model_path = '{}/{}/{}'.format(bucket_path, datetime_, args.model_name)
    else:
        model_path = '{}/{}'.format(datetime_, args.model_name)

    bucket = storage.Client().bucket(bucket_name)
    blob = bucket.blob(model_path)
    blob.upload_from_filename(args.model_name)


text:
Provenance for the World Bank Gross Domestic Product data table, imported into the UDC from the World Development Indicators data set.

Steps:

 * The file `ny.gdp.mktp.cd_Indicator_en_csv_v2.csv` contains the original data downloaded from the [World Bank GDP (current US$) page](http://data.worldbank.org/indicator/NY.GDP.MKTP.CD).
 * The script `preprocess.js` generates the output data table `../GDP_current_USD.csv` from the original data.


text:
@interface FMWriteVideoController ()<FMWVideoViewDelegate>
@property (nonatomic, strong)FMWVideoView *videoView;
@end

@implementation FMWriteVideoController

- (BOOL)prefersStatusBarHidden{
    return YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.navigationController.navigationBar.hidden = YES;

    _videoView  =[[FMWVideoView alloc] initWithFMVideoViewType:Type1X1];
    _videoView.delegate = self;
    [self.view addSubview:_videoView];
    self.view.backgroundColor = [UIColor blackColor];

}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if (_videoView.fmodel.recordState == FMRecordStateFinish) {
        [_videoView.fmodel reset];
    }
}

- (void)dismissVC
{
    [self.navigationController dismissViewControllerAnimated:YES completion:nil];
}

- (void)recordFinishWithvideoUrl:(NSURL *)videoUrl
{
    FMVideoPlayController *playVC = [[FMVideoPlayController alloc] init];
    playVC.videoUrl =  videoUrl;
    [self.navigationController pushViewController:playVC animated:YES];
}

@end


text:
package version

import (
	api "github.com/containerd/containerd/api/services/version/v1"
	"github.com/containerd/containerd/plugin"
	ctrdversion "github.com/containerd/containerd/version"
	ptypes "github.com/gogo/protobuf/types"
	"golang.org/x/net/context"
	"google.golang.org/grpc"
)

var _ api.VersionServer = &service{}

func init() {
	plugin.Register(&plugin.Registration{
		Type:   plugin.GRPCPlugin,
		ID:     "version",
		InitFn: initFunc,
	})
}

func initFunc(ic *plugin.InitContext) (interface{}, error) {
	return &service{}, nil
}

type service struct {
}

func (s *service) Register(server *grpc.Server) error {
	api.RegisterVersionServer(server, s)
	return nil
}

func (s *service) Version(ctx context.Context, _ *ptypes.Empty) (*api.VersionResponse, error) {
	return &api.VersionResponse{
		Version:  ctrdversion.Version,
		Revision: ctrdversion.Revision,
	}, nil
}


text:
const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');

describe('Settings Content API', function () {
    let agent;

    before(async function () {
        agent = await agentProvider.getContentAPIAgent();
        await fixtureManager.init('api_keys');
        agent.authenticate();
    });

    it('Can request settings', async function () {
        await agent.get('settings/')
            .expectStatus(200)
            .matchHeaderSnapshot()
            .matchBodySnapshot();
    });
});


text:
RSWebSocket - A highly-conformant WebSocket Client Framework
============================================================

Prerequistes
------------
 * Developed and tested on OS X 10.7 (Lion) and 10.8 (Mountain Lion), and may work on OS X 10.6 (Snow Leopard).
 * Tightly-coupled to Tavendo GmbH's AutobahnPython (http://autobahn.ws/python) for unit testing, and our examples.
 * Intended to work under iOS (currently untested).

Features
--------
 * Asynchronous networking
 * ARC-enabled
 * No weak refs

Untested
--------
 * Speed (proper queuing and asynchronicity)
 * SSL
 * iOS support

After cloning repository
------------------------
git submodule init

git submodule update


text:
namespace asdf
{
    using namespace util;

    render_target_t::render_target_t(uint32_t width, uint32_t height)
    : fbo{}
    , texture{"render_target_t texture", nullptr, width, height}
    {
        ASSERT(!CheckGLError(), "GL Error Creating Render Target");
    }

    void render_target_t::init()
    {
        ASSERT(!CheckGLError(), "GL Error **Before** Initializing Render Target");

        GL_State->init_render_target(fbo, texture);

        ASSERT(!CheckGLError(), "GL Error Initializing Render Target");
    }

    /// I'm not entirely sure why these functions return true if there's an error, but whatever

    bool CheckShader(GLuint shader)
    {
        GLint glStatus;
        glGetShaderiv(shader, GL_COMPILE_STATUS, &glStatus);

        if(glStatus == GL_FALSE)
        {
            GLint error_length = 0;
            glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &error_length);

            ASSERT(error_length >= 0, "Invalid GL Error Length");

            std::string gl_error_str(size_t(error_length), '\n');
            glGetShaderInfoLog(shader, error_length, nullptr, &(gl_error_str[0]));

            fprintf(stderr, "Failed to compile shader!\n%s\n", gl_error_str.data());
            return true;
        }

        return false;
    }

    bool CheckGLError(GLuint shader)
    {
        bool had_error = false;

        if(shader != nullindex)
        {
            had_error = CheckShader(shader);
        }

        GLenum errCode = GL_NO_ERROR;

        while((errCode = glGetError()) != GL_NO_ERROR)
        {
            const GLubyte *errString;
            errString = gluErrorString(errCode);
            fprintf(stderr, "OpenGL Error: %s\n", errString);
            had_error = true;
        }

        return had_error;
    }

    bool CheckGLError(){ return CheckGLError(0xFFFFFFFF); }

    bool check_attrib_error()
    {
        return CheckGLError();
    }
}


text:
title: Peter Hosey
date: '2014-01-06'
duration: '1:39:13'
description:
categories: [Design]
tags: [UserInterface]
episode_number: 114
attachments: ["NSBrief_114_Peter_Hosey.m4a"]
url: /114-peter-hosey
---

Peter Hosey ([@boredzo](http://twitter.com/boredzo)) is a Mac programmer. His credits include working on the Adium chat client. In this episode, we talk to Peter about a talk he gave at the MacTech Conference in LA and discuss things make a great user interface.

## Show Notes
- [Hosey Warnings Blog Post](http://boredzo.org/blog/archives/2009-11-07/warnings)
- [Adium](http://adium.im)
- [Steve Jobs Demonstrating NextStep3.0](https://www.youtube.com/watch?v=uESZnGGsLAE)
- [Action! The world's First Dynamic Interface Builder](https://vimeo.com/62618532)
- [DBKit](http://www.kevra.org/TheBestOfNext/NeXTProducts/NeXTSoftware/DBKit/DBKit.html)
- [Don't Make Me Think 3rd Edition](http://www.amazon.com/Dont-Make-Think-Revisited-Usability/dp/0321965515/ref=dp_ob_title_bk)
- [New Windows Explorer UI](http://www.usabilitypost.com/2011/08/29/new-windows-explorer-ui/)
- [Microsoft UI with all Toolbars Enabled](http://codinghorror.typepad.com/.a/6a0120a85dcdae970b0120a86d6311970b-pi)
- [Blog Post Source](http://www.codinghorror.com/blog/2006/02/sometimes-a-word-is-worth-a-thousand-icons.html)
- [Design of Everyday Things](http://www.amazon.com/Design-Everyday-Things-Revised-Expanded/dp/0465050654/ref=sr_1_1?s=books&ie=UTF8&qid=1388989955&sr=1-1&keywords=design+of+everyday+things)
- [Elements of Style](http://en.wikipedia.org/wiki/The_Elements_of_Style)
- [GEICO Caveman Commercials](http://en.wikipedia.org/wiki/GEICO_Cavemen)
- [WinForms](http://msdn.microsoft.com/en-us/library/dd30h2yb\(v=vs.110\).aspx)

{{> audio_mastered_jonathan_penn_rubber_city_wizards }}