Skip to content

Instantly share code, notes, and snippets.

@soeirosantos
soeirosantos / entrada.py
Created January 17, 2012 03:32
python - exercício 1
UNIDADE = 1
CAIXA_PCTE = 2
DUZIA = 3
def formata_codigo(codigo):
return codigo.zfill(10)
def formata_nome(nome):
return nome.upper()
@soeirosantos
soeirosantos / resources-copy.py
Created April 10, 2012 14:11
util for copy a lot of resources from diferent places and put them in a single place
'''
this is util for copy a lot of resources from diferent places and put them in a single place
In my case I use this for to copy dozens of jar files from my m2 local repository
'''
import shutil
'''
inform in a txt file all paths that you would like to copy, line by line
'''
@soeirosantos
soeirosantos / alo_spring_python.py
Created May 19, 2012 06:14
alo mundo usando Spring Python
"""
Download springpython-[release].tar.gz
Unpack and type python setup.py install
http://static.springsource.org/spring-python/1.2.x/sphinx/html/index.html
"""
from springpython.config import PythonConfig
from springpython.config import Object
from springpython.context import scope
@soeirosantos
soeirosantos / downpdf.py
Created October 9, 2012 17:10
simple script for download pdfs from a specific page
"""
simple script for download pdfs from a specific page
depends of BeautifulSoup http://www.crummy.com/software/BeautifulSoup/bs4/doc/
"""
import urllib2
import urllib
from bs4 import BeautifulSoup
#url from where are the pdfs
@soeirosantos
soeirosantos / CustomMethods.groovy
Created August 27, 2013 14:57
Groovy Module Extension
package br.com.soeirosantos
import java.text.SimpleDateFormat
class CustomMethods {
static isNotBlank(String self) {
!self.trim().isEmpty()
}
@soeirosantos
soeirosantos / to_utf8.py
Created December 15, 2014 17:01
Convert all files in a specified directory to utf-8. Warning: Make a backup of directory before run the script ;)
'''
sources:
http://stackoverflow.com/questions/191359/how-to-convert-a-file-to-utf-8-in-python
http://stackoverflow.com/questions/2212643/python-recursive-folder-read
'''
import os, sys, codecs
def convert(filepath):
BLOCKSIZE = 1048576
@soeirosantos
soeirosantos / hot_keywords.js
Last active August 29, 2015 14:19
Script da API do Google Ad Words que coloca um rótulo em todas as keywords que se aplicam a um determinado filtro.
function main() {
var IMPRESSIONS = 10;
var CTR = 0.01;
//var AVG_CPC = 2.00;
var keywords = AdWordsApp.keywords().
withCondition('CampaignStatus = ENABLED').
withCondition('AdGroupStatus = ENABLED').
withCondition('Status = ENABLED').
import os, sys, codecs
all_aliases = []
pattern = re.compile(r'[a-zA-Z_]+\$+[a-zA-Z_]+\$+[a-zA-Z_]+\$+[a-zA-Z_]+|[a-zA-Z_]+\$+[a-zA-Z_]+\$+[a-zA-Z_]+|[a-zA-Z_]+\$+[a-zA-Z_]+')
walk_dir = os.path.abspath('/caminho/para/o/diretorio/')
for root, subdirs, files in os.walk(walk_dir):
[all_aliases.extend(pattern.findall(" ".join( open(os.path.join(root, filename) ).readlines()))) for filename in files if filename.endswith("DAOOracle.java")]
plus_30_aliases = [alias for alias in all_aliases if len(alias) > 30]
@soeirosantos
soeirosantos / binding.xml
Created November 6, 2015 13:39
Exemplo de binding JAXB que força @XMLRootElement nas entidades criadas
<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings wsdlLocation="DetranMock.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:annox="http://annox.dev.java.net"
jxb:extensionBindingPrefixes="xjc annox">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://detran.mock']">
<jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
@soeirosantos
soeirosantos / wildfly-install.sh
Created December 3, 2015 11:55
Script to install Wildfly 8.x on CentOS 7
#!/bin/bash
#Title : wildfly-install.sh
#Description : Script to install Wildfly 8.x on CentOS 7
#Original script: http://sukharevd.net/wildfly-8-installation.html
# This version is the only variable to change when running the script
WILDFLY_VERSION=8.2.1.Final
WILDFLY_FILENAME=wildfly-$WILDFLY_VERSION
WILDFLY_ARCHIVE_NAME=$WILDFLY_FILENAME.tar.gz