Skip to content

Instantly share code, notes, and snippets.

View alireza-ahmadi's full-sized avatar

Alireza Ahmadi alireza-ahmadi

View GitHub Profile
@alireza-ahmadi
alireza-ahmadi / mbr.bat
Created September 2, 2012 18:24
Mbrfix Command
C:\> MbrFix /drive 0 fixmbr /yes
@alireza-ahmadi
alireza-ahmadi / style.css
Last active December 12, 2015 09:18
Follow #تمپلیت_ایمیل at Twitter
/* Normal Style */
#elementName{
background:#FFFFFF url(img/foobar.png) no-repeat center top;
}
/* Email Template Style */
#elementName{
background-color:#FFFFFF;
background-image:url(img/foobar.png);
/**
* Useful function for Melli code validation
* @author Alireza Ahmadi info@alireza.es
* @param code {String} Melli code
* @return {Boolean} Melli code credential
*/
var MelliCode = function(code){
if(code.length != 10) {
return false;
}
@alireza-ahmadi
alireza-ahmadi / redirect.js
Created January 10, 2014 20:24
A simple Node.js solution for 301 redirect
var http = require('http');
var server = http.createServer(function(req, res){
res.writeHead(301, {'Location' : 'http://www.example.com'});
res.end();
});
server.listen(process.env.PORT || 3000);
@alireza-ahmadi
alireza-ahmadi / dropzone.coffee
Created May 12, 2014 21:45
Simple AngularJS directive for drag and drop file upload in coffeescript
angular
.module 'DropzoneDirective', []
.directive 'dropzone', ->
restrict: 'A'
scope :
onComplete : '&'
link: (scope, element, attrs) ->
element.bind 'dragover', (event) ->
event.stopPropagation()
event.preventDefault()
angular.module('foobar', [])
.directive('timeMask', function(){
function format(input){
var time;
time = input.split(':');
if(time.length){
if(time[0] == ''){
time[0] = '00';
time[1] = '00';
}
@alireza-ahmadi
alireza-ahmadi / sort.js
Created September 22, 2014 14:42
Sort array by specific key
function sortByKey(arr, key) {
function compare(n, m){
return (m.localeCompare(n, 'fa') >= 0)
}
return arr.sort(function(a, b) {
var x,
y;
x = a[key];
y = b[key];
return ((check(x, y)) ? -1 : ((check(y, x)) ? 1 : 0));
@alireza-ahmadi
alireza-ahmadi / Gruntfile.js
Created September 25, 2014 12:04
Batch compression of PNG files
var APIKEY = "OOOOOOOOOOOOOOOOOOOOOOOOOO";
module.exports = function(grunt){
grunt.loadNpmTasks('grunt-tinypng');
grunt.initConfig({
tinypng: {
options: {
apiKey: APIKEY,
showProgress: true,
stopOnImageError: false
},
gulp = require 'gulp'
sourcestream = require 'vinyl-source-stream'
buffer = require 'vinyl-buffer'
util = require 'gulp-util'
sourcemaps = require 'gulp-sourcemaps'
uglify = require 'gulp-uglify'
browserify = require 'browserify'
livereload = require 'gulp-livereload'
minify = require 'gulp-minify-css'
express = require 'express'
public class Loop {
public static void main(String[] args)
{
Integer total = 500000000;
Integer chunk = 50000000;
Integer i = 0;