Skip to content

Instantly share code, notes, and snippets.

View meysampg's full-sized avatar
🖖
bit bit 0 bit

Meysam P. Ganji meysampg

🖖
bit bit 0 bit
View GitHub Profile
@meysampg
meysampg / file_chooser_firefox_snap.sh
Created June 7, 2022 06:34
Solve issue of opening file chooser on firefox (fucking SNAP version)
meysam@smartech:~
$ firefox
Gtk-Message: 10:51:36.982: Failed to load module "canberra-gtk-module"
Gtk-Message: 10:51:36.983: Failed to load module "canberra-gtk-module"
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
Missing chrome or resource URL: resource://gre/modules/UpdateListener.jsm
(firefox:2169453): Gtk-WARNING **: 10:51:49.473: Can't open portal file chooser: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.FileChooser” on object at path /org/freedesktop/portal/desktop
@meysampg
meysampg / ArgumentParser.scala
Created May 25, 2022 10:42
CLI argument parser for Scala2
package ir.mpgutils.utils
import scala.annotation.tailrec
class UnknownArgumentException(val msg: String) extends Exception(msg)
/**
* Parse CLI arguments to a Map[String, String].
*
* Example:
@meysampg
meysampg / cleanup.git
Created February 21, 2022 10:42
Cleanup Git Repository
# git config --global --edit
[alias]
cleanup = "!git branch --merged master | grep -v '\\*\\|master\\|main\\|develop' | xargs -n 1 -r git branch -d"
cleanup-remote = "!git branch --remote --merged master | grep -v '\\*\\|master\\|main\\|develop' | xargs -n 1 -r git branch -r -d"
@meysampg
meysampg / toCurl.kt
Created February 14, 2022 12:59
Convert HttpURLConnection to Curl Command in Kotlin
fun toCurl(connection: HttpURLConnection, body: ByteArray): String {
var builder = "curl -v "
builder += "-X " + connection.requestMethod + " \\\n "
for (entry in connection.requestProperties) {
builder += "-H \"" + entry.key + ":"
for (value in entry.value)
builder += " $value"
@meysampg
meysampg / distributed_systems_readings.md
Created August 23, 2021 07:19 — forked from mrzasa/distributed_systems_readings.md
distributed systems readings

#Distributed System Course List

##Systems

  • Cornell CS 614 - Advanced Course in Computer Systems - Ken Birman teaches this course. The readings cover more distributed systems research than is typical (which I am in favour of!). In fact, there's barely anything on traditional internal OS topics like filesystems or memory management. There's some worthwhile commentary at the bottom of the page.

  • Princeton COS 518 - Advanced Operating Systems - short and snappy reading list of two papers per topic, covering some interesting stuff like buffering inside the operating system, and L4.

@meysampg
meysampg / plot_regression_with_confidence_interval.py
Created June 13, 2021 05:46
Regression Plot with Confidence Interval in Python + Matplotlib + Seaborn
import matplotlib.pyplot as plt
import seaborn as sns
def parse_points(s):
return map(lambda x: map(int, x.strip().split(",")), filter(len, s.split("\n")))
def get_xy(points):
x = []
@meysampg
meysampg / scan_cassandra_unknown_fields.go
Created June 10, 2021 11:04
Scan a CQLSh query in golang with unknown fields
package query
// THIS CODE IS NOT SUITABLE FOR USING IN THE PRODUCTION.
// YOU SHOULD TAKE CARE ABOUT DB TYPES AND ERROR HANDLING.
// ANOTHER OPTIMIZATION CAN BE IN CHANGING []map[string]interface{}
// TO map[string][]interface{}
import (
"time"
@meysampg
meysampg / run_spark_inside_intellij_idea.md
Last active June 10, 2021 10:53
Describe how to submit Spark application into a cluster and showing the result inside Intellij IDEA
  1. Add bin folder of your Spark installation into the $PATH environmental variable

  2. Add a SBT Task configuration and input package inside the Tasks box

  3. Uncheck the Activate tool window and press Apply

  4. Add a Shell Script configuration and select Script text as Execute: value

  5. Insert

@meysampg
meysampg / template_io_test.md
Created June 1, 2021 12:04
fio/ioping template for test IO

Disk Test Speed

All tests are time based and limited to 60 seconds.

Sequnetial Random 4G Read

$ fio --randrepeat=1 --ioengine=libaio --direct=1 --gtod_reduce=1 --name=test --filename=random_read.fio --bs=4k --size=4G --readwrite=randread --runtime=60 --time_based --numjobs=1 --iodepth=1 --end_fsync=1

@meysampg
meysampg / CMakeLists.txt
Created May 23, 2021 08:41
CMakeLists file for using OpenMP inside of a C++ project
cmake_minimum_required(VERSION 3.19)
project(jacobi_method)
set(CMAKE_CXX_STANDARD 14)
find_package(OpenMP)
if (OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")