Skip to content

Instantly share code, notes, and snippets.

@babakhani
babakhani / eepromr_test.ino
Created April 10, 2020 17:50 — forked from xxlukas42/eepromr_test.ino
ESP8266 and ESP32 flash memory
#include <EEPROM_Rotate.h>
EEPROM_Rotate EEPROMr;
#define DATA_OFFSET 10
void setup() {
Serial.begin(115200);
delay(2000);
EEPROMr.size(4);
EEPROMr.begin(4096);
@babakhani
babakhani / commands.txt
Last active March 10, 2021 21:08
Useful terminal command for speed up development in terminal
# Quickly Find and Replace Text Across Multiple Files with One Command
perl -pi -w -e 's/SEARCH_FOR/REPLACE_WITH/g;' *.txt
# Find
find ~ -iname "screen*"
find ~ -iname "screen*" | more
# Useful Git Commands
## oficial git cheet-sheat
https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf
https://github.com/git-tips/tips#everyday-git-in-twenty-commands-or-so
https://github.com/dictcp/awesome-git
#### Pretty Log
`git log --all --graph --pretty=format:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative`
@babakhani
babakhani / smartInputDirection
Last active February 6, 2020 12:20
Check first char of input, if first char was persian char then set direction rtl to input.
app.directive('smartInputDirection', function () {
return {
restrict: "EA",
link: function ($scope, element, attrs) {
element.keyup(function () {
var thiVal = $(this).val().charAt(0)
, p = /^[\u0600-\u06FF\s]+$/;
if (p.test(thiVal)) {
element.css({
@babakhani
babakhani / jsgradient
Last active February 6, 2020 12:18
get array of color between two colors
//https://dl.dropboxusercontent.com/u/17365636/web/jsGradient.js
jsgradient = {
inputA : '',
inputB : '',
inputC : '',
gradientElement : '',
// Convert a hex color to an RGB array e.g. [r,g,b]
// Accepts the following formats: FFF, FFFFFF, #FFF, #FFFFFF
hexToRgb : function(hex){
@babakhani
babakhani / gist:9307097
Created March 2, 2014 14:13
Convert English digit to Persian digit
/*
Convert English Numbers to Persian in a web page
Behnam Emamian(www.BehnamEmamian.com)
*/
String.prototype.toPersianDigit = function (a) {
return this.replace(/\d+/g, function (digit) {
var enDigitArr = [], peDigitArr = [];
for (var i = 0; i < digit.length; i++) {
enDigitArr.push(digit.charCodeAt(i));
@babakhani
babakhani / jquery.tmpl
Created May 21, 2013 14:07
Micro mustache plugin
$.tmpl = function(input,dict) {
// Micro Mustache Template engine
String.prototype.format = function string_format(arrayInput) {
function replacer(key){
var keyArr =key.slice(2,-2).split("."),firstKey = keyArr[0], SecondKey = keyArr[1];
if (arrayInput[firstKey] instanceof Object){
return arrayInput[firstKey][SecondKey];
}
else{
return arrayInput[firstKey];
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {