Skip to content

Instantly share code, notes, and snippets.

View pydawan's full-sized avatar

Thiago Monteiro pydawan

View GitHub Profile
@pydawan
pydawan / composer-install.sh
Created January 27, 2020 12:24 — forked from vinaydotblog/composer-install.sh
Installing composer using curl
# Goto a directory you can write to:
cd ~
#get composer:
curl -s https://getcomposer.org/installer | php
# move composer into a bin directory you control:
sudo mv composer.phar /usr/local/bin/composer
# double check composer works
composer about
@pydawan
pydawan / security-http-headers.md
Created December 12, 2019 12:33 — forked from paulofreitas/security-http-headers.md
Cabeçalhos de resposta HTTP relacionados a segurança

Content-Security-Policy, X-Content-Security-Policy, X-WebKit-CSP

O cabeçalho de resposta HTTP Content-Security-Policy permite aos administradores de sites controlar os recursos que o navegador ou agente de usurio (user agent) pode carregar em uma determinada página. Com algumas exceções, as políticas envolvem principalmente especificar as origens do servidor e os endpoints de script. Isso ajuda a proteger contra ataques de XSS.

O cabeçalho de respsota HTTP X-Content-Security-Policy é requerido para implementar o CSP no Internet Explorer 10 e 11.

O cabealho de resposta HTTTP X-Webkit-CSP é requerido para implementar o CSP em versões mais antigas do Google Chrome, Safari e outros navegadores baseados na engine WebKit.

Para navegadores modernos, o cabeçalho Content-Security-Policy deve ser usado.

@pydawan
pydawan / embeddedH2.groovy
Created December 9, 2019 15:20 — forked from bradkarels/embeddedH2.groovy
Simple example: Embed H2 database within a groovy script (file based persistence)
@GrabConfig(systemClassLoader=true)
@Grab(group='com.h2database', module='h2', version='1.3.176')
import java.sql.*
import groovy.sql.Sql
import org.h2.jdbcx.JdbcConnectionPool
println("More groovy...")
def sql = Sql.newInstance("jdbc:h2:things", "sa", "sa", "org.h2.Driver") // DB files for 'things' in current directory (./hello.h2.db)
@pydawan
pydawan / create_migration.sh
Created December 7, 2019 15:18 — forked from MarkyMarkMcDonald/create_migration.sh
Create Flyway migration versioned by timestamp: ./bin/create_migration.sh "Add_Unique_Constraint_To_User_Email"
#!/bin/bash
echo "-- New Migration" > "`dirname $0`/../src/main/resources/db/migrations/V`date +%s`__$1.sql"
@pydawan
pydawan / jsoup_examples.java
Created November 27, 2019 09:10 — forked from chrisvoo/jsoup_examples.java
GET/POST HTTP request and HTML parsing with Jsoup library
import java.io.IOException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@pydawan
pydawan / LICENSE
Created November 6, 2019 18:08 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
@pydawan
pydawan / SmallNettyServer.groovy
Created October 17, 2019 05:40 — forked from itzg/SmallNettyServer.groovy
Just enough Groovy code to implement a GET'able HTTP server with regex based path routing.
import org.jboss.netty.bootstrap.ServerBootstrap
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.channel.ChannelHandlerContext
import org.jboss.netty.channel.ChannelPipeline
import org.jboss.netty.channel.ChannelPipelineFactory
import org.jboss.netty.channel.Channels
import org.jboss.netty.channel.MessageEvent
import org.jboss.netty.channel.SimpleChannelUpstreamHandler
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory
import org.jboss.netty.handler.codec.http.DefaultHttpResponse
@pydawan
pydawan / jpa-cheatsheet.java
Created October 16, 2019 21:18 — forked from jahe/jpa-cheatsheet.java
JPA Cheatsheet
/*
JPA (Java Persistence API)
Transaction Management with an Entity-Mananger:
---
entityManager.getTransaction().begin();
entityManager.persist(<some-entity>);
entityManager.getTransaction().commit();
entityManager.clear();
@pydawan
pydawan / jsp.md
Created October 15, 2019 00:26 — forked from splacentino/jsp.md
A JSP cheat sheet

Java expression evaluated at run time.

Prototype

<%=     %>

Example

@pydawan
pydawan / jsp.md
Created October 15, 2019 00:26 — forked from splacentino/jsp.md
A JSP cheat sheet

Java expression evaluated at run time.

Prototype

<%=     %>

Example