Skip to content

Instantly share code, notes, and snippets.

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

Mauricio Cunha mcunha98

🏠
Working from home
View GitHub Profile
function syncCKEditor(value)
{
CKEDITOR.instances[value].setData(document.getElementById(value).value);
}
//carrega a response para um textarea hidden
$('#resumo').val(response.data.resumo);
//reconecta o ckeditor com o valor atualizado
syncCKEditor('resumo');
function forceDownload(href) {
var li = Math.max(str.lastIndexOf('/'), str.lastIndexOf('\\'));
var bn = new String(str).substring(li + 1);
var anchor = document.createElement('a');
anchor.href = href;
anchor.download = bn;
document.body.appendChild(anchor);
anchor.click();
}
@mcunha98
mcunha98 / README.md
Created October 25, 2020 13:34 — forked from nichtich/README.md
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)
@mcunha98
mcunha98 / git-deployment.md
Created October 25, 2020 13:34 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.

Using Git to Manage a Live Web Site

Overview

As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.

Contents

//Append a custom dropdown for summernote
$(document).ready(function() {
$('.summernote').summernote({
lang: 'pt-BR',
height: 200,
dialogsInBody: true,
toolbar: [
['font', ['bold', 'italic' , 'underline', 'strikethrough', 'clear']],
['color', ['color']],
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>CSS Message Box Styles</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style type="text/css">
body
{
margin: 0;
@mcunha98
mcunha98 / php auto check enumerations
Created December 30, 2020 12:52
Check if current class has constant/enumeration based on value
class Assets
{
const ASSETS_BANNER = 'banner';
const ASSETS_BLOG = 'blog';
const ASSETS_TEMPLATE = 'template';
private static $constants;
public static function isConstant($value)
{
//Examples :
placeholder.php?size=200x100&bg=eee&fg=000&text=Hello
placeholder.php?size=200x100&bg=eee&fg=000
placeholder.php?size=200x100
<?php
$getsize = isset($_GET['size']) ? $_GET['size'] : '100x100';
$dimensions = explode('x', $getsize);
$image = imagecreate($dimensions[0], $dimensions[1]);
[abc] A single character: a, b or c
[^abc] Any single character but a, b, or c
[a-z] Any single character in the range a-z
[a-zA-Z] Any single character in the range a-z or A-Z
^ Start of line
$ End of line
\A Start of string
\z End of string
. Any single character
\s Any whitespace character