Skip to content

Instantly share code, notes, and snippets.

View jymcheong's full-sized avatar

Jym Cheong jymcheong

View GitHub Profile
@jordanthomas
jordanthomas / jaro-winkler.js
Last active April 7, 2021 00:50
The Jaro-Winkler distance metric in JavaScript. See also: https://github.com/jordanthomas/jaro-winkler
var distance = function(s1, s2) {
var m = 0;
// Exit early if either are empty.
if ( s1.length === 0 || s2.length === 0 ) {
return 0;
}
// Exit early if they're an exact match.
if ( s1 === s2 ) {
@augustoproiete
augustoproiete / ReadingPortableExecutable_PE_header.cs
Created December 6, 2016 04:03
Reading the Portable Executable (PE) header in C#
// Credits: John Stewien
// From: http://code.cheesydesign.com/?p=572
/*
Reading the Portable Executable (PE) header in C#
My job consists of writing fully custom applications for groups of people. The time pressure of these projects is quite high, so generally people start using the application while I’m still writing it, which means I write it modularly and add features as I go along. I also fix bugs as they are discovered. My clients are 2 tiered where expert users get a new build first, they test if for a while, and if they think it’s acceptable they then pass it on to others.
This method of distribution is quite ad-hoc so when a client rings me up and asks me to view their screen to look at something, it’s useful to know what build they are running. To facillitate this I print the link date in the main Window Title so I instantly have an idea about how old the version is that I am looking at. This date is calculated at run time. To do this requires reading in the Portable Executable (PE) header from th
@wesbos
wesbos / async-await.js
Created February 22, 2017 14:02
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@sparksbat
sparksbat / ProcessUtils.cs
Created October 24, 2017 21:23
C# Get Foreground Process
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace FGWindow
{
class ProcessUtils
{
[DllImport("user32.dll")]
private static extern IntPtr GetForegroundWindow();
@timebotdon
timebotdon / telegram_log_sender.sh
Last active January 17, 2025 07:49
Simple shell script to forward logs to a Telegram bot.
#!/bin/bash
## Credit: admin@Shellhacks
## Article URL: https://www.shellhacks.com/telegram-api-send-message-personal-notification-bot/
## Define Vars
token= #Telegram bot API token
chatID= #Telegram Chat ID
sendURL="https://api.telegram.org/bot$token/sendMessage"
logFile="/var/log/auth.log"
@wise-io
wise-io / InstallZeroTier.ps1
Last active January 28, 2025 03:32
Installs Latest ZeroTier One Client
<#
.SYNOPSIS
Installs ZeroTier
.DESCRIPTION
Install ZeroTier and join/configure ZeroTier network
.EXAMPLE
./ios-InstallZeroTier.ps1
.NOTES
This script will install PowerShell 7 if it is not present.
A UAC prompt will appear during install if -UI is used.