Skip to content

Instantly share code, notes, and snippets.

View Ambratolm's full-sized avatar
🌙

Ambratolm Ambratolm

🌙
View GitHub Profile
@Ambratolm
Ambratolm / open-with-sublime-text-3.bat
Last active February 23, 2022 19:06
Open folders and files with Sublime Text 3 from Windows explorer context menu.
Rem ============================================================================
Rem ■ Open with Sublime Text 3
Rem ----------------------------------------------------------------------------
Rem Open folders and files with Sublime Text 3
Rem from Windows explorer context menu.
Rem ============================================================================
Rem ----------------------------------------------------------------------------
Rem ● Settings
Rem ----------------------------------------------------------------------------
@Ambratolm
Ambratolm / update-git-credential.bat
Last active August 15, 2021 01:30
Replace Git credential (Username and Password) on Windows with the new one (Username and Personal Access Token).
REM Step 1: Remove old credential
REM Execute these commands:
git credential-manager reject https://github.com
git config --global credential.helper manager-core
REM Step 2: Enter new credential
REM 1- Choose any repository you have on your machine and try to push it.
REM 2- One or more prompt windows will popup asking for credential: Personal Access Token (PAT), Username, and Password.
REM 3- Enter: PAT, Username, and if asked for password always enter PAT instead.
REM 4- Done. Credential saved and the push should be successful.
@Ambratolm
Ambratolm / check-service.bat
Last active April 16, 2022 18:09
Check if a Windows service exists, Enable it, and Start it.
REM Check if service exists
sc query serviceName
REM Enable service to run automatically
sc config serviceName start= auto
REM Start service
net start serviceName
@Ambratolm
Ambratolm / money-raw-value.js
Last active February 23, 2022 19:09
Convert a formatted money string value (that may contain currencies, decimals, brackets ...etc) to a raw numeric value (to use it in calculations).
function moneyRawValue(value = 0, decimalSeparator = ",") {
if (typeof value === "number") return value;
const rawValue = parseFloat(
value
.replace(/\((?=\d+)(.*)\)/, "-$1")
.replace(new RegExp(`[^0-9-${decimalSeparator}]`, "g"), "")
.replace(decimalSeparator, ".")
);
return isNaN(rawValue) ? 0 : rawValue;
}
@Ambratolm
Ambratolm / omit.js
Last active August 14, 2021 16:14
Omits fields of an object in JavaScript.
// Function
function omit(obj = {}, fields = []) {
const rObj = { ...obj };
for (const prop in obj) {
if (fields.includes(prop)) {
delete rObj[prop];
}
}
return rObj;
}
@Ambratolm
Ambratolm / generate-pwa-assets.bat
Created March 16, 2020 19:51
Generate assets for PWA project from an image using PWA-Asset-Generator Node package
npm install --global pwa-asset-generator
cd [output-folder]
pwa-asset-generator [source-file] --manifest [manifest-file] --favicon
@Ambratolm
Ambratolm / package.json
Created March 14, 2020 02:37
Serve VueJS application in localhost with a custom name and port. The custom name should be added in system hosts file.
{
"name": "amb-app",
"version": "1.0.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open --host=app.ambratolm.com --port=2020",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint --fix"
},
"dependencies": {
@Ambratolm
Ambratolm / project-name.sublime-project
Last active March 17, 2022 00:57
Sublime Text project settings to hide some rarely used files and folders from the side bar (With snippet).
{
"folders":
[
{
"path": ".",
"folder_exclude_patterns": [
"node_modules"
],
"file_exclude_patterns": [
"*.sublime-*",
@Ambratolm
Ambratolm / Afficher du texte au chargement.cs
Created June 25, 2017 23:26
Créer une application qui permet d’afficher le texte « Ma première application évènementielle » au chargement du formulaire.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = "Ma première application évènementielle";
@Ambratolm
Ambratolm / Classes Client et Compte.cs
Created June 25, 2017 22:12
Définir une classe Client avec les attributs suivants : CIN, Nom, Prénom, Tél. et Créer Une classe Compte caractérisée par son solde et un code qui est incrémenté lors de sa création ainsi que son propriétaire qui représente un client ....
class Client
{
// Attributs
private string cin, nom, prénom;
private int téléphone;
// Accesseurs
public int Téléphone
{
get { return téléphone; }