Skip to content

Instantly share code, notes, and snippets.

View black-dragon74's full-sized avatar
💭

Niraj Yadav black-dragon74

💭
View GitHub Profile
@black-dragon74
black-dragon74 / JSONLoader.swift
Created September 22, 2019 09:56
A helper class to decode JSON data from a JSON file in the bundle or from a `Data` object instance. The class exposes two static functions that user can call without initializing the class.
//
// JSONLoader.swift
// Load JSON from file and data objects effortlessly
//
// Created by Nick on 9/22/19.
// Copyright © 2019 Nick. All rights reserved.
//
import Foundation
@black-dragon74
black-dragon74 / PageViewIndicator.dart
Created April 19, 2020 13:43
A companion widget to PageView in Flutter that provides iOS style page indicators and also provide scroll on tap.
//
// Code is poetry
//
// Created by Nick aka black-dragon74
//
import 'dart:math';
import 'package:flutter/material.dart';
class PageViewIndicator extends AnimatedWidget {
@black-dragon74
black-dragon74 / FixLoveGreenPencilsMalware.sh
Created December 2, 2020 21:04
Fixes love green pencils wordpress malware
#!/bin/bash
# Regex to fix DB is: "s/<script[\s\S]*?>[\s\S]*?<\/script>//g"
totalInfections=0
filesProcessed=0
echo "Welcome to lovegreenpencils malware fixer by black-dragon74"
echo "This fix is divided into 3 phases."
echo "Phase 1 fixes the \`beckup\` files."
@black-dragon74
black-dragon74 / DifferenceArrays.java
Created December 2, 2020 21:16
Difference Arrays
package com.blackdragon74;
import java.util.Scanner;
class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int M = scan.nextInt();
@black-dragon74
black-dragon74 / SudokuSolver.py
Created December 2, 2020 21:19
Solve sudoku fast AF
def find_next_empty(puzzle):
for r in range(9):
for c in range(9):
if puzzle[r][c] == 0:
return r, c
return None, None
def is_valid(guess, puzzle, row, col):
# First check the rows
@black-dragon74
black-dragon74 / compute_sha256.c
Created January 12, 2022 17:50
New way to Calculate SHA256Sum from OpenSSL v3
#include <stdio.h>
#include <string.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define EVP_MD_CTX_new EVP_MD_CTX_create
#define EVP_MD_CTX_free EVP_MD_CTX_destroy
#endif
@black-dragon74
black-dragon74 / shortpath.sh
Last active March 8, 2025 00:03
A neat script to print the shortpath of current working directory
#!/usr/bin/env bash
# A nifty utility that prints the PWD in a shortened format.
# Place this file in your PATH by removing the .sh extension
# If path is: /Our/Custom/path/to/dir
# It will output: /O/C/p/t/dir
# For directories inside $HOME, ~ is used.
path="${1:-$(</dev/stdin)}"
home="$HOME"
@black-dragon74
black-dragon74 / convert_to_epub.sh
Created March 8, 2025 10:51
Convert Apple Books or iTunes Books to general EPUB format
#!/usr/bin/env bash
for f in *.epub; do
if [ -d "$f" ]; then
echo "Converting: $f"
cd "$f"
find . -name "iTunesMetadata*.plist" -delete 2>/dev/null
zip -0X "../tmp.epub" mimetype >/dev/null
@black-dragon74
black-dragon74 / guess.py
Created March 21, 2025 10:52
A script to guess encryption key for JioFiber routers
#!/usr/bin/env python3
"""
Code is poetry; script by black-dragon74
Use this script to guess the encryption key for your JioFiber router.
You need to generate a backup and provide it as an input to this script.
The script will provide you the encryption key if it is successful, use ONLY that key