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
<client>
<firstname>Aly</firstname>
<lastname>Saleem</lastname>
<occupation permenant="true">Dentist</occupation>
</client>
<client>
<firstname>Mohammed</firstname>
<lastname>Ali</lastname>
<occupation permenant="false">Salesman</occupation>
</client>
/* paste this at the top: */
@import url('https://fonts.googleapis.com/css?family=Open+Sans');
/* paste this at the bottom: */
.highlight {
background: #fff;
}
.highlighter-rouge .highlight {
@alexcorvi
alexcorvi / get-pi-using-gcd.js
Last active March 14, 2017 02:45
Calculate Pi Value from random numbers
function getPi(){
function getRand(maxRand){
return Math.floor(Math.random()*maxRand);
}
function gcd(a,b) {
if (!b) return a;
else return gcd(b,a%b);
};
let coPrimes = 0;
const iterations = 10000000;
/// <reference path="../node_modules/@types/node/index.d.ts"/>
import * as fs from "fs";
import {join,resolve} from "path";
import marked = require("marked");
import handlebars = require("handlebars");
import mkdirp = require("mkdirp");
// retrieve a list of all the files in a given directory
function walkSync (dir:string, fileList?:string[]) {
const files = fs.readdirSync(dir).map((x)=>join(resolve(dir),x));
@alexcorvi
alexcorvi / style.css
Created February 28, 2017 11:19
vscode custom css
.vs-dark .monaco-workbench {
--input-bgcolor: #3c3c3c;
background-color: red;
color: #e7e7e7;
}
@alexcorvi
alexcorvi / file.js
Created February 16, 2017 00:41
JSX without react
var React = {
createElement: function (tag, attrs, children) {
var e = document.createElement(tag);
// Add attributes
for (var name in attrs) {
if (name && attrs.hasOwnProperty(name)) {
var v = attrs[name];
if (v === true) {
e.setAttribute(name, name);
@alexcorvi
alexcorvi / decode_if_b64.php
Last active June 29, 2016 12:23
will only decode the data if it's base64 (or a base64 data URI), if it's not will return the same data, also used to check if it's base64 or a data URI.
function decode_if_b64($file_content="",$return_boolean=false) {
/**
*
* Base64 files handling
* 1. first we'll check if it's a base64 data URI
* and we'll strip the data uri initials
*
* 2. Confirm it using regular expression
@alexcorvi
alexcorvi / mime2ext.php
Created June 29, 2016 10:04
converting mime types to extension in php
function mime2ext($mime){
$all_mimes = '{"png":["image\/png","image\/x-png"],"bmp":["image\/bmp","image\/x-bmp","image\/x-bitmap","image\/x-xbitmap","image\/x-win-bitmap","image\/x-windows-bmp","image\/ms-bmp","image\/x-ms-bmp","application\/bmp","application\/x-bmp","application\/x-win-bitmap"],"gif":["image\/gif"],"jpeg":["image\/jpeg","image\/pjpeg"],"xspf":["application\/xspf+xml"],"vlc":["application\/videolan"],"wmv":["video\/x-ms-wmv","video\/x-ms-asf"],"au":["audio\/x-au"],"ac3":["audio\/ac3"],"flac":["audio\/x-flac"],"ogg":["audio\/ogg","video\/ogg","application\/ogg"],"kmz":["application\/vnd.google-earth.kmz"],"kml":["application\/vnd.google-earth.kml+xml"],"rtx":["text\/richtext"],"rtf":["text\/rtf"],"jar":["application\/java-archive","application\/x-java-application","application\/x-jar"],"zip":["application\/x-zip","application\/zip","application\/x-zip-compressed","application\/s-compressed","multipart\/x-zip"],"7zip":["application\/x-compressed"],"xml":["application\/xml","text\/xml"],"svg":
/**
*
* input file => data URI
* image => cropped image
*
**/
(function($) {
/**
$.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();