text:
extern "C" {
	LUMIX_LIBRARY_EXPORT DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
	LUMIX_LIBRARY_EXPORT DWORD NvOptimusEnablement = 0x00000001;
}

namespace Lumix::os
{

struct EventQueue {
	struct Rec {
		Event e;
		Rec* prev;
		Rec* next = nullptr;
	};

	void pushBack(const Event& e) {
		Rec* n = LUMIX_NEW(allocator, Rec);
		n->prev = back;
		if (back) back->next = n;
		back = n;
		if (!front) front = n;
		n->e = e;
	}

	Event popFront() {
		ASSERT(front);
		Event e = front->e;
		Rec* tmp = front;
		front = tmp->next;
		if (!front) back = nullptr;
		LUMIX_DELETE(allocator, tmp);
		return e;
	}

	bool empty() const {
		return !front;
	}

	Rec* front = nullptr;
	Rec* back = nullptr;
	DefaultAllocator allocator;
};

static struct
{
	WindowHandle grabbed_window = INVALID_WINDOW;
	EventQueue event_queue;
	Point relative_mode_pos = {};
	bool relative_mouse = false;
	bool raw_input_registered = false;
	u16 surrogate = 0;
	struct {
		HCURSOR load;
		HCURSOR size_ns;
		HCURSOR size_we;
		HCURSOR size_nwse;
		HCURSOR arrow;
		HCURSOR text_input;
	} cursors;
} G;

InputFile::InputFile()
{
	m_handle = (void*)INVALID_HANDLE_VALUE;
	static_assert(sizeof(m_handle) >= sizeof(HANDLE), "");
}

OutputFile::OutputFile()
{
    m_is_error = false;
	m_handle = (void*)INVALID_HANDLE_VALUE;
	static_assert(sizeof(m_handle) >= sizeof(HANDLE), "");
}

InputFile::~InputFile()
{
	ASSERT((HANDLE)m_handle == INVALID_HANDLE_VALUE);
}

OutputFile::~OutputFile()
{
	ASSERT((HANDLE)m_handle == INVALID_HANDLE_VALUE);
}

bool OutputFile::open(const char* path)
{
	m_handle = (HANDLE)::CreateFileA(path, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
	m_is_error = INVALID_HANDLE_VALUE == m_handle;
    return !m_is_error;
}

bool InputFile::open(const char* path)
{
	m_handle = (HANDLE)::CreateFileA(path, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
	return INVALID_HANDLE_VALUE != m_handle;
}

void OutputFile::flush()
{
	ASSERT(nullptr != m_handle);
	FlushFileBuffers((HANDLE)m_handle);
}

void OutputFile::close()
{
	if (INVALID_HANDLE_VALUE != (HANDLE)m_handle)
	{
		::CloseHandle((HANDLE)m_handle);
		m_handle = (void*)INVALID_HANDLE_VALUE;
	}
}

void InputFile::close()
{
	if (INVALID_HANDLE_VALUE != (HANDLE)m_handle)
	{
		::CloseHandle((HANDLE)m_handle);
		m_handle = (void*)INVALID_HANDLE_VALUE;
	}
}

bool OutputFile::write(const void* data, u64 size)
{
	ASSERT(INVALID_HANDLE_VALUE != (HANDLE)m_handle);
	u64 written = 0;
	::WriteFile((HANDLE)m_handle, data, (DWORD)size, (LPDWORD)&written, nullptr);
	m_is_error = m_is_error || size != written;
    return !m_is_error;
}

bool InputFile::read(void* data, u64 size)
{
	ASSERT(INVALID_HANDLE_VALUE != m_handle);
	DWORD readed = 0;
	BOOL success = ::ReadFile((HANDLE)m_handle, data, (DWORD)size, (LPDWORD)&readed, nullptr);
	return success && size == readed;
}

u64 InputFile::size() const
{
	ASSERT(INVALID_HANDLE_VALUE != m_handle);
	return ::GetFileSize((HANDLE)m_handle, 0);
}

u64 InputFile::pos()
{
	ASSERT(INVALID_HANDLE_VALUE != m_handle);
	return ::SetFilePointer((HANDLE)m_handle, 0, nullptr, FILE_CURRENT);
}

bool InputFile::seek(u64 pos)
{
	ASSERT(INVALID_HANDLE_VALUE != m_handle);
	LARGE_INTEGER dist;
	dist.QuadPart = pos;
	return ::SetFilePointer((HANDLE)m_handle, dist.u.LowPart, &dist.u.HighPart, FILE_BEGIN) != INVALID_SET_FILE_POINTER;
}

static void fromWChar(Span<char> out, const WCHAR* in)
{
	const WCHAR* c = in;
	char* cout = out.begin();
	const u32 size = out.length();
	while (*c && c - in < size - 1)
	{
		*cout = (char)*c;
		++cout;
		++c;
	}
	*cout = 0;
}

template <int N> static void toWChar(WCHAR (&out)[N], const char* in)
{
	const char* c = in;
	WCHAR* cout = out;
	while (*c && c - in < N - 1)
	{
		*cout = *c;
		++cout;
		++c;
	}
	*cout = 0;
}

template <int N>
struct WCharStr
{
	WCharStr(const char* rhs)
	{
		toWChar(data, rhs);
	}

	operator const WCHAR*() const
	{
		return data;
	}

	WCHAR data[N];
};

void sleep(u32 milliseconds) { ::Sleep(milliseconds); }

static_assert(sizeof(ThreadID) == sizeof(::GetCurrentThreadId()));
ThreadID getCurrentThreadID() { return ::GetCurrentThreadId(); }

u32 getCPUsCount() {
	SYSTEM_INFO sys_info;
	GetSystemInfo(&sys_info);

	u32 num = sys_info.dwNumberOfProcessors;
	num = num > 0 ? num : 1;

	return num;
}

void logInfo() {
	DWORD dwVersion = 0;
	DWORD dwMajorVersion = 0;
	DWORD dwMinorVersion = 0;
	DWORD dwBuild = 0;

	dwVersion = GetVersion();

	dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
	dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));

	if (dwVersion < 0x80000000) dwBuild = (DWORD)(HIWORD(dwVersion));

	Lumix::logInfo("OS Version: ", u32(dwMajorVersion), ".", u32(dwMinorVersion), " (", u32(dwBuild), ")");

	SYSTEM_INFO sys_info;
	GetSystemInfo(&sys_info);
	Lumix::logInfo("Page size: ", u32(sys_info.dwPageSize));
	Lumix::logInfo("Number of processors: ", u32(sys_info.dwNumberOfProcessors));
	Lumix::logInfo("Allocation granularity: ", u32(sys_info.dwAllocationGranularity));
}

void getDropFile(const Event& event, int idx, Span<char> out)
{
	ASSERT(out.length() > 0);
	HDROP drop = (HDROP)event.file_drop.handle;
	WCHAR buffer[MAX_PATH];
	if (DragQueryFile(drop, idx, buffer, MAX_PATH))
	{
		fromWChar(out, buffer);
	}
	else
	{
		ASSERT(false);
	}
}

int getDropFileCount(const Event& event)
{
	HDROP drop = (HDROP)event.file_drop.handle;
	return (int)DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
}

void finishDrag(const Event& event)
{
	HDROP drop = (HDROP)event.file_drop.handle;
	DragFinish(drop);
}

static void UTF32ToUTF8(u32 utf32, char* utf8)
{
    if (utf32 <= 0x7F) {
        utf8[0] = (char) utf32;
    } else if (utf32 <= 0x7FF) {
        utf8[0] = 0xC0 | (char) ((utf32 >> 6) & 0x1F);
        utf8[1] = 0x80 | (char) (utf32 & 0x3F);
    } else if (utf32 <= 0xFFFF) {
        utf8[0] = 0xE0 | (char) ((utf32 >> 12) & 0x0F);
        utf8[1] = 0x80 | (char) ((utf32 >> 6) & 0x3F);
        utf8[2] = 0x80 | (char) (utf32 & 0x3F);
    } else if (utf32 <= 0x10FFFF) {
        utf8[0] = 0xF0 | (char) ((utf32 >> 18) & 0x0F);
        utf8[1] = 0x80 | (char) ((utf32 >> 12) & 0x3F);
        utf8[2] = 0x80 | (char) ((utf32 >> 6) & 0x3F);
        utf8[3] = 0x80 | (char) (utf32 & 0x3F);
	}
	else {
		ASSERT(false);
	}
}

bool getEvent(Event& event) {
	if (!G.event_queue.empty()) {
		event = G.event_queue.popFront();
		return true;
	}

	retry:
	MSG msg;
	if (!PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) return false;

	bool translate_msg = true;
	event.window = msg.hwnd;
	switch (msg.message) {
		case WM_DROPFILES:
			event.type = Event::Type::DROP_FILE;
			event.file_drop.handle = (HDROP)msg.wParam;
			break;
		case WM_QUIT:
			event.type = Event::Type::QUIT;
			break;
		case WM_CLOSE:
			event.type = Event::Type::WINDOW_CLOSE;
			break;
		case WM_SYSKEYDOWN:
			if (msg.wParam == VK_MENU) translate_msg = false;
			event.type = Event::Type::KEY;
			event.key.down = true;
			event.key.keycode = (Keycode)msg.wParam;
			break;
		case WM_SYSCOMMAND:
			if (msg.wParam != SC_KEYMENU || (msg.lParam >> 16) > 0) {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			goto retry;
		case WM_SYSKEYUP:
			event.type = Event::Type::KEY;
			event.key.down = false;
			event.key.keycode = (Keycode)msg.wParam;
			break;
		case WM_KEYDOWN:
			event.type = Event::Type::KEY;
			event.key.down = true;
			event.key.keycode = (Keycode)msg.wParam;
			break;
		case WM_KEYUP:
			event.type = Event::Type::KEY;
			event.key.down = false;
			event.key.keycode = (Keycode)msg.wParam;
			break;
		case WM_CHAR: {
			event.type = Event::Type::CHAR;
			event.text_input.utf8 = 0;
			u32 c = (u32)msg.wParam;
			if (c >= 0xd800 && c <= 0xdbff) {
				G.surrogate = (u16)c;
				goto retry;
			}

			if (c >= 0xdc00 && c <= 0xdfff) {
				if (G.surrogate) {
					c = (G.surrogate - 0xd800) << 10;
					c += (WCHAR)msg.wParam - 0xdc00;
					c += 0x10000;
				}
			}
			G.surrogate = 0;

			UTF32ToUTF8(c, (char*)&event.text_input.utf8);
			break;
		}
		case WM_INPUT: {
			HRAWINPUT hRawInput = (HRAWINPUT)msg.lParam;
			UINT dataSize;
			GetRawInputData(hRawInput, RID_INPUT, NULL, &dataSize, sizeof(RAWINPUTHEADER));
			alignas(RAWINPUT) char dataBuf[1024];
			if (dataSize == 0 || dataSize > sizeof(dataBuf)) break;

			GetRawInputData(hRawInput, RID_INPUT, dataBuf, &dataSize, sizeof(RAWINPUTHEADER));

			const RAWINPUT* raw = (const RAWINPUT*)dataBuf;
			if (raw->header.dwType != RIM_TYPEMOUSE) break;

			const RAWMOUSE& mouseData = raw->data.mouse;
			const USHORT flags = mouseData.usButtonFlags;
			const short wheel_delta = (short)mouseData.usButtonData;
			const LONG x = mouseData.lLastX, y = mouseData.lLastY;

			Event e;
			if (wheel_delta) {
				e.mouse_wheel.amount = (float)wheel_delta / WHEEL_DELTA;
				e.type = Event::Type::MOUSE_WHEEL;
				G.event_queue.pushBack(e);
			}

			if(flags & RI_MOUSE_LEFT_BUTTON_DOWN) {
				e.type = Event::Type::MOUSE_BUTTON;
				e.mouse_button.button = MouseButton::LEFT;
				e.mouse_button.down = true;
				G.event_queue.pushBack(e);
			}
			if(flags & RI_MOUSE_LEFT_BUTTON_UP) {
				e.type = Event::Type::MOUSE_BUTTON;
				e.mouse_button.button = MouseButton::LEFT;
				e.mouse_button.down = false;
				G.event_queue.pushBack(e);
			}

			if(flags & RI_MOUSE_RIGHT_BUTTON_UP) {
				e.type = Event::Type::MOUSE_BUTTON;
				e.mouse_button.button = MouseButton::RIGHT;
				e.mouse_button.down = false;
				G.event_queue.pushBack(e);
			}
			if(flags & RI_MOUSE_RIGHT_BUTTON_DOWN) {
				e.type = Event::Type::MOUSE_BUTTON;
				e.mouse_button.button = MouseButton::RIGHT;
				e.mouse_button.down = true;
				G.event_queue.pushBack(e);
			}

			if(flags & RI_MOUSE_MIDDLE_BUTTON_UP) {
				e.type = Event::Type::MOUSE_BUTTON;
				e.mouse_button.button = MouseButton::MIDDLE;
				e.mouse_button.down = false;
				G.event_queue.pushBack(e);
			}
			if(flags & RI_MOUSE_MIDDLE_BUTTON_DOWN) {
				e.type = Event::Type::MOUSE_BUTTON;
				e.mouse_button.button = MouseButton::MIDDLE;
				e.mouse_button.down = true;
				G.event_queue.pushBack(e);
			}

			if (x != 0 || y != 0) {
				e.type = Event::Type::MOUSE_MOVE;
				e.mouse_move.xrel = x;
				e.mouse_move.yrel = y;
				G.event_queue.pushBack(e);
			}

			if (G.event_queue.empty()) {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
				return false;
			}

			event = G.event_queue.popFront();

			break;
		}
		default:
			TranslateMessage(&msg);
			DispatchMessage(&msg);
			goto retry;
	}

	if (translate_msg) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	return true;
}

void destroyWindow(WindowHandle window)
{
	DestroyWindow((HWND)window);
}

Point toScreen(WindowHandle win, int x, int y)
{
	POINT p;
	p.x = x;
	p.y = y;
	::ClientToScreen((HWND)win, &p);
	Point res;
	res.x = p.x;
	res.y = p.y;
	return res;
}

void updateGrabbedMouse() {
	if (G.grabbed_window == INVALID_WINDOW) {
		ClipCursor(NULL);
		return;
	}

	RECT rect;
	GetWindowRect((HWND)G.grabbed_window, &rect);
	ClipCursor(&rect);
}

WindowHandle createWindow(const InitWindowArgs& args) {
	WCharStr<LUMIX_MAX_PATH> cls_name("lunex_window");
	static WNDCLASS wndcls = [&]() -> WNDCLASS {
		WNDCLASS wc = {};
		auto WndProc = [](HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) -> LRESULT {
			Event e;
			e.window = hWnd;
			switch (Msg)
			{
				case WM_MOVE:
					e.type = Event::Type::WINDOW_MOVE;
					e.win_move.x = (i16)LOWORD(lParam);
					e.win_move.y = (i16)HIWORD(lParam);
					G.event_queue.pushBack(e);
					updateGrabbedMouse();
					return 0;
				case WM_SIZE:
					e.type = Event::Type::WINDOW_SIZE;
					e.win_size.w = LOWORD(lParam);
					e.win_size.h = HIWORD(lParam);
					G.event_queue.pushBack(e);
					updateGrabbedMouse();
					return 0;
				case WM_CLOSE:
					e.type = Event::Type::WINDOW_CLOSE;
					G.event_queue.pushBack(e);
					if (hWnd == G.grabbed_window) G.grabbed_window = INVALID_WINDOW;
					updateGrabbedMouse();
					return 0;
				case WM_ACTIVATE:
					if (wParam == WA_INACTIVE) {
						showCursor(true);
						grabMouse(INVALID_WINDOW);
					}

					e.type = Event::Type::FOCUS;
					e.focus.gained = wParam != WA_INACTIVE;
					G.event_queue.pushBack(e);
					updateGrabbedMouse();
					break;
			}
			return DefWindowProc(hWnd, Msg, wParam, lParam);
		};

		wc.style = 0;
		wc.lpfnWndProc = WndProc;
		wc.cbClsExtra = 0;
		wc.cbWndExtra = 0;
		wc.hInstance = GetModuleHandle(NULL);
		wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
		wc.hCursor = NULL;
		wc.hbrBackground = NULL;
		wc.lpszClassName = cls_name;

		if (!RegisterClass(&wc)) {
			ASSERT(false);
			return {};
		}
		return wc;
	}();

	HWND parent_window = (HWND)args.parent;

	WCharStr<LUMIX_MAX_PATH> wname(args.name);
	DWORD style =  args.flags & InitWindowArgs::NO_DECORATION ? WS_POPUP : WS_OVERLAPPEDWINDOW ;
	DWORD ext_style = args.flags & InitWindowArgs::NO_TASKBAR_ICON ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
	const HWND hwnd = CreateWindowEx(
		ext_style,
		cls_name,
		wname,
		style,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		parent_window,
		NULL,
		wndcls.hInstance,
		NULL);
	ASSERT(hwnd);

	if (args.handle_file_drops)
	{
		DragAcceptFiles(hwnd, TRUE);
	}

	ShowWindow(hwnd, SW_SHOW);
	UpdateWindow(hwnd);

	if (!G.raw_input_registered) {
		RAWINPUTDEVICE device;
		device.usUsagePage = 0x01;
		device.usUsage = 0x02;
		device.dwFlags = RIDEV_INPUTSINK;
		device.hwndTarget = hwnd;
		BOOL status = RegisterRawInputDevices(&device, 1, sizeof(device));
		ASSERT(status);
		G.raw_input_registered = true;
	}

	return hwnd;
}

bool isKeyDown(Keycode keycode)
{
	const SHORT res = GetAsyncKeyState((int)keycode);
	return (res & 0x8000) != 0;
}

void getKeyName(Keycode keycode, Span<char> out)
{
	LONG scancode = MapVirtualKey((UINT)keycode, MAPVK_VK_TO_VSC);

	// because MapVirtualKey strips the extended bit for some keys
	switch ((UINT)keycode)
	{
		case VK_LEFT:
		case VK_UP:
		case VK_RIGHT:
		case VK_DOWN:
		case VK_PRIOR:
		case VK_NEXT:
		case VK_END:
		case VK_HOME:
		case VK_INSERT:
		case VK_DELETE:
		case VK_DIVIDE:
		case VK_NUMLOCK: scancode |= 0x100; break;
	}

	WCHAR tmp[256];
	u32 size = out.length();
	ASSERT(size <= 256 && size > 0);
	int res = GetKeyNameText(scancode << 16, tmp, size);
	if (res == 0) {
		out[0] = 0;
	}
	else {
		fromWChar(out, tmp);
	}
}

void showCursor(bool show)
{
	if (show) {
		while(ShowCursor(show) < 0);
	}
	else {
		while(ShowCursor(show) >= 0);
	}
}

void init() {
	G.cursors.arrow = LoadCursor(NULL, IDC_ARROW);
	G.cursors.text_input = LoadCursor(NULL, IDC_IBEAM);
	G.cursors.load = LoadCursor(NULL, IDC_WAIT);
	G.cursors.size_ns = LoadCursor(NULL, IDC_SIZENS);
	G.cursors.size_we = LoadCursor(NULL, IDC_SIZEWE);
	G.cursors.size_nwse = LoadCursor(NULL, IDC_SIZENWSE);
}

void setCursor(CursorType type) {
	switch (type) {
		case CursorType::DEFAULT: SetCursor(G.cursors.arrow); break;
		case CursorType::LOAD: SetCursor(G.cursors.load); break;
		case CursorType::SIZE_NS: SetCursor(G.cursors.size_ns); break;
		case CursorType::SIZE_WE: SetCursor(G.cursors.size_we); break;
		case CursorType::SIZE_NWSE: SetCursor(G.cursors.size_nwse); break;
		case CursorType::TEXT_INPUT: SetCursor(G.cursors.text_input); break;
		default: ASSERT(false); break;
	}
}

void setWindowTitle(WindowHandle win, const char* title)
{
	WCharStr<256> tmp(title);
	SetWindowText((HWND)win, tmp);
}

Rect getWindowScreenRect(WindowHandle win)
{
	RECT rect;
	GetWindowRect((HWND)win, &rect);
	return {rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top};
}

Rect getWindowClientRect(WindowHandle win)
{
	RECT rect;
	BOOL status = GetClientRect((HWND)win, &rect);
	ASSERT(status);
	return {rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top};
}

void setWindowScreenRect(WindowHandle win, const Rect& rect)
{
	MoveWindow((HWND)win, rect.left, rect.top, rect.width, rect.height, TRUE);
}

u32 getMonitors(Span<Monitor> monitors)
{
	struct Callback {
		struct Data {
			Span<Monitor>* monitors;
			u32 index;
		};

		static BOOL CALLBACK func(HMONITOR monitor, HDC, LPRECT, LPARAM lparam)
		{
			Data* data = reinterpret_cast<Data*>(lparam);
			if (data->index >= data->monitors->length()) return TRUE;

			MONITORINFO info = { 0 };
			info.cbSize = sizeof(MONITORINFO);
			if (!::GetMonitorInfo(monitor, &info)) return TRUE;

			Monitor& m = (*data->monitors)[data->index];
			m.monitor_rect.left = info.rcMonitor.left;
			m.monitor_rect.top = info.rcMonitor.top;
			m.monitor_rect.width = info.rcMonitor.right - info.rcMonitor.left;
			m.monitor_rect.height = info.rcMonitor.bottom - info.rcMonitor.top;

			m.work_rect.left = info.rcWork.left;
			m.work_rect.top = info.rcWork.top;
			m.work_rect.width = info.rcWork.right - info.rcWork.left;
			m.work_rect.height = info.rcWork.bottom - info.rcWork.top;

			m.primary = info.dwFlags & MONITORINFOF_PRIMARY;
			++data->index;

			return TRUE;
		}
	};

	Callback::Data data = {
		&monitors,
		0
	};

	::EnumDisplayMonitors(NULL, NULL, &Callback::func, (LPARAM)&data);
	return data.index;
}

void setMouseScreenPos(int x, int y)
{
	SetCursorPos(x, y);
}

Point getMouseScreenPos()
{
	POINT p;
	static POINT last_p = {};
	const BOOL b = GetCursorPos(&p);
	// under some unknown (permission denied...) rare circumstances GetCursorPos fails, we returns last known position
	if (!b) p = last_p;
	last_p = p;
	return {p.x, p.y};
}

WindowHandle getFocused()
{
	return GetActiveWindow();
}

bool isMaximized(WindowHandle win) {
	WINDOWPLACEMENT placement;
	BOOL res = GetWindowPlacement((HWND)win, &placement);
	ASSERT(res);
	return placement.showCmd == SW_SHOWMAXIMIZED;
}

void restore(WindowHandle win, WindowState state) {
	SetWindowLongPtr((HWND)win, GWL_STYLE, state.style);
	os::setWindowScreenRect(win, state.rect);
}

WindowState setFullscreen(WindowHandle win) {
	WindowState res;
	res.rect = os::getWindowScreenRect(win);
	res.style = SetWindowLongPtr((HWND)win, GWL_STYLE, WS_VISIBLE | WS_POPUP);
	int w = GetSystemMetrics(SM_CXSCREEN);
	int h = GetSystemMetrics(SM_CYSCREEN);
	SetWindowPos((HWND)win, HWND_TOP, 0, 0, w, h, SWP_FRAMECHANGED);
	return res;
}

void maximizeWindow(WindowHandle win)
{
	ShowWindow((HWND)win, SW_SHOWMAXIMIZED);
}

bool isRelativeMouseMode()
{
	return G.relative_mouse;
}

int getDPI()
{
	const HDC hdc = GetDC(NULL);
    return GetDeviceCaps(hdc, LOGPIXELSX);
}

u32 getMemPageSize() {
	SYSTEM_INFO info;
	GetSystemInfo(&info);
	return info.dwPageSize;
}

u64 getProcessMemory() {
	PROCESS_MEMORY_COUNTERS counters;
	if (GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)) != 0) {
		return counters.WorkingSetSize;
	}
	ASSERT(false);
	return 0;
}

