Skip to content

Instantly share code, notes, and snippets.

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

Adriano Rosa adrianorsouza

🏠
Working from home
View GitHub Profile
@adrianorsouza
adrianorsouza / ico-gen.php
Created November 8, 2019 20:49
PHP Icon Favicon.ico Generator
<?php
/*
Copyright 2011-2013 Chris Jean & iThemes
Licensed under GPLv2 or above
Version 1.0.2
*/
class PHP_ICO {
/**
* Images in the BMP format.
*
<!-- https://www.w3.org/2005/10/howto-favicon -->
<!DOCTYPE html
PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en-US">
<head profile="http://www.w3.org/2005/10/profile">
<link rel="icon"
type="image/png"
href="http://example.com/myicon.png">
@adrianorsouza
adrianorsouza / webpack.config.js
Created August 28, 2019 05:20
Full Webpack configuration for Laravel, ReactJS and Bootstrap + LiveServer.
const fs = require('fs');
const os = require('os');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const postcssNormalize = require('postcss-normalize');
@adrianorsouza
adrianorsouza / connect.js
Created July 23, 2019 01:57 — forked from gaearon/connect.js
connect.js explained
// connect() is a function that injects Redux-related props into your component.
// You can inject data and callbacks that change that data by dispatching actions.
function connect(mapStateToProps, mapDispatchToProps) {
// It lets us inject component as the last step so people can use it as a decorator.
// Generally you don't need to worry about it.
return function (WrappedComponent) {
// It returns a component
return class extends React.Component {
render() {
return (
@adrianorsouza
adrianorsouza / nginx.conf
Created August 2, 2018 03:52 — forked from micho/nginx.conf
nginx config for http/https proxy to localhost:3000
First, install nginx for mac with "brew install nginx".
Then follow homebrew's instructions to know where the config file is.
1. To use https you will need a self-signed certificate: https://devcenter.heroku.com/articles/ssl-certificate-self
2. Copy it somewhere (use full path in the example below for server.* files)
3. sudo nginx -s reload
4. Access https://localhost/
Edit /usr/local/etc/nginx/nginx.conf:
@adrianorsouza
adrianorsouza / generate-icns.sh
Created March 4, 2017 02:42
Generate icns from iconset
mkdir icon.iconset
sips -z 16 16 icon1024.png --out icon.iconset/icon_16x16.png
sips -z 32 32 icon1024.png --out icon.iconset/icon_16x16@2x.png
sips -z 32 32 icon1024.png --out icon.iconset/icon_32x32.png
sips -z 64 64 icon1024.png --out icon.iconset/icon_32x32@2x.png
sips -z 128 128 icon1024.png --out icon.iconset/icon_128x128.png
sips -z 256 256 icon1024.png --out icon.iconset/icon_128x128@2x.png
sips -z 256 256 icon1024.png --out icon.iconset/icon_256x256.png
sips -z 512 512 icon1024.png --out icon.iconset/icon_256x256@2x.png
sips -z 512 512 icon1024.png --out icon.iconset/icon_512x512.png
@adrianorsouza
adrianorsouza / issue-csr.md
Last active June 8, 2022 23:29
Generate new CSR (Certificate Signed Request) to get a new certificate issued from a CA.

Issue CSR

$ openssl req -new -newkey rsa:2048 -nodes -keyout domain.key -out domain.csr

CHECK CERTIFICATE COMMAND

$ openssl x509 -noout -modulus -in domain.crt | openssl md5
$ openssl rsa -noout -modulus -in domain.key | openssl md5

$ openssl req -noout -modulus -in domain.csr | openssl md5

@adrianorsouza
adrianorsouza / createUUID.js
Last active May 6, 2019 17:49
Javascript to generate UUID
function createUUID() {
// http://www.ietf.org/rfc/rfc4122.txt
var s = [];
var hexDigits = "0123456789abcdef";
for (var i = 0; i < 36; i++) {
s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
}
s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
s[8] = s[13] = s[18] = s[23] = "-";
@adrianorsouza
adrianorsouza / NGINX-CORS+CSP.conf
Last active September 18, 2023 08:09
Nginx CORS and CSP configuration for wildcard origin domains
server {
...
add_header Content-Security-Policy "default-src 'none'";
add_header X-Content-Security-Policy "default-src 'none'";
add_header X-WebKit-CSP "default-src 'none'";
add_header "Access-Control-Allow-Headers" "X-Requested-With";
if ( $http_origin ~* (https?://(.+\.)?(domain1|domain2|domain3)\.(?:me|co|com)$) ) {
@adrianorsouza
adrianorsouza / bootstrapSwitch.js
Created December 2, 2015 19:18 — forked from bjcull/bootstrapSwitch.js
Angular directive for bootstrap-switch | http://www.bootstrap-switch.org/
.directive('bootstrapSwitch', [
function() {
return {
restrict: 'A',
require: '?ngModel',
link: function(scope, element, attrs, ngModel) {
element.bootstrapSwitch();
element.on('switchChange.bootstrapSwitch', function(event, state) {
if (ngModel) {