Skip to content

Instantly share code, notes, and snippets.

View williampaulo's full-sized avatar

william paulo williampaulo

View GitHub Profile
@williampaulo
williampaulo / AESHelper.java
Created May 24, 2021 23:13 — forked from thackerronak/AESHelper.java
AES encryption/decryption in crypto-js way, use KDF for generating IV and Key, use CBC with PKCS7Padding for Cipher
import com.sun.jersey.core.util.Base64;
import java.io.UnsupportedEncodingException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
import javax.crypto.BadPaddingException;
@williampaulo
williampaulo / cloudSettings
Last active March 4, 2021 12:39
Synchronize settings, snippets, themes, icons, launch, keybindings, workspaces and extensions across machines using GitHub Gist.
{"lastUpload":"2021-03-04T12:39:12.100Z","extensionVersion":"v3.4.3"}
@williampaulo
williampaulo / json.php
Created March 6, 2018 03:49 — forked from itspriddle/json.php
Pure PHP json library
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
@williampaulo
williampaulo / cpf_cnpj_validator
Created February 23, 2018 13:12 — forked from igorcosta/cpf_cnpj_validator
Regex para validar CPF e CNPJ
Para CPF
/^\d{3}\.\d{3}\.\d{3}\-\d{2}$/
Para CNPJ
/^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/
Para ambos ao mesmo tempo
301 moved permanently (redirect):
<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com');
die();
?>
302 moved temporarily(redirect):
<?php
header('Location: http://www.example.com');
@williampaulo
williampaulo / app.js
Created March 15, 2017 18:55 — forked from VMBindraban/app.js
Resize/crop/center in javascript through canvas to base64
var $uplImageBtn = $('.pui--ev-upload'),
$uplContainer = $('#uplProfileImg'),
$previewImg = $('.macc--s-pimg img');
$uplImageBtn.click(function() {
$uplContainer.trigger('click');
});
$uplContainer.on('change', function() {
if (!this.files && !this.files[0]) {
server {
listen 80;
server_name CHANGEME.app;
root /var/www/vhosts/CHANGEME.app/public;
index index.html index.htm index.php;
charset utf-8;
location / {