Skip to content

Instantly share code, notes, and snippets.

@amdrade
amdrade / getMimeTypefromString
Created October 30, 2020 13:52
Get mimeType from file extension as string
//Mime types. Some keys are duplicated.
array(
".3dm"=>"x-world/x-3dmf",
".3dmf"=>"x-world/x-3dmf",
".a"=>"application/octet-stream",
".aab"=>"application/x-authorware-bin",
".aam"=>"application/x-authorware-map",
".aas"=>"application/x-authorware-seg",
".abc"=>"text/vnd.abc",
@amdrade
amdrade / git-apply-patch.md
Created November 6, 2018 17:08 — forked from emmanueltissera/git-apply-patch.md
Generate a git patch for a specific commit

Creating the patch

git format-patch -1 <sha>
OR
git format-patch -1 HEAD

Applying the patch

git apply --stat file.patch # show stats.
git apply --check file.patch # check for error before applying

@amdrade
amdrade / fc-fixed-column.css
Created October 15, 2018 02:50
Full Canlendar com coluna de horários fixa para visão dia
.table-responsive .fixed-column {
position: absolute;
display: inline-block;
width: auto;
border-right: 1px solid #ddd;
opacity: 0;
top: 0;
z-index: 3;
background: #fff;
color: #2d2d2d;
@amdrade
amdrade / cURL_auth.php
Last active April 4, 2020 06:05
PHP: Exemplo cURL com autenticação HTTP básica
<?php
// index.php
<?php
$aDados = ['item1' => 'value1', 'item2' => 'value2', 'dados' => ['a','b','c']];
$username = 'user';
$password = 'pass';
$sUrl = 'http://localhost/projetos/estudos/php/curl/response.php/?item3=value3&item4=value4';
$sHttpBuildQuery = http_build_query($aDados);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $sUrl );
@amdrade
amdrade / fn.php
Created September 29, 2017 02:46
Funções PHP
function generateUrl() {
$protocol = $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http';
$uri = $_SERVER['REQUEST_URI'];
$Url = $protocol.'://'.str_replace('//', '/', $_SERVER['SERVER_NAME'].'/'.$uri);
return $Url;
}
@amdrade
amdrade / fn.js
Last active November 12, 2017 20:01
Funções JS
function generateUrl() {
var location = window.location,
url = window.location.href;
if (location.protocol == 'https:') {
url = 'https:' + location.href.substring(location.protocol.length);
}
return url;
}
function hasClass(el, className) {