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 / 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 / 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 / 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 / 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 / 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 / backup.sh
Last active December 21, 2015 00:18
Mysql backup shell
#!/bin/bash
fecha=$(date +%Y%m%d_%H%M)
echo "ready to dump database"
mysqldump -u root database --ignore-table=logs > /tmp/dump-$fecha.sql
echo "comprimiendo"
pbzip2 /tmp/dump-$fecha.sql
@atomsfat
atomsfat / switchWorkspace.sh
Last active December 19, 2015 00:39
Switch workspace every certain time, util for DIY dashboard
#!/bin/bash
NUMBER_DESkTOP="$(xdotool get_num_desktops)"
CURRENT="0"
echo "Press [CTRL+C] to stop.."
while :
do
xdotool set_desktop $CURRENT
#echo $CURRENT
CURRENT="$(expr $CURRENT + '1')"
if [ "$CURRENT" -gt $NUMBER_DESkTOP ]; then
@atomsfat
atomsfat / gist:5659302
Created May 27, 2013 22:03
smart command to troubleshoot permission on directories
dir=/tmp/level1/level2/level3/level4/level5/level6; while [ "$dir" != "/" ]; do ls -ald $dir; dir=`dirname $dir`; done
@atomsfat
atomsfat / Arduino_telnet_Server.pde
Created February 13, 2012 05:02
Arduino telnet server
/* *
* Arduino Telnet Server *
* 7 July 2010 *
* Basic Arduino I/O via *
* a command line interface *
* by Steve Lentz *
* stlentz[at]gmail[dot]com *
Quick Start Instructions:
1) Set Ethernet address in code below.
@atomsfat
atomsfat / server.xml
Created January 17, 2012 17:04
Basic tomcat configuration for load balancing
<?xml version='1.0' encoding='utf-8'?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0