Skip to content

Instantly share code, notes, and snippets.

View malkafly's full-sized avatar
🏠
Working from home

d. malk malkafly

🏠
Working from home
View GitHub Profile
@malkafly
malkafly / mascaras.js
Created October 11, 2016 22:49
Máscaras de Javascript para dados de veículos
CPF = "999.999.999-99",
CNPJ = "99.999.999/9999-99",
IE = "9?999999999999",
IM = "9?999999999999" /*Inscricao municipal*/,
RG = "99.99?9.99?9-*",
TIT = "999999999/99",
CEP = "99999-999",
DDD = "99",
Numero = "9?999999", /*Nota do leiloeiro*/
NFE = "999.999.999",
@malkafly
malkafly / get_youtube_channel_ID.php
Created September 7, 2016 17:13 — forked from webarthur/get_youtube_channel_ID.php
Get youtube Channel ID by channel url
<?php
function get_youtube_channel_ID($url){
$html = file_get_contents($url);
preg_match("'<meta itemprop=\"channelId\" content=\"(.*?)\"'si", $html, $match);
if($match && $match[1]);
return $match[1];
}
@malkafly
malkafly / geo.js
Created August 28, 2016 04:27 — forked from mkhatib/geo.js
A Javascript utility function to generate number of random Geolocations around a center location and in a defined radius.
/**
* Generates number of random geolocation points given a center and a radius.
* @param {Object} center A JS object with lat and lng attributes.
* @param {number} radius Radius in meters.
* @param {number} count Number of points to generate.
* @return {array} Array of Objects with lat and lng attributes.
*/
function generateRandomPoints(center, radius, count) {
var points = [];
for (var i=0; i<count; i++) {
@malkafly
malkafly / gist:578ec3accf6938780f91cf57350fc1f3
Last active September 6, 2018 20:00 — forked from stiucsib86/gist:ebff282a3989f9a24117
Backup MySQL dump to Azure Storage
#!/bin/sh
mkdir /home/bitnami/backups/
export BACKUP_FILE=/home/bitnami/backups/db-backup.sql.gz
export DATABASE_SCHEMA_NAME=--all-databases
export AZURE_CONTAINER=YOUR_VALUE_HERE
export AZURE_NAME=YOUR_VALUE_HERE
export AZURE_KEY=YOUR_VALUE_HERE
export AZURE_BLOB_NAME=db-production-$(date +%Y%m%d%H%M%S).sql.gz
@malkafly
malkafly / base64.js
Created February 24, 2016 03:13 — forked from whatnickcodes/base64.js
How to Encode and Decode Strings with Base64 in JavaScript
// Create Base64 Object
var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f<e.length){n=e.charCodeAt(f++);r=e.charCodeAt(f++);i=e.charCodeAt(f++);s=n>>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(f<e.length){s=this._keyStr.indexOf(e.charAt(f++));o=this._keyStr.indexOf(e.charAt(f++));u=this._keyStr.indexOf(e.charAt(f++));a=this._keyStr.indexOf(e.charAt(f++));n=s<<2|o>>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");var t="";for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r
@malkafly
malkafly / gist:c0ee8bbce7f247a157be
Last active August 29, 2015 14:25 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@malkafly
malkafly / demo.html
Last active August 29, 2015 14:21 — forked from DevinVinson/demo.html
<ol>
<li>
<div class="fade-in one">
<div class="box" style="background:#d10000;"></div>
</div>
</li>
<li>
<div class="fade-in two">
<div class="box" style="background:#ff6622;"></div>
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
// I blantantly stole, tweaked and happily used this code from:
// Lord of Ports http://www.experts-exchange.com/M_1736399.html
$ky = 'lkirwf897+22#bbtrm8814z5qq=498j5'; // 32 * 8 = 256 bit key
$iv = '741952hheeyy66#cs!9hjv887mxx7@8y'; // 32 * 8 = 256 bit iv
var cidades=[{"id":1,"nome":"Acrelandia","ide":1,"cap":0},{"id":2,"nome":"Assis Brasil","ide":1,"cap":0},{"id":3,"nome":"Brasileia","ide":1,"cap":0},{"id":4,"nome":"Bujari","ide":1,"cap":0},{"id":5,"nome":"Capixaba","ide":1,"cap":0},{"id":6,"nome":"Cruzeiro do Sul","ide":1,"cap":0},{"id":7,"nome":"Epitaciolandia","ide":1,"cap":0},{"id":8,"nome":"Feijo","ide":1,"cap":0},{"id":9,"nome":"Jordao","ide":1,"cap":0},{"id":10,"nome":"Mancio Lima","ide":1,"cap":0},{"id":11,"nome":"Manoel Urbano","ide":1,"cap":0},{"id":12,"nome":"Marechal Thaumaturgo","ide":1,"cap":0},{"id":13,"nome":"Placido de Castro","ide":1,"cap":0},{"id":14,"nome":"Porto Acre","ide":1,"cap":0},{"id":15,"nome":"Porto Walter","ide":1,"cap":0},{"id":16,"nome":"Rio Branco","ide":1,"cap":1},{"id":17,"nome":"Rodrigues Alves","ide":1,"cap":0},{"id":18,"nome":"Santa Rosa","ide":1,"cap":0},{"id":19,"nome":"Sena Madureira","ide":1,"cap":0},{"id":20,"nome":"Senador Guiomard","ide":1,"cap":0},{"id":21,"nome":"Tarauaca","ide":1,"cap":0},{"id":22,"nome":"Xapuri
@malkafly
malkafly / Program.cs
Created April 27, 2015 13:01
Comparar senhas do Identity
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{