u32 getMemPageAlignment() {
	SYSTEM_INFO info;
	GetSystemInfo(&info);
	return info.dwAllocationGranularity;
}

void* memReserve(size_t size) {
	return VirtualAlloc(nullptr, size, MEM_RESERVE, PAGE_READWRITE);
}

void memCommit(void* ptr, size_t size) {
	VirtualAlloc(ptr, size, MEM_COMMIT, PAGE_READWRITE);
}

void memRelease(void* ptr, size_t size) {
	VirtualFree(ptr, 0, MEM_RELEASE);
}

struct FileIterator
{
	HANDLE handle;
	IAllocator* allocator;
	WIN32_FIND_DATA ffd;
	bool is_valid;
};

FileIterator* createFileIterator(const char* path, IAllocator& allocator)
{
	char tmp[LUMIX_MAX_PATH];
	copyString(tmp, path);
	catString(tmp, "/*");

	WCharStr<LUMIX_MAX_PATH> wtmp(tmp);
	auto* iter = LUMIX_NEW(allocator, FileIterator);
	iter->allocator = &allocator;
	iter->handle = FindFirstFile(wtmp, &iter->ffd);
	iter->is_valid = iter->handle != INVALID_HANDLE_VALUE;
	return iter;
}

void destroyFileIterator(FileIterator* iterator)
{
	FindClose(iterator->handle);
	LUMIX_DELETE(*iterator->allocator, iterator);
}

