Skip to content

Instantly share code, notes, and snippets.

View LordAmit's full-sized avatar

Amit Seal Ami LordAmit

View GitHub Profile
@LordAmit
LordAmit / buffer1.c
Last active October 28, 2022 11:24
Buffer Overflow / Stack Smashing Example
/*
Written by Amit Seal Ami
*/
#include <stdio.h>
#include <string.h>
/*
Instructions
============
@LordAmit
LordAmit / NameGenerator.java
Last active April 16, 2022 17:44
A random name generator written in Java. Did it for fun :|
import java.util.Calendar;
import java.util.Random;
/**
* Just did it for fun. :|
*
* @author amit
*
*/
public class NameGenerator {
@LordAmit
LordAmit / pdf_add_margin_annotation.sh
Last active February 20, 2022 22:14
Adding Right Margin to PDF for Writing Notes or Annotations
#!/bin/sh
## DISCLAIMERS
## 1. This script is not intended to be used as is. It is more like a set of instructions; by no means you are supposed to execute it exactly like this every.single.time.
## 2. Credit for mentioning pdf-crop-margins goes to https://unix.stackexchange.com/a/638371
# go to your desired directory
cd ~/git/pdfcropmargin
# create a venv
python3 -m venv venv
@LordAmit
LordAmit / pdf_optimize_script.sh
Last active February 19, 2022 21:50
Using GhostScript to optimize PDF file size while maintaining full texts
#!/bin/sh
# /screen can be changed to the following:
# /screen selects low-resolution output similar to the Acrobat Distiller (up to version X) "Screen Optimized" setting.
# /ebook selects medium-resolution output similar to the Acrobat Distiller (up to version X) "eBook" setting.
# /printer selects output similar to the Acrobat Distiller "Print Optimized" (up to version X) setting.
# /prepress selects output similar to Acrobat Distiller "Prepress Optimized" (up to version X) setting.
# /default selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.
# from https://www.ghostscript.com/doc/9.54.0/VectorDevices.htm
# Script copied and modified from https://stackoverflow.com/questions/10450120/optimize-pdf-files-with-ghostscript-or-other
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=output.pdf $1
@LordAmit
LordAmit / _amit_highlight.scss
Last active July 22, 2020 21:20
a syntax highlighter theme based on lots of other themes. The difference? I made sure that I picked colors which has a good contrast in terms of accessibility. You can use it with Jekyll, rouge, pygments, whatever floats your boat. :)
// based on friendly and more.
// an accessible, eye-friendly syntax highlighter theme based on lots of other themes.
// The difference? I made sure that I picked colors with good contrast in terms of accessibility.
// You can use it with Jekyll, rouge, pygments, whatever floats your boat. :)
// I checked the colors using Chrome Developer tools for color contrast.
// Please let me know if I missed anything, or if you have any suggestions.
// code style
code {
<!doctype html>
<html amp lang="en">
<head>
{% include meta.html %}
<link rel="canonical" href="{{ site.url}}{{site.baseurl}}{{ page.url | replace: '/amp', '' }}">
<title>{% if page.title %}{{ page.title }} – {% endif %}{{ site.name }}</title>
{% capture styles %}
{% include amp_style.scss %}
{% endcapture %}
<style amp-custom>
@LordAmit
LordAmit / img.html
Created June 27, 2018 07:25
hugo amp lightbox image shortcode with unique ID assignment
<!-- you also need to add the following script
<script async custom-element="amp-image-lightbox" src="https://cdn.ampproject.org/v0/amp-image-lightbox-0.1.js"></script>
-->
{{$unique_id := now.UnixNano}}
<amp-image-lightbox id="{{ $unique_id }}"
layout="nodisplay"></amp-image-lightbox>
<figure {{ if .Get "class" }} class='{{ .Get "class" }}'
{{else}} class="image-center" {{ end }} >
<amp-img
on='tap:{{ $unique_id }}'
@LordAmit
LordAmit / data_structure.py
Created July 5, 2013 13:13
Linked List, Stack, Queue implementations in Python. Might be wrong somewhere due to my lack of skill in Python. Please leave a comment in case you notice anything I should fix.
# -*- coding: utf-8 -*-
#!/usr/bin/python
from cssutils.util import Item
#==============================================================================
# Written following the example by Graham.
# IMHO, there was problem with the stack pop method. Even though
# tail pointed to the previous object in the linked list right after pop,
# the tail kept pointing at the popped Item.
#Written by Amit
from typing import Union
from typing import Type
class A():
a: int = 0
b: int = 0
class B():
from typing import Union
class A():
a: int = 0
b: int = 0
class B():
a: int = 0
b: int = 0