Skip to content

Instantly share code, notes, and snippets.

View kungfux's full-sized avatar
👨‍💻

Alexander Fuks kungfux

👨‍💻
View GitHub Profile
@kungfux
kungfux / CustomProfile.cmd
Created May 19, 2020 12:47
Run second copy of Microsoft Teams to use different account on the same PC
@ECHO OFF
REM Use filename as Teams profile name
SET MSTEAMS_PROFILE=%~n0
ECHO - Using profile "%MSTEAMS_PROFILE%"
SET "OLD_USERPROFILE=%USERPROFILE%"
SET "USERPROFILE=%LOCALAPPDATA%\Microsoft\Teams\CustomProfiles\%MSTEAMS_PROFILE%"
ECHO - Launching MS Teams with profile %MSTEAMS_PROFILE%
@kungfux
kungfux / NamespaceAlias.cs
Created August 6, 2018 10:37
Namespace Alias
namespace PC {
// Define an alias for the nested namespace.
using Project = PC.MyCompany.Project;
class A {
void M() {
// Use the alias
Project.MyClass mc = new Project.MyClass();
}
}
namespace MyCompany {
@kungfux
kungfux / DHTTester.ino
Created March 13, 2018 23:08
[Arduino] Example: DHT11 Temperature Humidity Sensor
#include <DHT.h>
#include <DHT_U.h>
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
#define DHTPIN A2 // what digital pin we're connected to
@kungfux
kungfux / AsyncAwait.cs
Last active December 29, 2020 09:35
C# async await example
using System;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
class Program
{
[STAThread]
public static void Main()
{
@kungfux
kungfux / XDatabaseExamples.cs
Last active March 24, 2017 10:14
XDatabase usage examples
// https://github.com/kungfux/xdatabase
using System;
using XDatabase;
namespace Examples
{
public class Test
{
private const string _connectionString = "Data Source=db.sqlite;";
@kungfux
kungfux / Extension.cs
Created December 11, 2016 00:19
How to write extension in .NET
// Example of extensions for IWebElement
using System.Collections.ObjectModel;
namespace OpenQA.Selenium.Extensions
{
public static class WebElement
{
public static void ClearAndSendKeys(this IWebElement webElement, string keys)
{
webElement.Clear();
@kungfux
kungfux / SmallestDivisor.js
Created November 27, 2016 17:52
Find smaller divisor for number
export const smallestDivisor = (a) => {
if (a === 1)
return 1;
const findDivisor = (a, d) => {
if (a % d === 0)
return d;
else
return findDivisor(a, d + 1);
@kungfux
kungfux / BiggerCommonDivisor.js
Last active November 27, 2016 17:52
Find bigger common divisor for two numbers
const biggerCommonDivisor = (a, b) => {
const findDivisor = (a, b, z) => {
console.log(z);
if (a % z === 0 && b % z === 0)
return z;
else
return findDivisor(a, b, z - 1);
};
@kungfux
kungfux / IsPrimeNumber.js
Last active November 27, 2016 17:57
Check is number prime
export const isPrime = (a) => {
let resultCount = 0;
let b = a;
while(b >= 1) {
if (a % b === 0)
resultCount++;
b--;
}
@kungfux
kungfux / SumOfNaturalNumbers.js
Created November 27, 2016 17:43
Calculate sum of natural numbers
const sum = (n, a, b) => {
let result = 0;
for (let i = n - 1; i > 0; i--) {
if (i % a === 0 || i % b === 0) {
result += i;
}
}