Skip to content

Instantly share code, notes, and snippets.

Ali Farhadi farhadi

Block or report user

Report or block farhadi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@farhadi
farhadi / rc4.js
Created Mar 24, 2012
RC4 encryption in javascript and php
View rc4.js
/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str) {
var s = [], j = 0, x, res = '';
@farhadi
farhadi / autodir.js
Created Jan 25, 2012
jQuery plugin to automatically set direction on input/textarea fields.
View autodir.js
(function($) {
$.fn.autodir = function() {
return this.each(function() {
$(this).on('keypress keyup change', function() {
$(this).css('direction', $(this).val().match(/^[^a-z]*[^\x00-\x7E]/ig) ? 'rtl' : 'ltr');
}).keyup();
});
};
})(jQuery);
View http-agent-bug.js
var http = require('http');
for (var i = 0; i < 10; i++) {
http.get({
host: 'localhost',
port: 80,
path: '/',
}, function(res) {
console.log(res.statusCode);
}).on('error', function(e) {
You can’t perform that action at this time.