bool getNextFile(FileIterator* iterator, FileInfo* info)
{
	if (!iterator->is_valid) return false;

	info->is_directory = (iterator->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
	fromWChar(Span(info->filename), iterator->ffd.cFileName);

	iterator->is_valid = FindNextFile(iterator->handle, &iterator->ffd) != FALSE;
	return true;
}

void setCurrentDirectory(const char* path)
{
	WCharStr<LUMIX_MAX_PATH> tmp(path);
	SetCurrentDirectory(tmp);
}

void getCurrentDirectory(Span<char> output)
{
	WCHAR tmp[LUMIX_MAX_PATH];
	GetCurrentDirectory(lengthOf(tmp), tmp);
	fromWChar(output, tmp);
}

bool getSaveFilename(Span<char> out, const char* filter, const char* default_extension)
{
	WCharStr<LUMIX_MAX_PATH> wtmp("");
	WCHAR wfilter[LUMIX_MAX_PATH];

	const char* c = filter;
	WCHAR* cout = wfilter;
	while ((*c || *(c + 1)) && (c - filter) < LUMIX_MAX_PATH - 2) {
		*cout = *c;
		++cout;
		++c;
	}
	*cout = 0;
	++cout;
	*cout = 0;

	WCharStr<LUMIX_MAX_PATH> wdefault_extension(default_extension ? default_extension : "");
	OPENFILENAME ofn;
	ZeroMemory(&ofn, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = NULL;
	ofn.lpstrFile = wtmp.data;
	ofn.lpstrFile[0] = '\0';
	ofn.nMaxFile = lengthOf(wtmp.data);
	ofn.lpstrFilter = wfilter;
	ofn.nFilterIndex = 1;
	ofn.lpstrDefExt = default_extension ? wdefault_extension.data : nullptr;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = NULL;
	ofn.Flags = OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR | OFN_NONETWORKBUTTON;

	bool res = GetSaveFileName(&ofn) != FALSE;

	char tmp[LUMIX_MAX_PATH];
	fromWChar(Span(tmp), wtmp);
	if (res) Path::normalize(tmp, out);
	return res;
}

bool getOpenFilename(Span<char> out, const char* filter, const char* starting_file)
{
	OPENFILENAME ofn;
	ZeroMemory(&ofn, sizeof(ofn));
	ofn.lStructSize = sizeof(ofn);
	ofn.hwndOwner = NULL;
	if (starting_file)
	{
		char* to = out.begin();
		for (const char *from = starting_file; *from; ++from, ++to)
		{
			if (to - out.begin() > out.length() - 1) break;
			*to = *to == '/' ? '\\' : *from;
		}
		*to = '\0';
	}
	else
	{
		out[0] = '\0';
	}
	WCHAR wout[LUMIX_MAX_PATH] = {};
	WCHAR wfilter[LUMIX_MAX_PATH];

	const char* c = filter;
	WCHAR* cout = wfilter;
	while ((*c || *(c + 1)) && (c - filter) < LUMIX_MAX_PATH - 2) {
		*cout = *c;
		++cout;
		++c;
	}
	*cout = 0;
	++cout;
	*cout = 0;

	ofn.lpstrFile = wout;
	ofn.nMaxFile = sizeof(wout);
	ofn.lpstrFilter = wfilter;
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = nullptr;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_NONETWORKBUTTON;

	const bool res = GetOpenFileName(&ofn) != FALSE;
	if (res) {
		char tmp[LUMIX_MAX_PATH];
		fromWChar(Span(tmp), wout);
		Path::normalize(tmp, out);
	}
	else {
		auto err = CommDlgExtendedError();
		ASSERT(err == 0);
	}
	return res;
}

bool getOpenDirectory(Span<char> output, const char* starting_dir)
{
	bool ret = false;
	IFileDialog* pfd;
	if (SUCCEEDED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd))))
	{
		if (starting_dir)
		{
			PIDLIST_ABSOLUTE pidl;
			WCHAR wstarting_dir[MAX_PATH];
			WCHAR* wc = wstarting_dir;
			for (const char *c = starting_dir; *c && wc - wstarting_dir < MAX_PATH - 1; ++c, ++wc)
			{
				*wc = *c == '/' ? '\\' : *c;
			}
			*wc = 0;

			HRESULT hresult = ::SHParseDisplayName(wstarting_dir, 0, &pidl, SFGAO_FOLDER, 0);
			if (SUCCEEDED(hresult))
			{
				IShellItem* psi;
				hresult = ::SHCreateShellItem(NULL, NULL, pidl, &psi);
				if (SUCCEEDED(hresult))
				{
					pfd->SetFolder(psi);
				}
				ILFree(pidl);
			}
		}

		DWORD dwOptions;
		if (SUCCEEDED(pfd->GetOptions(&dwOptions)))
		{
			pfd->SetOptions(dwOptions | FOS_PICKFOLDERS);
		}
		if (SUCCEEDED(pfd->Show(NULL)))
		{
			IShellItem* psi;
			if (SUCCEEDED(pfd->GetResult(&psi)))
			{
				WCHAR* tmp;
				if (SUCCEEDED(psi->GetDisplayName(SIGDN_DESKTOPABSOLUTEPARSING, &tmp)))
				{
					char* c = output.begin();
					const u32 max_size = output.length();
					while (*tmp && c - output.begin() < max_size - 1)
					{
						*c = (char)*tmp;
						++c;
						++tmp;
					}
					*c = '\0';
					if (!endsWith(output.begin(), "/") && !endsWith(output.begin(), "\\") && c - output.begin() < max_size - 1)
					{
						*c = '/';
						++c;
						*c = '\0';
					}
					ret = true;
				}
				psi->Release();
			}
		}
		pfd->Release();
	}
	return ret;
}

