Skip to content

Instantly share code, notes, and snippets.

View mhsattarian's full-sized avatar
🎯
Focusing

Mohammad H. Sattarian mhsattarian

🎯
Focusing
View GitHub Profile
@onildoaguiar
onildoaguiar / sorting-an-array-by-date-with-moment-js.md
Last active July 21, 2023 04:28
Sorting an array by date with Moment.js
const Moment = require('moment')
const array = [{date:"2018-05-11"},{date:"2018-05-12"},{date:"2018-05-10"}]
const sortedArray  = array.sort((a,b) => new Moment(a.date).format('YYYYMMDD') - new Moment(b.date).format('YYYYMMDD'))
console.log(sortedArray)
@MeTe-30
MeTe-30 / Convert Persian & English digits together
Created December 6, 2016 07:53
Convert Persian & English digits together | Javascript
String.prototype.toPersianDigits = function () {
var id = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
return this.replace(/[0-9]/g, function (w) {
return id[+w];
});
};
String.prototype.toEnglishDigits = function () {
var id = { '۰': '0', '۱': '1', '۲': '2', '۳': '3', '۴': '4', '۵': '5', '۶': '6', '۷': '7', '۸': '8', '۹': '9' };
@also
also / wave.js
Created April 2, 2011 23:50
Generate WAVE file headers in JavaScript
// https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
function buildWaveHeader(opts) {
var numFrames = opts.numFrames;
var numChannels = opts.numChannels || 2;
var sampleRate = opts.sampleRate || 44100;
var bytesPerSample = opts.bytesPerSample || 2;
var blockAlign = numChannels * bytesPerSample;
var byteRate = sampleRate * blockAlign;
var dataSize = numFrames * blockAlign;
@pfig
pfig / mkfavicon.sh
Created February 12, 2012 12:01
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png
@mort3za
mort3za / install-php5.6-ubuntu.sh
Last active February 15, 2024 14:16
Install php 5.6 and composer in ubuntu 18.04
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6
php --version
sudo apt-get install php5.6-curl php5.6-xml
sudo apt-get install composer
@mahmoud-eskandari
mahmoud-eskandari / README.md
Last active February 28, 2024 00:27
Install v2ray on Bridge:(Ubuntu +18 via systemd) - Upstream (Ubuntu +18/CentOS +7 via docker)

پنل x-ui

پنل تحت وب مدیریت V2ray و ساخت کاربر و مدیریت سرور

mkdir x-ui && cd x-ui
docker run -itd --network=host \
    -v $PWD/db/:/etc/x-ui/ \
 -v $PWD/cert/:/root/cert/ \
@Jack-Works
Jack-Works / 2018.js
Last active March 1, 2024 02:23
cRAzY eSnEXt (*all* proposals mixed in)
#! Aaaaaaaaaaa this is JS!!!
// https://github.com/tc39/proposal-hashbang
// This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics
// Enjoy!!!
// Created at Nov 23, 2018
for await(const x of (new A // https://github.com/tc39/proposal-pipeline-operator
|> do { // https://github.com/tc39/proposal-do-expressions
case(?) { // https://github.com/tc39/proposal-pattern-matching
when {val}: class {
@chriswhong
chriswhong / RadiusMode.js
Created March 1, 2018 12:04
RadiusMode, a custom mode for mapbox-gl-draw for drawing a radius
// custom mapbopx-gl-draw mode that modifies draw_line_string
// shows a center point, radius line, and circle polygon while drawing
// forces draw.create on creation of second vertex
import MapboxDraw from 'mapbox-gl-draw';
import numeral from 'numeral';
import lineDistance from 'npm:@turf/line-distance';
const RadiusMode = MapboxDraw.modes.draw_line_string;
@vladikoff
vladikoff / doskey.md
Last active March 11, 2024 17:27
Setup Persistent Aliases & Macros in Windows Command Prompt (cmd.exe) using DOSKey

Setup Persistent Aliases & Macros in Windows Command Prompt (cmd.exe) using DOSKey

Saved from Archive.org, Date: May 14, 2010 Author: Jesse Webb

http://web.archive.org/web/20140330024520/http://devblog.point2.com/2010/05/14/setup-persistent-aliases-macros-in-windows-command-prompt-cmd-exe-using-doskey/

Our development machines here at Point2 are not standardized; we have a mixture of Windows XP, 7, and Mac OSX/Unix computers. I find myself constantly switching back and forth between command prompt interfaces when pair programming. As a result, I catch myself using “ls” to list a directories contents regardless of what system I am on. I am currently using a Windows XP machine for my developer box and I wanted to setup an alias to the “ls” command to actually perform a “dir”. Here is how I accomplished it…

There is a command available in a Window’s shell that let’s you “alias” command to whatever you please: DOSKey. It allows you to create “macros” to execute one or more other commands with a custom nam

@inorganik
inorganik / app.js
Last active March 31, 2024 21:13
Using CountUp.js in React
import { useEffect, useRef } from 'react'
// playground: https://stackblitz.com/edit/react-ts-nv5fxe?file=App.tsx
export default function App() {
// create a ref and declare an instance for each countUp animation
const countupRef = useRef(null);
let countUpAnim;