Skip to content

Instantly share code, notes, and snippets.

View vaibhavpandeyvpz's full-sized avatar
🐢
I may be slow to respond.

Vaibhav Pandey vaibhavpandeyvpz

🐢
I may be slow to respond.
View GitHub Profile
@vaibhavpandeyvpz
vaibhavpandeyvpz / Fingerprint.cs
Last active February 11, 2024 11:09
Generate unique device ID or fingerprint for licensing etc. on Windows based system.
using System;
using System.Linq;
using System.Management;
using System.Security.Cryptography;
using System.Text;
namespace DeviceID
{
internal class Fingerprint
{
@vaibhavpandeyvpz
vaibhavpandeyvpz / Dockerfile
Created September 22, 2023 11:16
Chromium's Docker image based on AlpineLinux
FROM alpine:3
RUN apk update && apk upgrade
RUN apk add --no-cache chromium chromium-chromedriver
RUN mkdir -p /usr/src/app \
&& adduser -D chromium \
&& chown -R chromium:chromium /usr/src/app
@vaibhavpandeyvpz
vaibhavpandeyvpz / infosec-iq-qa.js
Last active June 15, 2022 16:08
Complete a InfoSec institute course automatically.
function getCsrfToken() {
var parts = ('; ' + document.cookie)
.split("; csrf=");
if (parts.length === 2) {
const value = parts.pop().split(";").shift();
return decodeURIComponent(value);
}
}
function sendXhr(url, method, data = null, headers = {}) {
@vaibhavpandeyvpz
vaibhavpandeyvpz / e164_format.php
Last active May 26, 2022 04:24
Normalize phone number inputs from user to E.164 format.
<?php
/**
* @param string|null $number
* @return string|null
*/
function normalize_to_e164(?string $number): ?string
{
if (empty($number)) {
return null;
@vaibhavpandeyvpz
vaibhavpandeyvpz / Dockerfile.ms
Created May 13, 2022 04:27
Run Meilisearch server on Apple (M1) silicon using Docker, for Laravel
FROM ubuntu
WORKDIR /meilisearch
RUN apt-get update && \
apt-get install -y libc6-dev wget
RUN wget -O exe https://github.com/meilisearch/MeiliSearch/releases/download/v0.12.0/meilisearch-linux-armv8 && \
chmod a+x exe
@vaibhavpandeyvpz
vaibhavpandeyvpz / Button.jsx
Last active February 23, 2022 05:47
Creating themed components based on styled.div
import { darken, getLuminance } from 'polished';
import styled, { css } from 'styled-components';
const isDarkColor = color => getLuminance(color) <= .5;
const Button = styled.button`
background: white;
border: 1px solid black;
color: black;
cursor: pointer;
@vaibhavpandeyvpz
vaibhavpandeyvpz / HasUuidAsPrimaryKey.php
Created February 4, 2022 03:05
Generate and use UUIDs as primary keys in Laravel
<?php
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;
trait HasUuidAsPrimaryKey
{
public static function bootHasUuidAsPrimaryKey()
{
static::creating(function (Model $model) {
@vaibhavpandeyvpz
vaibhavpandeyvpz / 00-common-aws-policies.md
Last active February 22, 2022 05:01
Common policies for AWS/IAM

This Gist includes some of the common AWS/IAM policy examples to give granular access to users.

@vaibhavpandeyvpz
vaibhavpandeyvpz / guide.md
Last active December 2, 2021 08:17
Send SSH login notifications to Slack

Setting up notifications for successful SSH logins to Slack on a Linux server is pretty easy. Before everything, please make sure to create a Slack app (if not already), add a Webhook and keep its URL handy.

To get started, login to your instance as root (or as a sudoer user) and run below commands:

# create a directory in /opt
sudo mkdir -p /opt/ssh2slack

# paste the contents from file included and save it with Ctrl+O and Ctrl+X
sudo nano /opt/ssh2slack/slack_message.json
@vaibhavpandeyvpz
vaibhavpandeyvpz / metabase.md
Last active December 1, 2021 20:05
Running Metabase + Nginx + SSL on Ubuntu

First get Docker installed and setup on machine. Once installed, create a new user e.g., metabase for your installation using following command:

sudo adduser metabase

Now add the newly created user to docker group, you won't need sudo for docker ... commands:

sudo usermod -aG docker metabase