void copyToClipboard(const char* text)
{
	if (!OpenClipboard(NULL)) return;
	int len = stringLength(text) + 1;
	HGLOBAL mem_handle = GlobalAlloc(GMEM_MOVEABLE, len * sizeof(char));
	if (!mem_handle) return;

	char* mem = (char*)GlobalLock(mem_handle);
	copyString(Span(mem, len), text);
	GlobalUnlock(mem_handle);
	EmptyClipboard();
	SetClipboardData(CF_TEXT, mem_handle);
	CloseClipboard();
}

ExecuteOpenResult shellExecuteOpen(const char* path)
{
	const WCharStr<LUMIX_MAX_PATH> wpath(path);
	const uintptr_t res = (uintptr_t)ShellExecute(NULL, NULL, wpath, NULL, NULL, SW_SHOW);
	if (res > 32) return ExecuteOpenResult::SUCCESS;
	if (res == SE_ERR_NOASSOC) return ExecuteOpenResult::NO_ASSOCIATION;
	return ExecuteOpenResult::OTHER_ERROR;
}

ExecuteOpenResult openExplorer(const char* path)
{
	const WCharStr<LUMIX_MAX_PATH> wpath(path);
	const uintptr_t res = (uintptr_t)ShellExecute(NULL, L"explore", wpath, NULL, NULL, SW_SHOWNORMAL);
	if (res > 32) return ExecuteOpenResult::SUCCESS;
	if (res == SE_ERR_NOASSOC) return ExecuteOpenResult::NO_ASSOCIATION;
	return ExecuteOpenResult::OTHER_ERROR;
}

bool deleteFile(const char* path)
{
	const WCharStr<LUMIX_MAX_PATH> wpath(path);
	return DeleteFile(wpath) != FALSE;
}

bool moveFile(const char* from, const char* to)
{
	const WCharStr<LUMIX_MAX_PATH> wfrom(from);
	const WCharStr<LUMIX_MAX_PATH> wto(to);
	return MoveFileEx(wfrom, wto, MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED) != FALSE;
}

size_t getFileSize(const char* path)
{
	WIN32_FILE_ATTRIBUTE_DATA fad;
	const WCharStr<LUMIX_MAX_PATH> wpath(path);
	if (!GetFileAttributesEx(wpath, GetFileExInfoStandard, &fad)) return -1;
	LARGE_INTEGER size;
	size.HighPart = fad.nFileSizeHigh;
	size.LowPart = fad.nFileSizeLow;
	return (size_t)size.QuadPart;
}

