Skip to content

Instantly share code, notes, and snippets.

View ifarbod's full-sized avatar
🙃
I'm a jack of all trades

iFarbod ifarbod

🙃
I'm a jack of all trades
View GitHub Profile
@ifarbod
ifarbod / deleted_rows_count-trigger.sql
Created May 21, 2023 21:53
count the number of deleted rows using an after-delete trigger
-- count the number of deleted rows using an after-delete trigger
-- sql server 2019
CREATE TABLE Orders (
OrderID int IDENTITY (1, 1) NOT NULL,
Names nchar (15) NULL,
)
GO CREATE TRIGGER Deleted ON Orders FOR DELETE AS
DECLARE @Count int
SELECT @Count = COUNT(*)
FROM DELETED IF @Count > 0 BEGIN PRINT @Count
@ifarbod
ifarbod / android_thermal_sensors.py
Last active March 24, 2023 13:48
Print thermal sensor name and values.
import subprocess
for i in range(0, 95):
print(f"#{i}")
subprocess.run(f"adb shell cat /sys/class/thermal/thermal_zone{i}/type")
temp = int(subprocess.run(f"adb shell cat /sys/class/thermal/thermal_zone{i}/temp", capture_output=True).stdout.decode("utf-8"))
print(temp / 1000)
@ifarbod
ifarbod / bench_fmt.cpp
Created June 4, 2022 20:59
Benchmark std::format vs fmt::format
// Copyright (c) 2018-2022 iFarbod and other contributors. All Rights Reserved.
//
// SPDX-License-Identifier: MIT
#include <format>
#include <vendor/benchmark/include/benchmark/benchmark.h>
#define FMT_USE_FULL_CACHE_DRAGONBOX 1
#include <vendor/fmt/include/fmt/format.h>
@ifarbod
ifarbod / vs2022_mdd_ndk_r23_patch.md
Created April 16, 2022 20:34
Change needed for NDK r23 to work on VS 2022

Path: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Application Type\Android\3.0

22c22
<     <ToolchainPrebuiltRoot_x64_Present Condition="'$(ToolchainPrebuiltRoot_x64_Present)' == '' and '$(HostTag)' == '' and Exists('$(VS_NdkRoot)\toolchains\$(LLVMName)\prebuilt\windows-x86_64') and Exists('$(VS_NdkRoot)\toolchains\$(ToolchainName)-$(ToolchainVersion)\prebuilt\windows-x86_64')">true</ToolchainPrebuiltRoot_x64_Present>
---
>     <ToolchainPrebuiltRoot_x64_Present Condition="'$(ToolchainPrebuiltRoot_x64_Present)' == '' and '$(HostTag)' == '' and Exists('$(VS_NdkRoot)\toolchains\$(LLVMName)\prebuilt\windows-x86_64')">true</ToolchainPrebuiltRoot_x64_Present>

The reason for this is that the second condition is not met, thus not setting ToolchainPrebuiltRoot_x64_Present to true, making HostTag return windows.

// from this
template <typename T, typename U>
inline T Lerp(const T& a, const T& b, const U& t)
{
return a * (1.0 - t) + b * t;
}
// to this:
@ifarbod
ifarbod / find_dxsdk.lua
Created March 15, 2017 23:46
look for dxsdk
-- just do 'dofile()' on this and call the functions
-- should correct the legacy dx sdk fine on most systems
--require "utils"
--included here:
function os.file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
function findRotation(x1,y1,x2,y2)
local t = -math.deg(math.atan2(x2-x1,y2-y1))
if t < 0 then t = t + 360 end;
return t;
end
// TimecycConverter.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <cstdint>
struct TColour
{
uint32_t bRed;
uint32_t bGreen;
#include <Windows.h>
#include <iostream>
#include <string>
#include <cstdint>
#include <vector>
#include <tchar.h>
#include <stdio.h>
struct IplInstEntry
{
@ifarbod
ifarbod / CTN_CLA.md
Last active May 30, 2017 18:30
CTNorth Individual Contributor License Agreement.

CTNorth Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Projects”) made available by CTNorth Team or its affiliates (“CTNorth”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to CTNorth in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact opensource@projectctn.com.

You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.

Copyright License. You hereby grant, and agree to grant, to CTNorth a non-exclusive, pe