Skip to content

Instantly share code, notes, and snippets.

View alimbada's full-sized avatar

Ammaar Limbada alimbada

View GitHub Profile
@mikeminutillo
mikeminutillo / ProjectDependencies.cs
Created June 12, 2015 01:25
Get project dependency graph out using yuml.me and LINQPad
void Main()
{
var ignores = new Regex[]
{
new Regex(@"Approval"),
new Regex(@"Test"),
new Regex(@"Demo")
};
var serviceControl = @"C:\Code\Particular\ServiceControl\src\";
Util.Image("http://yuml.me/diagram/scruffy;scale:150/class/" + String.Join(",", GetDependencies(serviceControl, ignores))).Dump();
@bradwilson
bradwilson / gist:2229275
Created March 28, 2012 18:41
Scorch PowerShell script for mixed Git/TFS environments
& taskkill /f /im msbuild.exe
if ((get-gitstatus) -ne $null) {
& git clean -xdf -e *.suo -e packages/*
} else {
& tfpt scorch . /recursive /deletes /diff /noprompt /exclude:"*.suo,.\packages"
}
curl -u admin -k -d command=poweroff -d shutdown_option=1 -d OPERATION=set -d PAGE=System -d OUTER_TAB=tab_shutdown -d INNER_TAB=none https://{$1}/get_handler|awk -F"message>" '{print $2}'|awk -F"</" '{print $1}'
or
curl -u admin:netgear1 -k -d command=poweroff -d shutdown_option=1 -d OPERATION=set -d PAGE=System -d OUTER_TAB=tab_shutdown -d INNER_TAB=none https://10.20.0.102/get_handler
or
curl -u $user:$pass -k "https://$host/admin/index.cgi?CURRENTTAB=Shutdown&CURRENTPAGE=System&MODE=Advanced&button=Current&command=poweroff&MODIFIED=1" >/dev/null 2>/dev/null
@czaux
czaux / DNSExternalResolver.py
Last active June 7, 2021 14:05
Get External IP with whoami.cloudflare and DNSPython
import dns.resolver #dnspython
my_resolver = dns.resolver.Resolver()
#Cloudflares DNS Server
my_resolver.nameservers = ['1.1.1.1']
#Get IP from cloudflare chaosnet TXT record
#https://community.cloudflare.com/t/can-1-1-1-1-be-used-to-find-out-ones-public-ip-address/14971/6
result = my_resolver.resolve("whoami.cloudflare","TXT", "CH", tcp=True, lifetime=15)
response = result.response
answer = response.answer
ExternalIP = str(list(answer[0])[0]).replace('"', '')
@bzerangue
bzerangue / mac-trim-support-non-apple-ssd.markdown
Created June 25, 2012 02:39
Enabling TRIM Support on Mac OS X with Non-Apple SSDs

How To: Enable TRIM with Non-Apple SSD

The guide breaks the process down into three steps, all performed via copying and pasting the code snippets through the terminal window. To launch a terminal window, open the Utilities folder inside the Applications folder and select terminal.

The first step makes a backup of the original IOAHCIBlockStorage file called IOAHCIBlockStorage.original. You will be prompted to enter in your system password when using the "sudo" command, since you are modifying system files. Copy and paste the code into the terminal window, a successful or uneventful response is a new blank terminal line.

sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original

Next the code patches the IOAHCIBlockStorage file, removing the requirements that the SSD be made by Apple. Copy and paste t

@mariusGundersen
mariusGundersen / gist:6925246
Last active May 8, 2022 20:38
Programmer collective nouns
@braian87b
braian87b / relayd-igmpproxy.sh
Last active October 22, 2023 12:32
How to setup Client Bridged / Client Mode / RelayD and IGMPProxy for OpenWRT / LEDE
# Client Bridged / Client Mode / RelayD and IGMPProxy (It works)
# RelayD is to redirect packages and IGMP is for redirect IGMP packages
# Our network is 192.168.1.0/24
# Steps:
# Configure WAN as static
# We should edit our wan iface and put static IP
uci set network.wan='interface'
uci set network.wan.proto='static'
uci set network.wan.ipaddr='192.168.1.239' # Main Network IP
@sukesh-ak
sukesh-ak / README.md
Last active October 26, 2023 10:15
How to Convert OVA to VHDX

How to convert OVA to VHDX

  • Rename .OVA file to .7z
  • Use winrar to extract .vmdk out of it

Read here and install qemu (extract zip file)

https://cloudbase.it/qemu-img-windows/

qemu-img convert "D:\VirtualBox\Open-disk001.vmdk" -O vhdx -o subformat=dynamic "D:\VirtualBox\Open.vhdx"

@dvdsgl
dvdsgl / Monads for a C# dev.md
Last active January 8, 2024 06:11
Monads explained (sort of) to a C# developer

A monad is a fancy word for a generic type of the form MyMonad<T> (a generic type of arity 1).

A monad is special because it adds 'special powers' to the T that it wraps. These 'special powers' won't sound very special to an imperative programmer, so you have to squint to see them but bear with me.

  • IEnumerable<T> is a monad that gives values of type T the special power of nondeterminism, or the ability to 'be' multiple values at once.
  • Nullable<T> is a monad that gives values of type T the special power of nullability, or the ability to be absent.
  • Task<T> is a monad that gives values of type T the special power of asynchronicity, or the ability to be used before they are computed.

The trick with monads comes when you want to play with the T values, because they are inside another type. C# introduced language changes to make dealing with values inside these monads easier: