Skip to content

Instantly share code, notes, and snippets.

@unicornist
unicornist / Coda Persian Fixes.user.js
Last active January 2, 2020 11:29
Collection of: UserScripts (GreeseMonkey / TamperMonkey)
// ==UserScript==
// @name Coda Persian Fixes
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://coda.io/*
// @grant GM_addStyle
// ==/UserScript==

Keybase proof

I hereby claim:

  • I am unicornist on github.
  • I am unicornist (https://keybase.io/unicornist) on keybase.
  • I have a public key whose fingerprint is 648B AD2D DBA9 5CCD DCC3 98D4 7A32 2E78 55D4 9CA4

To claim this, I am signing this object:

@unicornist
unicornist / index.jsx
Last active October 30, 2018 19:25 — forked from rhernandog/index.jsx
React & Recompose withProps - A simple example of using recompose's withProps
// styles for this are based on Bootstrap 3.3.7
import React, { Component } from "react";
import ReactDOM from "react-dom";
import { withProps } from "recompose";
const users = [
{ "name": "Homer Jay", "status": "pending" },
{ "name": "El Barto", "status": "active" },
{ "name": "SideshowBob", "status": "active" }
];
@unicornist
unicornist / Centos7.md
Last active September 3, 2024 09:38
CentOS 7 Server Setup including NginX, NodeJs, MongoDB, Redis, Docker, etc...

Note: For newer versions of NodeJS, Nginx and MongoDB, checkout their websites and update the related parts.

0.Pre-requisites

run all the commands in terminal as the root user (sudo su)

yum update
yum install -y epel-release
@unicornist
unicornist / BrowserSync Backend Proxy.md
Last active April 22, 2018 18:09
BrowserSync Proxy /api to backend to prevent CORS errors
npm i http-proxy-middleware --save

Then add this inside server prop of your BrowserSync config object:

middleware: [require('http-proxy-middleware')('/api', {target: 'http://localhost:8020/'})]

@unicornist
unicornist / log-es6.js
Last active November 29, 2019 07:58
TimeStamped console.log
const log = (...args) => console.log(`[${new Date().toLocaleString()}]`, ...args);
module.exports = log;
// log(1,2,3) --> [2018-3-10 01:42:21] 1 2 3
// log([1,2,3]) --> [2018-3-10 01:43:47] [ 1, 2, 3 ]
// log('this is:', this) --> [2018-3-10 01:43:01] this is: { console: [Getter],............}
@unicornist
unicornist / Native Date and Number Formatting.js
Last active June 30, 2024 10:22
Natively Format Javascript Dates & Numbers in different Locales (Including Persian Calendar)
(12345.6789).toLocaleString("fa-IR"); // ۱۲٬۳۴۵٫۶۷۹
var now = new Date();
now.toLocaleString(); // 1/27/2018, 12:07:03 AM
now.toLocaleDateString(); // 1/27/2018
now.toLocaleTimeString(); // 12:07:03 AM
now.toLocaleString("fa-IR") // ۱۳۹۶/۱۱/۷،‏ ۰:۰۷:۰۳
now.toLocaleDateString("fa-IR") // ۱۳۹۶/۱۱/۷
@unicornist
unicornist / MongoDB Win Service.bat
Last active January 26, 2018 20:35
Install MongoDB as a Windows Service
cd %programfiles%\MongoDB\Server\3.6\bin
mongod --dbpath="%programdata%\Mongo\Data" --logpath="%programdata%\Mongo\log.txt" --install && net start MongoDB

Windows

  • Rename All (e.g. *.jpg_*.jpg)
    for /f "delims=" %i in ('dir /b /a-d *.jpg') do ren "%~i" "_%~ni%~xi"
    • %~ni is for the name part (*)
    • ~xi is for the extension part (.jpg)

  • Replace All

Convert Video

Just Convert Format:
ffmpeg -i input.avi -c:v libx265 output.mp4
ffmpeg -i input.avi -c:v libx264 output.mp4
ffmpeg -i input.mp4 -c:v flv output.flv
Convert to H265 with smaller size and medium quality:
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -vf "scale=iw/2:ih/2" -c:a copy output.mp4
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -vf "scale=720:-1" -c:a copy output.mp4
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -vf "scale=720:trunc(ow/a/2)*2" -c:a copy output.mp4

ffmpeg -i input.mp4 -c:v libx265 -crf 28 -vf "scale=trunc(oh*a/2)*2:720" -c:a copy output.mp4