Skip to content

Instantly share code, notes, and snippets.

View AliAlmasi's full-sized avatar
📚
Studying for the entrance exam (Konkour)

Ali Almasi AliAlmasi

📚
Studying for the entrance exam (Konkour)
View GitHub Profile
@AliAlmasi
AliAlmasi / FormMove.cs
Last active June 23, 2024 17:46
Makes a Windows Form Application program movable when user drags any part of the form.
namespace WindowsFormApplication1 {
public partial class Form1: Form {
public Form1() {
InitializeComponent();
}
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[System.Runtime.InteropServices.DllImport("user32.dll")]
@AliAlmasi
AliAlmasi / IrIdNumberCheck.js
Created June 17, 2024 15:49
Iranian ID number checker, implemented with JS
function IrIdCheck(code) {
var L = code.length;
if (L < 8 || parseInt(code, 10) === 0) return false;
code = ('0000' + code).substr(L + 4 - 10);
if (parseInt(code.substr(3, 6), 10) === 0) return false;
int c = parseInt(code.substr(9, 1), 10);
int s = 0;
for (int i = 0; i < 9; i++)
s += parseInt(code.substr(i, 1), 10) * (10 - i);
s = s % 11;
@AliAlmasi
AliAlmasi / PersianDate.js
Created December 15, 2023 23:00
A better way to use Persian Calendar in JS.
class PersianDate extends Date {
constructor(...args) {
super(...args);
}
toLocaleDateString = () => super.toLocaleDateString("fa-IR-u-nu-latn");
getParts = () => this.toLocaleDateString().split("/");
getDay = () => (super.getDay() === 6 ? 0 : super.getDay() + 1);
getDate = () => this.getParts()[2];
getMonth = () => this.getParts()[1] - 1;
@AliAlmasi
AliAlmasi / Preload CSS - Not blocking CSS.html
Created November 24, 2023 21:10 — forked from thedaviddias/Preload CSS - Not blocking CSS.html
Preload CSS and don't block the DOM with your CSS file request.
<link rel="preload" href="css/global.min.css" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="css/global.min.css"></noscript>
<script>
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(a){"use strict";var b=function(b,c,d){function j(a){if(e.body)return a();setTimeout(function(){j(a)})}function l(){f.addEventListener&&f.removeEventListener("load",l),f.media=d||"all"}var g,e=a.document,f=e.createElement("link");if(c)g=c;else{var h=(e.body||e.getElementsByTagName("head")[0]).childNodes;g=h[h.length-1]}var i=e.styleSheets;f.rel="stylesheet",f.href=b,f.media="only x",j(function(){g.parentNode.insertBefore(f,c?g:g.nextSibling)});var k=function(a){for(var b=f.href,c=i.length;c--;)if(i[c].href===b)return a();setTimeout(function(){k(a)})};return f.addEventListener&&f.addEventListener("load",l),f.onloadcssdefined=k,k(l),f};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
/*! loadCSS rel=preload po

RTL8821CE Wireless card fix on Linux Mint (or any other Debian/Ubuntu based distros)

For some reason, the rtl8821ce WiFi hardware works poorly or not at all on most Linux distros. Apparently, the driver used in the Linux kernel for this hardware is outdated or for other reasons that I don't know about, it doesn't work properly. The solution to this problem is a driver developed by a friend from Portugal and placed on GitHub.

In this guide, we want to build and install this driver.

Warning: Before proceeding, take a Timeshift snapshot for safety.

Open a Terminal and follow along:

  1. Update your APT: sudo apt update
@AliAlmasi
AliAlmasi / Counter.js.html
Created October 17, 2023 00:27
Simple counter w/ JS
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Counter.Js</title>
<style>
*,
*::before,
*::after {
@AliAlmasi
AliAlmasi / index.html
Created August 20, 2023 22:04
Dark Mode w/ JS
<html data-theme="light">
<head>
<title>Dark Mode w/ JS</title>
<style>
[data-theme="light"] {
--color-bg: #e5e5e5;
--color-fg: #0f0f0f;
}
[data-theme="dark"] {
@AliAlmasi
AliAlmasi / dinoCheat.js
Created July 8, 2023 02:01
Cheat for dino game on Google Chrome
javascript: function keyDown(e) {
Podium = {};
var n = document.createEvent("KeyboardEvent");
Object.defineProperty(n, "keyCode", {
get: function () {
return this.keyCodeVal;
},
}),
n.initKeyboardEvent
? n.initKeyboardEvent("keydown", !0, !0, document.defaultView, e, e, "", "", !1, "")
@AliAlmasi
AliAlmasi / ferriswheel.html
Created July 2, 2023 22:44
"Ferris wheel" with HTML & CSS. From freeCodeCamp Responsive Web Design Certification curriculum.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ferris Wheel &mdash; Ali Almasi </title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<div class="wheel">
<span class="line"></span>
@AliAlmasi
AliAlmasi / tkCalc
Created August 22, 2022 21:23
Python tkinter Calculator
import tkinter as tk
def buttonpressed(i):
if i != '=':
entry.insert(tk.END, i)
else:
expression = entry.get()
try:
value = eval(expression)
new_string = f'{value: ,}'