Skip to content

Instantly share code, notes, and snippets.

@juque
juque / MySQL-Chile:regiones-provincias-comunas
Created July 6, 2010 19:32
Chile: Regiones, Provincias, Comunas
/* Estructura y Datos de las Regiones, Provincias */
/* y Comunas de Chile. */
/* */
/* Fecha: Julio 2010 */
/* Autor: Juan Pablo Aqueveque - juque.cl */
--
-- Comunas
--
DROP TABLE IF EXISTS `comunas`;
@dahnielson
dahnielson / UUID.php
Last active May 31, 2024 23:54
Pure PHP UUID generator
<?php
/**
* UUID class
*
* The following class generates VALID RFC 4122 COMPLIANT
* Universally Unique IDentifiers (UUID) version 3, 4 and 5.
*
* UUIDs generated validates using OSSP UUID Tool, and output
* for named-based UUIDs are exactly the same. This is a pure
* PHP implementation.
@RiANOl
RiANOl / gist:1077760
Last active April 13, 2024 06:17
AES128 / AES256 CBC with PKCS7Padding in Ruby
require "openssl"
require "digest"
def aes128_cbc_encrypt(key, data, iv)
key = Digest::MD5.digest(key) if(key.kind_of?(String) && 16 != key.bytesize)
iv = Digest::MD5.digest(iv) if(iv.kind_of?(String) && 16 != iv.bytesize)
aes = OpenSSL::Cipher.new('AES-128-CBC')
aes.encrypt
aes.key = key
aes.iv = iv
@tomas-stefano
tomas-stefano / receive.py
Created April 1, 2012 16:06
RabbitMQ example in Python
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callback(ch, method, properties, body):
print "[x] Received: %r" % (body,)
channel.basic_consume(callback, queue='hello', no_ack=True)
@quiver
quiver / new_task.py
Created October 6, 2012 12:15
rabbitmq : dead letter exchange example with python/pika
#!/usr/bin/env python
# http://www.rabbitmq.com/tutorials/tutorial-two-python.html
import pika
import sys
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
message = ' '.join(sys.argv[1:]) or "Hello World!"
@soarez
soarez / ca.md
Last active July 15, 2024 09:31
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@toast38coza
toast38coza / call_weather_service.py
Created August 29, 2014 08:25
Calling a SOAP WebService with Python Suds
from suds.client import Client
url="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"
client = Client(url)
print client ## shows the details of this service
result = client.service.GetWeatherInformation()
print result ## see: restult.txt below
@urodoz
urodoz / clean_docker.sh
Last active September 12, 2022 18:17
Cleans the old images and exited containers
# Clean the exited containers
docker rm $(sudo docker ps -a | grep Exit | cut -d ' ' -f 1)
# Clean the untagged images (or old images)
docker rmi $(docker images | tail -n +2 | awk '$1 == "<none>" {print $'3'}')
# On Docker 1.9+ you can remove the orphan volumes with the next command
docker volume rm $(docker volume ls -qf dangling=true)
@joshuacalloway
joshuacalloway / SecureRequestCache
Created February 27, 2015 00:08
HowTo force Spring Security to make https redirect requests when behind a load balancer
package com.retel.security;
import org.springframework.security.web.PortResolver;
import org.springframework.security.web.PortResolverImpl;
import org.springframework.security.web.WebAttributes;
import org.springframework.security.web.savedrequest.DefaultSavedRequest;
import org.springframework.security.web.util.UrlUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@richlander
richlander / dotnet-crypto-46.cs
Last active June 4, 2022 18:45
.NET Cryptography Updates for the .NET Framework 4.6
// Example 1: Signing a byte[] using PKCS#1 v1.5 padding and a SHA-256 hash
// 4.5:
public static byte[] SignDataPkcs1Sha256(X509Certificate2 cert, byte[] data)
{
// X509Certificate2.PrivateKey returns the same object across multiple calls,
// so it shouldn't be Disposed independent of the X509Certificate2 object.
//
// The RSA base class doesn't expose any signature-based methods.
// The PrivateKey property returns AsymmetricAlgorithm, so really this call should be