Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Mohammad H. Sattarian mhsattarian

🎯
Focusing
View GitHub Profile
@mhsattarian
mhsattarian / areaToTableSpec.ts
Created Jul 31, 2021
Generate an object describing a table row and cells (with `colspan` an `rowspan` support) from a text representing cells like CSS grid areas.
View areaToTableSpec.ts
interface ITableCellSpec {
id: string;
rows: number;
columns: number;
origin: { rowIndex: number; cellIndex: number };
}
const areaToTableSpec = (arr: string[][]) => {
const output: ITableCellSpec[][] = [];
View use_screenshot.js
// Code from https://github.com/leighhalliday/generate-og-image/blob/master/src/chromium.ts
// and https://github.com/wesbos/wesbos/blob/master/functions/ogimage/ogimage.js
// and thanks wes.bos for the video on this at https://youtu.be/A0Ww-SU7K5E
exports.handler = async (event, context, callback) => {
const url = event.queryStringParameters.url;
const r = await fetch(
`https://publish.twitter.com/oembed?url=${url}&hide_thread=true`
).then((r) => r.json());
View screenshot_html_element.js
// Code from https://github.com/leighhalliday/generate-og-image/blob/master/src/chromium.ts
// and https://github.com/wesbos/wesbos/blob/master/functions/ogimage/ogimage.js
// and thanks wes.bos for the video on this at https://youtu.be/A0Ww-SU7K5E
async function getScreenshot(html, isDev) {
const options = await getOptions(isDev);
console.log("📸");
const browser = await puppeteer.launch(options);
const page = await browser.newPage();
@mhsattarian
mhsattarian / screenshot_example.js
Last active Jul 9, 2020
Using puppeteer-core and chrome-aws-lamba to screenshot a web element
View screenshot_example.js
// Code from https://github.com/leighhalliday/generate-og-image/blob/master/src/chromium.ts
// and https://github.com/wesbos/wesbos/blob/master/functions/ogimage/ogimage.js
// and thanks wes.bos for the video on this at https://youtu.be/A0Ww-SU7K5E
const chrome = require("chrome-aws-lambda");
const puppeteer = require("puppeteer-core");
const exePath = "/usr/bin/google-chrome";
async function getOptions(isDev) {
@mhsattarian
mhsattarian / Download-Springer-Free-Ebooks.md
Last active Apr 30, 2020
Springer Publications has recently released a huge list of books that are now free to access, Lets grab download links fr
View Download-Springer-Free-Ebooks.md

Download Springer Free Ebooks

Springer Publications has recently released a huge list of books that are now free to access, Let's grab download links for them.

Ebook links

List of books is available as an google sheet. you can also use this repository to download them. but, it's a python script to download them and is probably slow and as far as I checked is not using download managers like aria2, so I decided to grab the download links automatically and download them using IDM.

View connecting using serial console.md

Install minicom to access serial console:

sudo pacman -S minicom

run minicom :

sudo minicom -D /dev/ttyUSB0
@mhsattarian
mhsattarian / polyline.js
Last active Dec 10, 2019
Geohash polyline decode and encode. use google's utility for interactive encoding: https://developers.google.com/maps/documentation/utilities/polylineutility
View polyline.js
'use strict';
/**
* Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm)
*
* Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js)
* by [Mark McClure](http://facstaff.unca.edu/mcmcclur/)
*
* @module polyline
*/
@mhsattarian
mhsattarian / JNB_endpoint.ipynb
Last active Nov 3, 2019 — forked from psychemedia/SimpleAPI.ipynb
Using Jupyter Notebooks as Rest API Endpoint
View JNB_endpoint.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mhsattarian
mhsattarian / command
Created Jan 10, 2019
Requires Imagemagick to be installed
View command
magick mogrify -gravity south -extent x87+0-20 -background transparent a.png
@mhsattarian
mhsattarian / Sights of Experience.md
Last active Nov 15, 2018
Instructions I found helpful to solve problems or install various packages and softwares on my Manjaro linux.
View Sights of Experience.md

Sights of Experience!

Instructions I found helpful to solve problems or install various packages and softwares on my Manjaro linux.