Skip to content

Instantly share code, notes, and snippets.

View peymanmajidi's full-sized avatar
:octocat:
Github Pro User

Peyman Majidi Moein peymanmajidi

:octocat:
Github Pro User
View GitHub Profile
@peymanmajidi
peymanmajidi / cipher.ipynb
Last active April 26, 2022 09:29
Code and decode ROX13 & Caesar Cipher
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@peymanmajidi
peymanmajidi / EasyRest.cs
Created February 22, 2022 08:29
Easy Rest API With Serialize and Deserialize
public bool EasyRest(long sortingDataId, out string error, out int error_code, out bool fatal)
{
var httpWebRequest = (HttpWebRequest)WebRequest.Create(Api.ApiOptions.LightSortingConfirmationURL);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("Authorization", $"{ApiOptions.TokenType} {ApiOptions.Token}");
error_code = 0;
fatal = false;
@peymanmajidi
peymanmajidi / Persian Culture Initializer
Created September 19, 2021 05:38
Intilize persian culture means every usage of DateTime becomes to Hijri and there is no any concern and extra work needed. Simply print datetime in Hijri by `DateTime.Now` or in SQL Server Transactions.
public class Cultures
{
// Call this method to initialize Persian Hijri culture
public static void InitPersian()
{
InitCulture("fa-ir", new[] { "ی", "د", "س", "چ", "پ", "ج", "ش" },
new[] { "یکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه" },
new[]
{
"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی",
@peymanmajidi
peymanmajidi / contribute.gif
Last active January 1, 2022 20:22
contribute.gif
contribute.gif
@peymanmajidi
peymanmajidi / NTFS partition mount as read only.sh
Last active February 21, 2021 08:07
NTFS partition mount as read only?
sudo ntfsfix /dev/sdxX # where x is HDD and X is drive number, in my case it was /dev/sda1
# remove any logfile created by windows.
@peymanmajidi
peymanmajidi / basic_motion_detection_opencv_python.py
Created February 14, 2021 13:28 — forked from pknowledge/basic_motion_detection_opencv_python.py
Motion Detection and Tracking Using Opencv Contours
import cv2
import numpy as np
cap = cv2.VideoCapture('vtest.avi')
frame_width = int( cap.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height =int( cap.get( cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc('X','V','I','D')
@peymanmajidi
peymanmajidi / DateConvertor.cs
Created November 29, 2020 08:55
DateTime To Shamsi(Persian/Iran) Format
public static string ToShamsi(this DateTime value)
{
PersianCalendar pc=new PersianCalendar();
return pc.GetYear(value) + "/" + pc.GetMonth(value).ToString("00") + "/" +
pc.GetDayOfMonth(value).ToString("00");
}
@peymanmajidi
peymanmajidi / linkedin.js
Created November 22, 2020 16:43
Auto Accept LinkedIn Following Request
var x = document.querySelectorAll("[aria-label^='Accept']");
for (var i = 0; i < x.length; i++) {
x[i].click();
}
@peymanmajidi
peymanmajidi / ConsoleDependencyInjection.cs
Last active November 28, 2020 11:28
DotNet Core Dependency Injection in Console App
private static ParcelsRepository _parcelsRepository;
static void Main(string[] args)
{
var configuration = new ConfigurationBuilder().AddJsonFile("appsettings.json").Build();
var cn = configuration.GetConnectionString("CrossbeltDataContext");
var options = new DbContextOptionsBuilder<CrossbeltDataContext>();
options.UseSqlServer(cn);
@peymanmajidi
peymanmajidi / .bashrc
Created June 21, 2020 04:55
My Prefered .bashrc to make my bash more useful when I'm using git
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)