Skip to content

Instantly share code, notes, and snippets.

View alexcorvi's full-sized avatar
🏗️
Building something new

Ali A. Saleem alexcorvi

🏗️
Building something new
  • Mosul
View GitHub Profile
@alexcorvi
alexcorvi / randomstring.js
Created April 25, 2015 12:05
Javascript: Function to create random string
var getChars = function (size) {
var str = '',
i = 0,
chars = '0123456789abcdefghijklmnopqurstuvwxyzABCDEFGHIJKLMNOPQURSTUVWXYZ';
while (i < size) {
str += chars.substr(Math.floor(Math.random() * 62), 1);
i++;
}
return str;
}
@alexcorvi
alexcorvi / encrypt-decrypt.php
Created April 30, 2015 14:16
PHP Encrypt/Decrypt Function
function encrypt($mprhase) {
$MASTERKEY = "some key here";
$td = mcrypt_module_open('tripledes', '', 'ecb', '');
$iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);
mcrypt_generic_init($td, $MASTERKEY, $iv);
$crypted_value = mcrypt_generic($td, $mprhase);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return base64_encode($crypted_value);
}
@alexcorvi
alexcorvi / html.html
Last active August 29, 2015 14:20
HTML5 Start-up Template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>TITLE</title>
<!-- [if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![end if]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
@alexcorvi
alexcorvi / reverseArray.js
Created May 9, 2015 20:23
reversing array elements
// in a new array
var reverseArray = function (old_array) {
var new_array = [];
for (i=0; i<=old_array.length-1; i++) {
new_array[old_array.length-1 - i] = old_array[i];
}
return new_array;
}
// in the same array
@alexcorvi
alexcorvi / multilevel-js-loop.js
Last active August 29, 2015 14:20
multilevel loop through Javascript Object
function traverse(obj) {
for (var prop in obj) {
// do something with obj[prop]
if (obj[prop] !== null && typeof(obj[prop])=="object") {
//going on step down in the object tree!!
traverse(obj[prop]);
}
}
}
@alexcorvi
alexcorvi / main.html
Last active August 29, 2015 14:25
Srood VCM
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700" type="text/css" />
<style type="text/css">
.srood_container {
font-family:'Lato';
max-width:960px;
margin:0 auto;
padding:2em 0 2em 0;
}
.srood_container .heading-primary {
font-size:1.9em;
{
"cat0":[
{
"id":3291,
"title":"شاورمة دجاج بالجبن",
"parentRstrnt":"مطعم سكوزي",
"img":"http://images.grabhouse.com/urbancocktail/wp-content/uploads/2015/05/1-Source-oaza.eb2a.me_.jpg",
"price":"3500"
},
{
@alexcorvi
alexcorvi / detect.js
Created March 1, 2016 16:03
detect if the browser is google chrome or not via JavaScript
var is_chrome = ((navigator.userAgent.toLowerCase().indexOf('chrome') > -1) &&(navigator.vendor.toLowerCase().indexOf("google") > -1));
$.file2URI = function (obj) {
if (obj.el.files && obj.el.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
obj.success(e.target.result);
}
reader.readAsDataURL(obj.el.files[0]);
}
else {
obj.error();
/**
*
* input file => data URI
* image => cropped image
*
**/
(function($) {
/**