Skip to content

Instantly share code, notes, and snippets.

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

Tomás atomsfat

🏠
Working from home
View GitHub Profile
@atomsfat
atomsfat / s3_up.groovy
Last active July 10, 2019 15:02
Upload to S3 with Groovy
/* Script to upload files to S3.
* @author Tomas Salazar
*/
@GrabResolver(name='jets3t', root='http://www.jets3t.org/maven2', m2Compatible='true')
@Grab(group='net.java.dev.jets3t', module='jets3t', version='0.9.0')
import org.jets3t.service.impl.rest.httpclient.RestS3Service
import org.jets3t.service.security.AWSCredentials
import org.jets3t.service.model.*
accessKey = 'Cambiar'
@atomsfat
atomsfat / copy certificate
Created October 15, 2013 20:29
certficate jenkins
def command = """cat /var/lib/jenkins/.ssh/id_rsa.pub"""// Create the String
def proc = command.execute() // Call *execute* on the string
proc.waitFor() // Wait for the command to finish
// Obtain status and output
println "return code: ${ proc.exitValue()}"
println "stderr: ${proc.err.text}"
println "stdout: ${proc.in.text}" // *out* from the external program is *in* for groovy
@atomsfat
atomsfat / 2roman.groovy
Created December 20, 2013 18:20
cardinal to roman
def cardinalToRoman( int num){
def TreeMap map = [1:"I", 5: "V", 10 : "X", 100 :"C"]
def getLatestKey = {int nu ->
def val = null
for (Map.Entry entry : map.descendingMap().entrySet()) {
def residuo = nu % entry.key;
@atomsfat
atomsfat / Media.groovy
Created January 28, 2014 18:36
Fat grails domain class with custom marshaller
package atoms.fat.media
import grails.converters.JSON
import org.joda.time.DateTime
class Media implements Serializable {
String url
String name
DateTime dateCreated
@atomsfat
atomsfat / BootStrap.groovy
Created January 28, 2014 18:45
BootStrap definition to automatically register custom marshaller
class BootStrap {
def grailsApplication
grailsApplication.getArtefacts("Domain").each{dc->
//here we register custom marshallers declared in domain classes
if(dc.hasProperty("marshaller")){
dc.clazz.marshaller()
}
}
@atomsfat
atomsfat / concurrent
Created April 21, 2014 21:16
concurrent closuere
def concurrent(int count, Closure closure) {
def values = []
def futures = []
ExecutorService executor = Executors.newFixedThreadPool(count)
CyclicBarrier barrier = new CyclicBarrier(count)
for (int i = 0; i < count; i++) {
futures.add(executor.submit(new Callable() {
public def call() throws Exception {
@atomsfat
atomsfat / Ingreso Proyecto
Last active August 29, 2015 14:08
Proyecto GEX Developer SR
Construir una api REST, para hacer altas, bajas cambios de usuarios, documentar la API.
Utilizar las siguientes tecnologias.
* Spring Boot
* PostgreSQL hibernate o Gorm
* Gradle
@atomsfat
atomsfat / docker_acordeon.txt
Created November 5, 2014 17:34
docker acordeon
boot2docker ip →Get lP
docker info
docker rm <name>
docker stop <name>
docker start <name>
docker attach <name>
docker ps -a
docker logs -f <name>
docker top <name>
docker inspect <name>
@atomsfat
atomsfat / gist:dc2ede8cbea2f397cd7f
Created February 25, 2015 18:33
raml2code build
#!/bin/bash
git@github.com:gextech/json-schema-2-groovy-pojo.git
git@github.com:gextech/json-schema-java-mapper-utils.git
git@github.com:atomsfat/raml2code.git
git@github.com:atomsfat/raml2code-fixtures.git
git@github.com:gextech/raml2code-jaxrs-interfaces.git
git@github.com:gextech/raml2code-retrofit.git
git@github.com:gextech/ram2code-utils.git
@atomsfat
atomsfat / varnish.vcl
Created August 30, 2016 21:39
Mobile Device Detection via User Agent RegEx Varnish
#Mobile detect https://gist.github.com/dalethedeveloper/1503252
if(req.http.User-Agent ~ ".*(Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune).*")
{
set req.http.X-ua = "mobile";
}else{
set req.http.X-ua = "desktop";
}
sub vcl_hash {
hash_data(req.http.X-ua + ":" + req.url );