bool fileExists(const char* path)
{
	const WCharStr<LUMIX_MAX_PATH> wpath(path);
	DWORD dwAttrib = GetFileAttributes(wpath);
	return (dwAttrib != INVALID_FILE_ATTRIBUTES && !(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}

bool dirExists(const char* path)
{
	const WCharStr<LUMIX_MAX_PATH> wpath(path);
	DWORD dwAttrib = GetFileAttributes(wpath);
	return (dwAttrib != INVALID_FILE_ATTRIBUTES && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
}

u64 getLastModified(const char* path)
{
	const WCharStr<LUMIX_MAX_PATH> wpath(path);
	FILETIME ft;
	HANDLE handle = CreateFile(wpath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (handle == INVALID_HANDLE_VALUE) return 0;
	if (GetFileTime(handle, NULL, NULL, &ft) == FALSE) {
		CloseHandle(handle);
		return 0;
	}
	CloseHandle(handle);

	ULARGE_INTEGER i;
	i.LowPart = ft.dwLowDateTime;
	i.HighPart = ft.dwHighDateTime;
	return i.QuadPart;
}

bool makePath(const char* path)
{
	char tmp[MAX_PATH];
	char* out = tmp;
	const char* in = path;
	while (*in && out - tmp < lengthOf(tmp) - 1)
	{
		*out = *in == '/' ? '\\' : *in;
		++out;
		++in;
	}
	*out = '\0';

	const WCharStr<LUMIX_MAX_PATH> wpath(tmp);
	int error_code = SHCreateDirectoryEx(NULL, wpath, NULL);
	return error_code == ERROR_SUCCESS || error_code == ERROR_ALREADY_EXISTS;
}

void grabMouse(WindowHandle win) {
	G.grabbed_window = win;
	updateGrabbedMouse();
}

bool copyFile(const char* from, const char* to)
{
	WCHAR tmp_from[MAX_PATH];
	WCHAR tmp_to[MAX_PATH];
	toWChar(tmp_from, from);
	toWChar(tmp_to, to);

	if (CopyFile(tmp_from, tmp_to, FALSE) == FALSE) return false;

	FILETIME ft;
	SYSTEMTIME st;

	GetSystemTime(&st);
	SystemTimeToFileTime(&st, &ft);
	HANDLE handle = CreateFile(tmp_to, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	bool f = SetFileTime(handle, (LPFILETIME)NULL, (LPFILETIME)NULL, &ft) != FALSE;
	ASSERT(f);
	CloseHandle(handle);

	return true;
}

bool getAppDataDir(Span<char> out) {
	WCHAR path[MAX_PATH];
	if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) return false;
	fromWChar(out, path);
	return true;
}

void getExecutablePath(Span<char> buffer)
{
	WCHAR tmp[MAX_PATH];
	GetModuleFileName(NULL, tmp, sizeof(tmp));
	fromWChar(buffer, tmp);
}

void messageBox(const char* text)
{
	WCHAR tmp[2048];
	toWChar(tmp, text);
	MessageBox(NULL, tmp, L"Message", MB_OK);
}

void setCommandLine(int, char**)
{
	ASSERT(false);
}

bool getCommandLine(Span<char> output)
{
	WCHAR* cl = GetCommandLine();
	fromWChar(output, cl);
	return true;
}

void* loadLibrary(const char* path)
{
	WCHAR tmp[MAX_PATH];
	toWChar(tmp, path);
	return LoadLibrary(tmp);
}

void unloadLibrary(void* handle)
{
	FreeLibrary((HMODULE)handle);
}

void* getLibrarySymbol(void* handle, const char* name)
{
	return (void*)GetProcAddress((HMODULE)handle, name);
}

Timer::Timer()
{
	LARGE_INTEGER f, n;

	QueryPerformanceFrequency(&f);
	QueryPerformanceCounter(&n);
	first_tick = last_tick = n.QuadPart;
	frequency = f.QuadPart;

}

float Timer::getTimeSinceStart()
{
	LARGE_INTEGER n;
	QueryPerformanceCounter(&n);
	const u64 tick = n.QuadPart;
	float delta = static_cast<float>((double)(tick - first_tick) / (double)frequency);
	return delta;
}

float Timer::getTimeSinceTick()
{
	LARGE_INTEGER n;
	QueryPerformanceCounter(&n);
	const u64 tick = n.QuadPart;
	float delta = static_cast<float>((double)(tick - last_tick) / (double)frequency);
	return delta;
}

float Timer::tick()
{
	LARGE_INTEGER n;
	QueryPerformanceCounter(&n);
	const u64 tick = n.QuadPart;
	float delta = static_cast<float>((double)(tick - last_tick) / (double)frequency);
	last_tick = tick;
	return delta;
}

u64 Timer::getFrequency()
{
	static u64 freq = []() {
		LARGE_INTEGER f;
		QueryPerformanceFrequency(&f);
		return f.QuadPart;
	}();
	return freq;
}

u64 Timer::getRawTimestamp()
{
	LARGE_INTEGER tick;
	QueryPerformanceCounter(&tick);
	return tick.QuadPart;
}

} // namespace Lumix::OS


text:
using System;
using System.Globalization;
using LibGit2Sharp.Core;

namespace LibGit2Sharp
{
    /// <summary>
    /// A branch is a special kind of reference
    /// </summary>
    public class Branch : ReferenceWrapper<Commit>
    {
        private readonly Lazy<Branch> trackedBranch;

        /// <summary>
        /// Needed for mocking purposes.
        /// </summary>
        protected Branch()
        { }

        /// <summary>
        /// Initializes a new instance of the <see cref="Branch"/> class.
        /// </summary>
        /// <param name="repo">The repo.</param>
        /// <param name="reference">The reference.</param>
        /// <param name="canonicalName">The full name of the reference</param>
        internal Branch(Repository repo, Reference reference, string canonicalName)
            : this(repo, reference, _ => canonicalName)
        { }

        /// <summary>
        /// Initializes a new instance of an orphaned <see cref="Branch"/> class.
        /// <para>
        ///   This <see cref="Branch"/> instance will point to no commit.
        /// </para>
        /// </summary>
        /// <param name="repo">The repo.</param>
        /// <param name="reference">The reference.</param>
        internal Branch(Repository repo, Reference reference)
            : this(repo, reference, r => r.TargetIdentifier)
        { }

        private Branch(Repository repo, Reference reference, Func<Reference, string> canonicalNameSelector)
            : base(repo, reference, canonicalNameSelector)
        {
            trackedBranch = new Lazy<Branch>(ResolveTrackedBranch);
        }

        /// <summary>
        /// Gets the <see cref="TreeEntry"/> pointed at by the <paramref name="relativePath"/> in the <see cref="Tip"/>.
        /// </summary>
        /// <param name="relativePath">The relative path to the <see cref="TreeEntry"/> from the <see cref="Tip"/> working directory.</param>
        /// <returns><c>null</c> if nothing has been found, the <see cref="TreeEntry"/> otherwise.</returns>
        public virtual TreeEntry this[string relativePath]
        {
            get
            {
                if (Tip == null)
                {
                    return null;
                }

                return Tip[relativePath];
            }
        }

        /// <summary>
        /// Gets a value indicating whether this instance is a remote.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is remote; otherwise, <c>false</c>.
        /// </value>
        public virtual bool IsRemote
        {
            get { return IsRemoteBranch(CanonicalName); }
        }

        /// <summary>
        /// Gets the remote branch which is connected to this local one, or null if there is none.
        /// </summary>
        public virtual Branch TrackedBranch
        {
            get { return trackedBranch.Value; }
        }

        /// <summary>
        /// Determines if this local branch is connected to a remote one.
        /// </summary>
        public virtual bool IsTracking
        {
            get { return TrackedBranch != null; }
        }

        /// <summary>
        /// Gets additional information about the tracked branch.
        /// </summary>
        public virtual BranchTrackingDetails TrackingDetails
        {
            get { return new BranchTrackingDetails(repo, this); }
        }

        /// <summary>
        /// Gets a value indicating whether this instance is current branch (HEAD) in the repository.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is the current branch; otherwise, <c>false</c>.
        /// </value>
        public virtual bool IsCurrentRepositoryHead
        {
            get
            {
                if (this is DetachedHead)
                {
                    return repo.Head.Reference.TargetIdentifier == this.Reference.TargetIdentifier;
                }

                return repo.Head.Reference.TargetIdentifier == this.CanonicalName;
            }
        }

        /// <summary>
        /// Gets the <see cref="Commit"/> that this branch points to.
        /// </summary>
        public virtual Commit Tip
        {
            get { return TargetObject; }
        }

        /// <summary>
        /// Gets the commits on this branch. (Starts walking from the References's target).
        /// </summary>
        public virtual ICommitLog Commits
        {
            get { return repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = this }); }
        }

        /// <summary>
        /// Gets the configured canonical name of the upstream branch.
        /// <para>
        ///   This is the upstream reference to which this branch will be pushed.
        ///   It corresponds to the "branch.branch_name.merge" property of the config file.
        /// </para>
        /// </summary>
        public virtual string UpstreamBranchCanonicalName
        {
            get
            {
                if (IsRemote)
                {
                    using (var remote = repo.Network.Remotes.RemoteForName(RemoteName))
                    {
                        return remote.FetchSpecTransformToSource(CanonicalName);
                    }
                }

                return UpstreamBranchCanonicalNameFromLocalBranch();
            }
        }

        /// <summary>
        /// Get the name of the remote for the branch.
        /// <para>
        ///   If this is a local branch, this will return the configured
        ///   <see cref="Remote"/> to fetch from and push to. If this is a
        ///   remote-tracking branch, this will return the name of the remote
        ///   containing the tracked branch. If there is no tracking information,
        ///   this will return null.
        /// </para>
        /// </summary>
        public virtual string RemoteName
        {
            get
            {
                return IsRemote
                    ? RemoteNameFromRemoteTrackingBranch()
                    : RemoteNameFromLocalBranch();
            }
        }

        private string UpstreamBranchCanonicalNameFromLocalBranch()
        {
            ConfigurationEntry<string> mergeRefEntry = repo.Config.Get<string>("branch", FriendlyName, "merge");

            if (mergeRefEntry == null)
            {
                return null;
            }

            return mergeRefEntry.Value;
        }

        private string RemoteNameFromLocalBranch()
        {
            ConfigurationEntry<string> remoteEntry = repo.Config.Get<string>("branch", FriendlyName, "remote");

            if (remoteEntry == null)
            {
                return null;
            }

            string remoteName = remoteEntry.Value;

            if (string.IsNullOrEmpty(remoteName) ||
                string.Equals(remoteName, ".", StringComparison.Ordinal))
            {
                return null;
            }

            return remoteName;

        }

        private string RemoteNameFromRemoteTrackingBranch()
        {
            return Proxy.git_branch_remote_name(repo.Handle, CanonicalName, false);
        }

        private Branch ResolveTrackedBranch()
        {
            if (IsRemote)
            {
                return null;
            }

            string trackedReferenceName = Proxy.git_branch_upstream_name(repo.Handle, CanonicalName);

            if (trackedReferenceName == null)
            {
                return null;
            }

            Branch branch = repo.Branches[trackedReferenceName];

            if (branch != null)
            {
                return branch;
            }

            return new Branch(repo, new VoidReference(repo, trackedReferenceName), trackedReferenceName);
        }

        private static bool IsRemoteBranch(string canonicalName)
        {
            return canonicalName.LooksLikeRemoteTrackingBranch();
        }

        /// <summary>
        /// Removes redundent leading namespaces (regarding the kind of
        /// reference being wrapped) from the canonical name.
        /// </summary>
        /// <returns>The friendly shortened name</returns>
        protected override string Shorten()
        {
            if (CanonicalName.LooksLikeLocalBranch())
            {
                return CanonicalName.Substring(Reference.LocalBranchPrefix.Length);
            }

            if (CanonicalName.LooksLikeRemoteTrackingBranch())
            {
                return CanonicalName.Substring(Reference.RemoteTrackingBranchPrefix.Length);
            }

            throw new ArgumentException(string.Format(CultureInfo.InvariantCulture,
                                                      "'{0}' does not look like a valid branch name.",
                                                      CanonicalName));
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
ActiveRecord::Schema.define(version: 20130813113418) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

  create_table "contacts", force: true do |t|
    t.string   "name"
    t.integer  "phone"
    t.string   "email"
    t.integer  "user_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "contacts", ["user_id", "name"], name: "index_contacts_on_user_id_and_name", using: :btree

  create_table "opro_auth_grants", force: true do |t|
    t.string   "code"
    t.string   "access_token"
    t.string   "refresh_token"
    t.text     "permissions"
    t.datetime "access_token_expires_at"
    t.integer  "user_id"
    t.integer  "application_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "opro_auth_grants", ["access_token"], name: "index_opro_auth_grants_on_access_token", unique: true, using: :btree
  add_index "opro_auth_grants", ["code"], name: "index_opro_auth_grants_on_code", unique: true, using: :btree
  add_index "opro_auth_grants", ["refresh_token"], name: "index_opro_auth_grants_on_refresh_token", unique: true, using: :btree

  create_table "opro_client_apps", force: true do |t|
    t.string   "name"
    t.string   "app_id"
    t.string   "app_secret"
    t.text     "permissions"
    t.integer  "user_id"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  add_index "opro_client_apps", ["app_id", "app_secret"], name: "index_opro_client_apps_on_app_id_and_app_secret", unique: true, using: :btree
  add_index "opro_client_apps", ["app_id"], name: "index_opro_client_apps_on_app_id", unique: true, using: :btree

  create_table "users", force: true do |t|
    t.string   "name"
    t.string   "email"
    t.boolean  "admin"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "encrypted_password",               default: "", null: false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",                    default: 0
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.string   "username"
    t.string   "org_name"
    t.boolean  "is_developer"
    t.integer  "developer_account_id",   limit: 8
  end

  add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
  add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree

end


text:
#ifndef __ARCHIVE_RAR_IN_H
#define __ARCHIVE_RAR_IN_H

#include "Common/DynamicBuffer.h"
#include "Common/MyCom.h"

#include "../../ICoder.h"
#include "../../IStream.h"

#include "../../Common/StreamObjects.h"

#include "../../Crypto/RarAes.h"

#include "RarHeader.h"
#include "RarItem.h"

namespace NArchive {
namespace NRar {

class CInArchiveException
{
public:
  enum CCauseType
  {
    kUnexpectedEndOfArchive = 0,
    kArchiveHeaderCRCError,
    kFileHeaderCRCError,
    kIncorrectArchive
  }
  Cause;
  CInArchiveException(CCauseType cause) :   Cause(cause) {}
};

struct CInArchiveInfo
{
  UInt32 Flags;
  Byte EncryptVersion;
  UInt64 StartPosition;

  bool IsSolid() const { return (Flags & NHeader::NArchive::kSolid) != 0; }
  bool IsCommented() const {  return (Flags & NHeader::NArchive::kComment) != 0; }
  bool IsVolume() const {  return (Flags & NHeader::NArchive::kVolume) != 0; }
  bool HaveNewVolumeName() const {  return (Flags & NHeader::NArchive::kNewVolName) != 0; }
  bool IsEncrypted() const { return (Flags & NHeader::NArchive::kBlockEncryption) != 0; }
  bool IsThereEncryptVer() const { return (Flags & NHeader::NArchive::kEncryptVer) != 0; }
  bool IsEncryptOld() const { return (!IsThereEncryptVer() || EncryptVersion < 36); }
};

class CInArchive
{
  CMyComPtr<IInStream> m_Stream;

  UInt64 m_StreamStartPosition;

  CInArchiveInfo _header;
  CDynamicBuffer<char> m_NameBuffer;
  CDynamicBuffer<wchar_t> _unicodeNameBuffer;

  CByteBuffer _comment;

  void ReadName(CItemEx &item, int nameSize);
  void ReadHeaderReal(CItemEx &item);

  HRESULT ReadBytesSpec(void *data, size_t *size);
  bool ReadBytesAndTestSize(void *data, UInt32 size);

  HRESULT Open2(IInStream *stream, const UInt64 *searchHeaderSizeLimit);

  void ThrowExceptionWithCode(CInArchiveException::CCauseType cause);
  void ThrowUnexpectedEndOfArchiveException();

  void AddToSeekValue(UInt64 addValue);

  CDynamicBuffer<Byte> m_FileHeaderData;

  NHeader::NBlock::CBlock m_BlockHeader;

  NCrypto::NRar29::CDecoder *m_RarAESSpec;
  CMyComPtr<ICompressFilter> m_RarAES;

  Byte *m_CurData; // it must point to start of Rar::Block
  UInt32 m_CurPos;
  UInt32 m_PosLimit;
  Byte ReadByte();
  UInt16 ReadUInt16();
  UInt32 ReadUInt32();
  void ReadTime(Byte mask, CRarTime &rarTime);

  CBuffer<Byte> m_DecryptedData;
  Byte *m_DecryptedDataAligned;
  UInt32 m_DecryptedDataSize;

  bool m_CryptoMode;
  UInt32 m_CryptoPos;
  void FinishCryptoBlock()
  {
    if (m_CryptoMode)
      while ((m_CryptoPos & 0xF) != 0)
      {
        m_CryptoPos++;
        m_Position++;
      }
  }

public:
  UInt64 m_Position;

  HRESULT Open(IInStream *inStream, const UInt64 *searchHeaderSizeLimit);
  void Close();
  HRESULT GetNextItem(CItemEx &item, ICryptoGetTextPassword *getTextPassword, bool &decryptionError, AString &errorMessage);

  void GetArchiveInfo(CInArchiveInfo &archiveInfo) const;

  void SeekInArchive(UInt64 position);
  ISequentialInStream *CreateLimitedStream(UInt64 position, UInt64 size);
};

}}

#endif


text: static const double  EPSILON = 0.0000000001;


text:
@implementation DownLoadTool

-(void)downLoadData:(NSString *)strUrl
{
    NSURL *url = [NSURL URLWithString:strUrl];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60];
    //异步block请求
    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        if (connectionError) {
            NSLog(@"网络请求出错");
            return;
        }
        //下载结束,用代理传值的方式将下载的数据传回,//
        [self.myDelegate sendDataFromTool:data];

    }];
}

@end


text:
<?php
define('UNREG_TITLE', "SYNAPP - ELIMINAR USUARIO ");
define('UNREG_HEADER', "ELIMINAR CUENTA SYNAPP DEL USUARIO");
define('UNREG_PASS', "Password");
define('UNREG_SEND', "ELIMINAR CUENTA");
define('UNREG_ERR_1', "Password incorrecto. Por favor intentelo de nuevo.");
define('UNREG_ERR_2', "Un email de confirmacion ha sido enviado. Por favor siga el enlace en el mismo para eliminar su registro.");
define('UNREG_ERR_3', "Captcha incorrecto. Por favor intentelo de nuevo");
define('UNREG_CAPT', "Captcha:");
define('UNREG_CONFIRM', "¿¿¿ESTA USTED SEGURO??? ESTA A PUNTO DE ELIMINAR LA CUENTA PARA EL USUARIO:");
define('UNREG_WARNING', "Esta operacion es IRREVERSIBLE. TODOS LOS DATOS relacionados con su cuenta seran PERDIDOS PARA SIEMPRE.");

define('UR_MAIL_SUBJECT_1', "SYNAPP solicitud de baja para el usuario ");
define('UR_MAIL_SUBJECT_2', ". No responder.");
define('UR_MAIL_MIMEALT', "Si esta leyendo esto, por favor actualice su software de lectura de correo electronico.");
define('UR_MAIL_TITLE', "SYNAPP - Eliminacion de cuenta.");
define('UR_MAIL_TO', "Este email ha sido automaticamente generado y enviado desde SYNAPP a la direccion");
define('UR_MAIL_USR_1', "como resultado de la recepcion de un formulario de solicitud de eliminacion de cuenta para el usuario");
define('UR_MAIL_USR_2', "");
define('UR_MAIL_NR', "POR FAVOR NO RESPONDA A ESTE MENSAJE.");
define('UR_MAIL_IGNORE', "Si no tiene relacion con esta cuenta o no desea eleminar su cuenta, por favor ignore este email.");
define('UR_MAIL_DO', "Para eliminar su subscripcion y todos los datos relacionados con si cuenta, por favor siga este enlace haciendo clic en el o copiandolo a la barra de direccion de su navegador:");
define('UR_TITLE_1', "SYNAPP - Formulario de eliminacion de cuenta.");
define('UR_HEADER_1', "Por favor escriba a continuacion su nombre de usuario o email asociado.<br />En unos minutos recibira un email en esta direccion con instrucciones para la eliminacion de su cuenta.");
define('UR_SENT_2', "Un email de solicitud de confirmacion ha sido enviado a la direccion associada al usuario");
define('UR_SENT_DO', "Por favor siga las instrucciones proporcionadas en el mismo para eliminar su cuenta de usuario.");
define('UR_SENT_TITLE_2', "Email de solicitud de confirmacion de eliminacion de cuenta enviada al usuario");
define('UR_GOTO_HOME', "ir a la pagina principal de SynAPP");


text:
function gup(name, url) {
  if (!url) url = location.href;
  name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(url);
  return results == null ? null : results[1];
}
function httpGet(theUrl) {
  var xmlHttp = new XMLHttpRequest();
  xmlHttp.open("GET", theUrl, false); // false for synchronous request
  xmlHttp.send(null);
  return JSON.parse(xmlHttp.responseText);
}

var stepSlider = document.getElementById("slider-step");


text:
<component name="InspectionProjectProfileManager">
  <profile version="1.0" is_locked="true">
    <option name="myName" value="Project Default" />
    <inspection_tool class="AmdModulesDependencies" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="Annotator" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="AnonymousFunctionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="AnonymousGroup" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="AssignmentResultUsedJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="AssignmentToForLoopParameterJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="AssignmentToFunctionParameterJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="BadExpressionStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="BlockStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="BreakStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="BreakStatementWithLabelJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="CallerJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ChainedEqualityJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ChainedFunctionCallJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="CheckDtdRefs" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CheckEmptyScriptTag" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CheckImageSize" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CheckNodeTest" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CheckTagEmptyBody" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CheckValidXmlInScriptTagBody" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CheckXmlFileWithXercesValidator" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CoffeeScriptArgumentsOutsideFunction" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CoffeeScriptFunctionSignatures" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="CoffeeScriptInfiniteLoop" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CoffeeScriptLiteralNotFunction" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CoffeeScriptSillyAssignment" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CoffeeScriptSwitchStatementWithNoDefaultBranch" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CoffeeScriptUnusedLocalSymbols" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CommaExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ComposeFileStructure" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="ConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ConditionalExpressionWithIdenticalBranchesJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ConfusingFloatingPointLiteralJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ConfusingPlusesOrMinusesJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ConstantConditionalExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ConstantIfStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ConstantOnLHSOfComparisonJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ConstantOnRHSOfComparisonJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ContinueOrBreakFromFinallyBlockJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ContinueStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ContinueStatementWithLabelJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="CssConvertColorToHexInspection" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="CssConvertColorToRgbInspection" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="CssFloatPxLength" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="CssInvalidAtRule" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssInvalidCharsetRule" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssInvalidElement" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssInvalidFunction" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssInvalidHtmlTagReference" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssInvalidImport" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssInvalidMediaFeature" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssInvalidPropertyValue" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssInvalidPseudoSelector" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssMissingComma" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssMissingSemicolon" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="CssNegativeValue" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssNoGenericFontName" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssOptimizeSimilarProperties" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="CssOverwrittenProperties" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssRedundantUnit" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssUnitlessNumber" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CssUnknownProperty" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="myCustomPropertiesEnabled" value="false" />
      <option name="myIgnoreVendorSpecificProperties" value="false" />
      <option name="myCustomPropertiesList">
        <value>
          <list size="0" />
        </value>
      </option>
    </inspection_tool>
    <inspection_tool class="CssUnknownTarget" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssUnresolvedClass" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssUnresolvedCustomProperty" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssUnresolvedCustomPropertySet" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CssUnusedSymbol" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CucumberExamplesColon" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CucumberMissedExamples" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="CucumberTableInspection" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CucumberUndefinedStep" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="CyclomaticComplexityJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_limit" value="10" />
    </inspection_tool>
    <inspection_tool class="DartOutdatedDependencies" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="DartPathPackageReference" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="DebuggerStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="DefaultNotLastCaseInSwitchJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="DivideByZeroJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="DockerFileArgumentCount" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="DocumentWriteJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="DuplicateAlternationBranch" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="DuplicateCaseLabelJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="DuplicateConditionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Duplicates" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="DynamicallyGeneratedCodeJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ES6BindWithArrowFunction" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ES6ConvertModuleExportToExport" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="ES6ConvertRequireIntoImport" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="ES6ConvertToForOf" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="ES6ConvertVarToLetConst" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ES6MissingAwait" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="ES6ModulesDependencies" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="ES6PossiblyAsyncFunction" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="ES6ShorthandObjectProperty" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="ES6UnusedImports" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ES6Validation" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="EjsUnresolvedInclude" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="EmptyAlternationBranch" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="EmptyCatchBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="EmptyEventHandler" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="EmptyFinallyBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="EmptyStatementBodyJS" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_reportEmptyBlocks" value="false" />
    </inspection_tool>
    <inspection_tool class="EmptyTryBlockJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="EscapedMetaCharacter" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="Eslint" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="ExceptionCaughtLocallyJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="FallThroughInSwitchStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="FlowJSConfig" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="FlowJSCoverage" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="FlowJSError" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="FlowJSFlagCommentPlacement" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ForLoopReplaceableByWhileJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_ignoreLoopsWithoutConditions" value="false" />
    </inspection_tool>
    <inspection_tool class="ForLoopThatDoesntUseLoopVariableJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="FunctionNamingConventionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="FunctionWithInconsistentReturnsJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="FunctionWithMultipleLoopsJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="FunctionWithMultipleReturnPointsJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="GherkinBrokenTableInspection" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="GherkinMisplacedBackground" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="GjsLint" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="HamlNestedTagContent" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HardwiredNamespacePrefix" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HbEmptyBlock" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HtmlDeprecatedTag" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HtmlExtraClosingTag" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HtmlFormInputWithoutLabel" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HtmlMissingClosingTag" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="HtmlNonExistentInternetResource" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="HtmlPresentationalElement" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HtmlUnknownAnchorTarget" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HtmlUnknownAttribute" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="myValues">
        <value>
          <list size="0" />
        </value>
      </option>
      <option name="myCustomValuesEnabled" value="true" />
    </inspection_tool>
    <inspection_tool class="HtmlUnknownBooleanAttribute" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="HtmlUnknownTag" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="myValues">
        <value>
          <list size="6">
            <item index="0" class="java.lang.String" itemvalue="nobr" />
            <item index="1" class="java.lang.String" itemvalue="noembed" />
            <item index="2" class="java.lang.String" itemvalue="comment" />
            <item index="3" class="java.lang.String" itemvalue="noscript" />
            <item index="4" class="java.lang.String" itemvalue="embed" />
            <item index="5" class="java.lang.String" itemvalue="script" />
          </list>
        </value>
      </option>
      <option name="myCustomValuesEnabled" value="true" />
    </inspection_tool>
    <inspection_tool class="HtmlUnknownTarget" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="IfStatementWithIdenticalBranchesJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="IfStatementWithTooManyBranchesJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_limit" value="3" />
    </inspection_tool>
    <inspection_tool class="ImplicitTypeConversion" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="BITS" value="1720" />
      <option name="FLAG_EXPLICIT_CONVERSION" value="true" />
      <option name="IGNORE_NODESET_TO_BOOLEAN_VIA_STRING" value="true" />
    </inspection_tool>
    <inspection_tool class="IncompatibleMaskJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="InconsistentLineSeparators" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="IncrementDecrementResultUsedJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="IndexZeroUsage" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="InfiniteLoopJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="InfiniteRecursionJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="InjectedReferences" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="InnerHTMLJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JSAccessibilityCheck" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSAnnotator" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="JSBitwiseOperatorUsage" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSCheckFunctionSignatures" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSClassNamingConvention" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JSClosureCompilerSyntax" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSCommentMatchesSignature" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSComparisonWithNaN" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSConsecutiveCommasInArrayLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSConstructorReturnsPrimitive" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSDeclarationsAtScopeStart" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
    <inspection_tool class="JSDeprecatedSymbols" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSDuplicatedDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSEqualityComparisonWithCoercion" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSEqualityComparisonWithCoercion.TS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="JSFileReferences" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSFunctionExpressionToArrowFunction" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="JSHint" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="JSIgnoredPromiseFromCall" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSJQueryEfficiency" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSLastCommaInArrayLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSLastCommaInObjectLiteral" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSLint" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="JSMethodCanBeStatic" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSMismatchedCollectionQueryUpdate" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="queries" value="trace,write,forEach" />
      <option name="updates" value="pop,push,shift,splice,unshift,add,insert,remove" />
    </inspection_tool>
    <inspection_tool class="JSNonASCIINames" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSPotentiallyInvalidConstructorUsage" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="myConsiderUppercaseFunctionsToBeConstructors" value="true" />
    </inspection_tool>
    <inspection_tool class="JSPotentiallyInvalidTargetOfIndexedPropertyAccess" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSPotentiallyInvalidUsageOfThis" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSPrimitiveTypeWrapperUsage" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSReferencingArgumentsOutsideOfFunction" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="JSReferencingMutableVariableFromClosure" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSStringConcatenationToES6Template" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="JSSuspiciousNameCombination" enabled="true" level="WARNING" enabled_by_default="true">
      <group names="x,width,left,right" />
      <group names="y,height,top,bottom" />
      <exclude classes="Math" />
    </inspection_tool>
    <inspection_tool class="JSTypeOfValues" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUndeclaredVariable" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUndefinedPropertyAssignment" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnfilteredForInLoop" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnnecessarySemicolon" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnresolvedExtXType" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnresolvedFunction" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnresolvedLibraryURL" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnresolvedVariable" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnusedAssignment" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnusedGlobalSymbols" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSUnusedLocalSymbols" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSValidateJSDoc" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JSValidateTypes" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JSXNamespaceValidation" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="JadeTabsAndSpaces" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="Jscs" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="JsonDuplicatePropertyKeys" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="JsonStandardCompliance" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="KarmaConfigFile" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="LabeledStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="LessResolvedByNameOnly" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="LessUnresolvedMixin" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="LessUnresolvedVariable" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="LocalVariableNamingConventionJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_regex" value="[a-z][A-Za-z]*" />
      <option name="m_minLength" value="1" />
      <option name="m_maxLength" value="32" />
    </inspection_tool>
    <inspection_tool class="LongLine" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="LoopStatementThatDoesntLoopJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="LossyEncoding" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="MagicNumberJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="MeteorUnresolvedSymbol" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="NegatedConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NegatedIfStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NestedAssignmentJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NestedConditionalExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NestedFunctionCallJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NestedFunctionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NestedSwitchStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NestingDepthJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_limit" value="5" />
    </inspection_tool>
    <inspection_tool class="NodeJsCodingAssistanceForCoreModules" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="NodeModulesDependencies" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="NonAsciiCharacters" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="NonBlockStatementBodyJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NonShortCircuitBooleanExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="NpmUsedModulesInstalled" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="ObjectAllocationIgnoredJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="OctalEscape" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="OctalIntegerJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="OverlyComplexArithmeticExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="OverlyComplexBooleanExpressionJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_limit" value="3" />
    </inspection_tool>
    <inspection_tool class="ParameterNamingConventionJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_regex" value="[a-z][A-Za-z]*" />
      <option name="m_minLength" value="1" />
      <option name="m_maxLength" value="32" />
    </inspection_tool>
    <inspection_tool class="ParametersPerFunctionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="PlatformDetectionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="PointlessArithmeticExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="PointlessBitwiseExpressionJS" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_ignoreExpressionsContainingConstants" value="false" />
    </inspection_tool>
    <inspection_tool class="PointlessBooleanExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ProblematicWhitespace" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="QuirksModeInspectionTool" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="IE50" value="false" />
      <option name="IE55" value="false" />
      <option name="IE6" value="true" />
      <option name="IE7" value="true" />
      <option name="IE_MAC" value="false" />
      <option name="MOZILLA" value="true" />
      <option name="OPERA7" value="false" />
      <option name="OPERA8" value="false" />
      <option name="OPERA85" value="true" />
      <option name="OPERA9" value="true" />
      <option name="SAFARI" value="true" />
    </inspection_tool>
    <inspection_tool class="RedundantTypeConversion" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="CHECK_ANY" value="false" />
    </inspection_tool>
    <inspection_tool class="RepeatedSpace" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ReplaceAssignmentWithOperatorAssignmentJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="RequiredAttributes" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="myAdditionalRequiredHtmlAttributes" value="" />
    </inspection_tool>
    <inspection_tool class="ReservedWordUsedAsNameJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ReturnFromFinallyBlockJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ReuseOfLocalVariableJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="SSBasedInspection" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="SassScssResolvedByNameOnly" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="SassScssUnresolvedMixin" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="SassScssUnresolvedPlaceholderSelector" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="SassScssUnresolvedVariable" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ShiftOutOfRangeJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="SillyAssignmentJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="SingleCharAlternation" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
      <option name="processCode" value="true" />
      <option name="processLiterals" value="true" />
      <option name="processComments" value="true" />
    </inspection_tool>
    <inspection_tool class="StandardJS" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="StatementsPerFunctionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="StringLiteralBreaksHTMLJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="Stylelint" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="SwitchStatementWithNoDefaultBranchJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="SyntaxError" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="TailRecursionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="TaskProblemsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="TextLabelInSwitchStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ThisExpressionReferencesGlobalObjectJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="ThreeNegationsPerFunctionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="ThrowFromFinallyBlockJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="TodoComment" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="TrivialConditionalJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="TrivialIfJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="TsLint" enabled="false" level="ERROR" enabled_by_default="false" />
    <inspection_tool class="TypeScriptAccessibilityCheck" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="TypeScriptCheckImport" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="TypeScriptMissingAugmentationImport" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="TypeScriptPreferShortImport" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="TypeScriptUMDGlobal" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="TypeScriptUnresolvedFunction" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="TypeScriptUnresolvedVariable" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="TypeScriptValidateJSTypes" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
    <inspection_tool class="TypeScriptValidateTypes" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="TypescriptExplicitMemberType" enabled="true" level="INFORMATION" enabled_by_default="true" />
    <inspection_tool class="UnnecessaryContinueJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnnecessaryLabelJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnnecessaryLabelOnBreakStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnnecessaryLabelOnContinueStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnnecessaryLocalVariableJS" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="m_ignoreImmediatelyReturnedVariables" value="false" />
      <option name="m_ignoreAnnotatedVariables" value="false" />
    </inspection_tool>
    <inspection_tool class="UnnecessaryReturnJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnreachableCodeJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="UnresolvedReference" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="UnterminatedStatementJS" enabled="true" level="WARNING" enabled_by_default="true">
      <option name="ignoreSemicolonAtEndOfBlock" value="true" />
    </inspection_tool>
    <inspection_tool class="UnusedCatchParameterJS" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="m_ignoreCatchBlocksWithComments" value="false" />
    </inspection_tool>
    <inspection_tool class="UnusedDefine" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="VoidExpressionJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="VueDataFunction" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="VueDuplicateTag" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="W3CssValidation" enabled="false" level="WARNING" enabled_by_default="false">
      <option name="myCssVersion" value="css3" />
      <option name="myIgnoreVendorSpecificProperties" value="false" />
    </inspection_tool>
    <inspection_tool class="WebpackConfigHighlighting" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="WithStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="XHTMLIncompatabilitiesJS" enabled="false" level="WARNING" enabled_by_default="false" />
    <inspection_tool class="XmlDefaultAttributeValue" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="XmlDuplicatedId" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="XmlHighlighting" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="XmlInvalidId" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="XmlPathReference" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="XmlUnboundNsPrefix" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="XmlUnusedNamespaceDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="XmlWrongRootElement" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="XsltDeclarations" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="XsltTemplateInvocation" enabled="true" level="ERROR" enabled_by_default="true" />
    <inspection_tool class="XsltUnusedDeclaration" enabled="true" level="WARNING" enabled_by_default="true" />
    <inspection_tool class="XsltVariableShadowing" enabled="true" level="WARNING" enabled_by_default="true" />
  </profile>
</component>


text:
title: FL0073
category: how-to
hide_menu: true
---

# FavourReRaise (FL0073)

*Introduced in `0.21.1`*

## Cause

An exception was re-thrown (re-raised) without the use of function `reraise()`.

## Rationale

Using `raise ex` (inside a try..with|ex` block) to re-raise an exception is not ideal, as it loses valuable stacktrace information from the original exception.

## How To Fix

Use `reraise()` instead of `raise ex`.

## Rule Settings

    {
        "favourReRaise": {
           "enabled": true
        }
    }


text:
struct CmosOV3642;;
struct CmosOV8825;

struct ICameraCtrlVisitorBase : IVisitor<CmosOV3642,CmosOV8825> {};

template <typename CLASS, typename RETURN_TYPE> using
CameraCtrlVisitorBase = Visitor<CLASS,RETURN_TYPE,ICameraCtrlVisitorBase,CmosOV3642,CmosOV8825>;


text:
Susy two example
========

This is an example using Silex and Susy two

Install
=========
```bash
$ git clone https://github.com/dmouse/susy-two.git
$ cd susy-two
$ composer install

```

Development
========

```bash
$ cd web/css/Susy
$ compass compile
$ compass watch

```

Requirements
========

* Sass
* Compass
* Breakpoint
* Susy

```bash
$ gem install sass compass breakpoint susy
```


text:
#include "XMLParserThread.h"

#ifdef USE_XML
#include "XMLTool.h"
#include "UserLicenceKey.h"
#include "XMLServerElements.h"
#include "ParserUserHandler.h"
#include "XMLAuthData.h"
#include "ClientSettings.h"

using namespace XMLTool;

bool
XMLParserThread::xmlParseUpdateKeysRequest( DOMNode* cur,
                                            DOMNode* out,
                                            DOMDocument* reply,
                                            bool indent )
try {
   bool ok = true;
   int indentLevel = 1;
   MC2String errorCode;      //errorcode if one should be sent in reply.
   MC2String errorMessage;   //errorMessage if one should be sent in reply

   DOMElement* uhk_reply = reply->createElement(
      X( "update_hardware_keys_reply" ) );
   out->appendChild( uhk_reply );

   MC2String transaction_id;
   getAttrib( transaction_id, "transaction_id", cur );
   uhk_reply->setAttribute( X( "transaction_id" ), X( transaction_id ) );

   // Get input
   uint32 uin;
   getAttribValue( uin, "uin", cur );
   MC2String client_type;
   getAttribValue( client_type, "client_type", cur );
   MC2String client_type_options;
   getAttribValue( client_type_options, "client_type_options", cur );
   const ClientSetting* setting = m_group->getSetting(
      client_type.c_str(), client_type_options.c_str() );
   // Hardware key(s)
   DOMNodeList* hwdNodes = static_cast<DOMElement*>( cur )
      ->getElementsByTagName( X( "hardware_key" ) );
   for ( uint32 i = 0 ; i < hwdNodes->getLength() ; ++i ) {
      m_authData->hwKeys.push_back( UserLicenceKey( MAX_UINT32 ) );
      m_authData->hwKeys.back().setProduct(
         setting->getProduct() );
      MC2String type;
      XMLTool::getAttribValue( type, "type", hwdNodes->item( i ) );
      m_authData->hwKeys.back().setKeyType( type );
      m_authData->hwKeys.back().setLicence(
         XMLUtility::getChildTextStr( *hwdNodes->item( i ) ) );
   }
   // Find and set best
   getUserHandler()->setBestLicenceKey( m_authData->hwKeys,
                                        m_authData->hwKey );

   // Get the user
   UserItem* userItem = NULL;
   bool commOk = getUser( uin, userItem, true );

   if ( !ok ) {
      // Error above
   } else if ( !m_user->getUser()->getEditUserRights() ) {
      // SECURITY!
      MC2String logonIDString;

      mc2log << warn
             << "XMLParserThread::xmlParseUpdateKeysRequest "
             << "Access denied to user "
             << (userItem ? userItem->getUser()->getLogonID() :
                 "[No such user]")
             << "(" << uin << ")"
             << " for " << m_user->getUser()->getLogonID()
             << "(" << m_user->getUIN() << ")"
             << endl;
      errorCode = "-1";
      errorMessage = "Access denied.";
      ok = false;
   } else if ( userItem != NULL ) {
      // Licence to user
      int status = getUserHandler()->licenceTo(
         userItem->getUser(), &m_authData->hwKey );
      ok = status == 0;

      if ( status == 0 ) {
         errorCode = "0";
         errorMessage = "";
      } else if ( status == -2 ) {
         errorCode = "-3";
         errorMessage = "Timeout updating user.";
      } else {
         errorCode = "-1";
         errorMessage = "Error updating user";
      }
   } else {
      // Check getUser status
      errorCode = "-1";
      if ( !commOk ) {
         errorMessage = "Database connection error, no connection.";
      } else {
         errorMessage = "No such user!";
      }

      ok = false;
   }

   releaseUserItem( userItem );

   if ( !ok ) {
      XMLServerUtility::
         appendStatusNodes( uhk_reply, reply, 0, false,
                            errorCode.c_str(), errorMessage.c_str() );
      ok = true; // Handled error
   }

   if ( indent ) {
      XMLUtility::indentPiece( *uhk_reply, indentLevel );
   }
   return ok;

} catch ( const XMLTool::Exception& e ) {
   mc2log << error << "[UpdateKeys]  " << e.what() << endl;
   XMLServerUtility::
      appendStatusNodes( out->getFirstChild(), reply, 1, false,
                         "-1", e.what() );
   return false;

}

#endif // USE_XML


text:
const dotenv = require("dotenv");
const fs = require("fs-extra");
const _ = require("lodash");
const proGulp = require("pro-gulp");

const {NODE_ENV, BUILD_DIR} = require("../config");

module.exports = proGulp.task("config", () => {
    var config = {};
    if (NODE_ENV === "development") {
        // In development, read from the `.env` file
        try {
            const env = fs.readFileSync(`${process.cwd()}/.env`);
            config = dotenv.parse(env);
        } catch (ignore) {
            console.log("Failed to read configuration from file `.env`");
        }
    }
    if (NODE_ENV === "production") {
        // In production, read from the `process.env` but only those variables
        // having a key that starts with __APP_CONFIG__
        const prefixRegexp = /^__APP_CONFIG__/;
        config = _(process.env)
            .pickBy((value, key) => prefixRegexp.test(key))
            .mapKeys((value, key) => key.replace(prefixRegexp, ""));
    }
    const code = `window.APP_CONFIG = ${JSON.stringify(config, null, 4)};`;
    fs.ensureDirSync(BUILD_DIR);
    fs.writeFileSync(`${BUILD_DIR}/app-config.js`, code);
});


text:
// source:

package nl.esciencecenter.vlet.grid.voms;

/** VO Server information Holders */
public class VOServer
{
	public String host=null;
	public int port=0;
	public String certFile=null;
	public String hostDN=null;

	public VOServer(String hostv,int portv,String certf,String hostDNv)
	{
		this.host=hostv;
		this.port=portv;
		this.certFile=certf;
		this.hostDN=hostDNv;
	}

	public String toString()
	{
		return "{"+host+":"+port+","+hostDN+"}";
	}

	public String getHostname()
	{
		return host;
	}

	public int getPort()
	{
		return port;
	}

	//public java.net.URI getServerURI()
	//{
	//	return new java.net.URI("https://"+host+":"+port+"/");
	//}

	/** Static List factory method to create list from one server definition */
	public static VOServer[] createList(String hostv, int portv, String certf,String hostDNv)
	{
		VOServer servers[]=new VOServer[1];
		servers[0]=new VOServer(hostv,portv,certf,hostDNv);
		return servers;
	}
}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Thai_Resort.HotelInfo
{
    public class BillingInfo
    {
        public float totalHotel { get; set; }
        public float totalMeal { get; set; }
        public float totalRoomService { get; set; }
    }
}