Skip to content

Instantly share code, notes, and snippets.

View behrad's full-sized avatar
🤠
Doing Well

Behrad Zari behrad

🤠
Doing Well
View GitHub Profile
@behrad
behrad / gist:5744174
Created June 9, 2013 16:33
rtl select2 multivalue search box resizing
var containerLeft = ($(window).width() - (this.selection.offset().left + this.selection.outerWidth()) );
var left = ($(window).width() - (this.search.offset().left + this.search.outerWidth()));
@behrad
behrad / linux-admin
Last active March 1, 2020 10:02
Linux Commands
# File Management
#==================
tail -n +$X /path/to/file | head -n $((Y-X+1))
grep -ir -n "ramesh" *
find / -iname passwd
# Process management
#===================
lsof -p PID
@behrad
behrad / jalali.erl
Last active December 18, 2015 14:49
Jalali Calendar Implementation
%% Copyright
-module(jalali).
-author("jrad <behradz@gmail.com>").
-define( G_DAYS_IN_MONTH, [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] ).
-define( J_DAYS_IN_MONTH, [ 31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29 ] ).
%% API
-export([
gregorian_to_jalali/1,
@behrad
behrad / flipcss.php
Created June 17, 2013 20:17
Flip CSS to RTL version
<?php
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* flipcss.php 0.4
* by daif alotaibi (http://daif.net)
* daif@daif.net
@behrad
behrad / FarsiType
Created July 2, 2013 15:48
FarsiType Javascript Plugin
/*
FarsiType
Version: 1.3.6
http://www.farsitype.ir
This script developed to ease typing Farsi (Persian) in web forms where there is no Farsi Keyboard installed on a PC.
Works with Internet Explorer, FireFox, Opera and Chrome.
For more information and getting the using manual please visit the script website (http://www.farsitype.ir).
Copyright 2002-2011 Kaveh Ahmadi (http://www.kavehahmadi.com, email: me@kavehahmadi.com).
@behrad
behrad / install_redis_node_cent
Created August 4, 2013 08:13
Install latest Redis & Node in Centos 6
yum update
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
# to --enablerepo=remi
nano /etc/yum.repos.d/remi.repo
yum install redis -y
chkconfig redis on
# From EPEL
yum install npm
@behrad
behrad / install_zotonic_centos
Created August 4, 2013 08:20
Zotonic Installation in Centos 6
# firs make sure EPEL & REMI repos are enabled!
yum -y install erlang mercurial gcc gcc-c++ make librsvg2-devel lcms-devel libjpeg-devel libpng-devel jasper-devel fontconfig-devel freetype-devel libxml2-devel libtiff-devel bzip2-devel ncurses-devel openssl-devel
yum install ImageMagick
rpm -Uvh http://yum.postgresql.org/9.2/redhat/rhel-6-x86_64/pgdg-centos92-9.2-6.noarch.rpm
su - postgres -c /usr/pgsql-9.2/bin/initdb
chkconfig --levels 235 postgresql-9.2 on
vim /etc/postgresql/<pg version>/main/pg_hba.conf
/*
This is an experimental HashMap implementation with some features I needed and didn't found in JS default Arrays and Objects
Features :
* Direct acces too elements throught .get(key)
* fast keys or values iteration using for (;;) instead of for in syntax (http://jsperf.com/array-keys-vs-object-keys-iteration/3 )
*/
class HashMap {
public length: number = 0;
@behrad
behrad / node_daemon_cent
Last active December 25, 2015 10:09
Node.js Apps as Service in Linux
#!/bin/bash
#
# Service script for a Node.js application running under Forever.
#
# This is suitable for Fedora, Red Hat, CentOS and similar distributions.
# It will not work on Ubuntu or other Debian-style distributions!
#
# There is some perhaps unnecessary complexity going on in the relationship between
# Forever and the server process. See: https://github.com/indexzero/forever
#
upstream myapp_upstream {
server 127.0.0.1:3000;
keepalive 64;
}
server {
listen 8080;
server_name myapp.com;