Skip to content

Instantly share code, notes, and snippets.

View giovannicandido's full-sized avatar

Giovanni Silva giovannicandido

View GitHub Profile
@giovannicandido
giovannicandido / BuscaRecusiva.scala
Created February 25, 2015 17:10
Busca recusiva em grafo binario
object Main extends App {
case class Vertice(valor: Int, esquerda: Option[Vertice], direita: Option[Vertice]) {
override def toString = valor.toString
}
val v1 = Vertice(10,None,None)
val v3 = Vertice(30,None,None)
val v2 = Vertice(5,Some(v3),None)
val root = Vertice(3,Some(v1), Some(v2))
def imprimeGrafo(vertice: Vertice): Unit = {
object Main extends App {
val nomes = Seq("Twing","Twing","Twofi")
def imprimirSeq(seq: Seq[String], filtro: Filtro){
val filtrados = filtro.filtrar(seq)
filtrados.foreach(println)
}
imprimirSeq(nomes, new FiltrarPorNome("Twing"))
imprimirSeq(nomes, new FiltrarPorComecarCom("Tw"))
imprimirSeq(nomes, new Filtro {
override def filtrar(valores: Seq[String]) = {
package framework;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;
import org.springframework.util.Assert;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
@giovannicandido
giovannicandido / HomeController.cs
Created April 21, 2016 02:09
WebMVC 6 Hello World
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNet.Mvc;
namespace WebApplication1.Controllers
{
public class HomeController : Controller
{
@giovannicandido
giovannicandido / rename_pascal_tablenames.sql
Last active June 7, 2017 09:07
Rename pascal case tables to snake case in postgresql
SELECT ddlsql || regexp_replace(name, E'^_',E'','g') As ddlsql FROM (SELECT 'ALTER TABLE ' || quote_ident(t.table_schema) || '.'
|| quote_ident(t.table_name) || ' RENAME TO ' As ddlsql, quote_ident(lower(regexp_replace(t.table_name, E'([A-Z])', E'\_\\1','g'))) || ';' as name
FROM information_schema.tables As t
WHERE t.table_schema NOT IN('information_schema', 'pg_catalog')
AND t.table_name <> lower(t.table_name)
ORDER BY t.table_schema, t.table_name) x;
@giovannicandido
giovannicandido / rename_pascal_columns.sql
Created June 12, 2016 02:28
Rename pascal column names to snake case columns names in postgresql
SELECT ddlsql || regexp_replace(name, E'^_',E'','g') || ';' as ddlsql FROM
(
SELECT 'ALTER TABLE ' || quote_ident(c.table_schema) || '.'
|| quote_ident(c.table_name) || ' RENAME "' || c.column_name || '" TO ' As ddlsql, quote_ident(lower(regexp_replace(column_name, E'([A-Z])', E'\_\\1','g'))) as name
FROM information_schema.columns As c
WHERE c.table_schema NOT IN('information_schema', 'pg_catalog')
AND c.column_name <> lower(c.column_name)
ORDER BY c.table_schema, c.table_name, c.column_name
) x;
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql">
<resources>
<resource-root path="postgresql-42.1.4.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
#!/bin/sh
# Determine the version of RHEL
COND=`grep -i Taroon /etc/redhat-release`
if [ "$COND" = "" ]; then
export PREFIX="/usr/sbin"
else
export PREFIX="/sbin"
fi
#!/bin/bash
#stop logging services
/sbin/service rsyslog stop
/sbin/service auditd stop
#remove old kernels
/bin/package-cleanup --oldkernels --count=1
#clean yum cache
/usr/bin/yum clean all
#force logrotate to shrink logspace and remove old logs as well as truncate logs
/usr/sbin/logrotate -f /etc/logrotate.conf
#function New-LinuxVM {
#requires -Modules Hyper-V
[CmdletBinding(SupportsShouldProcess=$true)]
param
(
[Parameter(Mandatory=$true, Position=1)][String]$VMName,
[Parameter()][String]$VHDXName = '',
[Parameter()][String]$VMStoragePath = '',
[Parameter()][String]$VHDStoragePath = '',
[Parameter()][String]$InstallISOPath = 'C:\Users\giova\Downloads\CentOS-7-x86_64-Minimal-1708.iso',