Skip to content

Instantly share code, notes, and snippets.

View miceno's full-sized avatar

Orestes Sanchez miceno

  • Barcelona, Spain
View GitHub Profile
@miceno
miceno / notas desarrollo bbpress.txt
Created January 3, 2011 10:36
Notas desarrollo bbpress
notas de integracion
opciones:
public_key
private_key
bluevia_auth_cookie_name: la cookie que vamos a utilizar para la autenticacion.
bluevia_cookies: nombres de las cookies.
bluevia_login_url: url de la pagina de login de bluevia
bluevia_register_url: url de la pagina de registro de bluevia
bluevia_edit_profile_url: url de la pagina de perfil de un usuario de bluevia
@miceno
miceno / send-email-attachment.pl
Created January 3, 2011 12:46
Database backup and send by email
#!/bin/bash
function do_backup(){
FICHERO_BACKUP=$1
# Do the backup
$MYSQL_PATH/mysqldump -p"$password" \
--add-drop-table \
-h "$hostname" \
-u "$username" \
"$database" \
@miceno
miceno / gist:787640
Created January 20, 2011 09:33
Groovy HTML DSL example
// def writer = new FileWriter('markup.html')
def writer = new StringWriter()
def html = new groovy.xml.MarkupBuilder(writer)
html.html {
head { title 'Constructed by MarkupBuilder' }
body {
h1 'What can I do with MarkupBuilder?'
form (action:'whatever') {
@miceno
miceno / gist:793079
Created January 24, 2011 11:03
Date parsing
import java.util.Date
import java.text.SimpleDateFormat
String myDate= '2011-01-20T13:51:24.63Z'
Date dtTmp = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss").parse( myDate);
println dtTmp.toString()
@miceno
miceno / gist:800543
Created January 28, 2011 16:53
HTML Markup builder example
// def writer = new FileWriter('markup.html')
def writer = new StringWriter()
def html = new groovy.xml.MarkupBuilder(writer)
html.html {
head { title 'Constructed by MarkupBuilder' }
body {
h1 'What can I do with MarkupBuilder?'
form (action:'whatever') {
for (line in ['Produce HTML','Produce XML','Have some fun'])
@miceno
miceno / gist:802781
Created January 30, 2011 10:58
Groovy (java) escape HTML
import org.apache.commons.lang.StringEscapeUtils
// Alternate way to import
this.class.classLoader.rootLoader.addURL(new File("/usr/local/java/grails-1.0/lib/commons-lang-2.1.jar").toURL())
xml = '''
<module id="id" version="0.0.1" package="package"> </module>
'''
@miceno
miceno / gist:814594
Created February 7, 2011 16:04
Groovy XML Builder to DOM and Document
import org.restlet.data.MediaType;
import org.restlet.resource.DomRepresentation;
import org.w3c.dom.Document
// Representation
DomRepresentation representation = new DomRepresentation( MediaType.TEXT_XML)
// Get the document root
Document doc= representation.getDocument()
@miceno
miceno / gist:824596
Created February 13, 2011 11:12
Groovy testing
class MyClass{
def myname
}
class TestCase{
TestCase(){ }
def testNonEmptyTask(){
def f = new MyClass()
@miceno
miceno / gist:838854
Created February 22, 2011 15:43
convert String to List
data= '[ "mykey": "myValue" ]'
map = Eval.me( data )
// map= {myKey=myValue}
@miceno
miceno / gist:841964
Created February 24, 2011 09:32
Crawl with wget
wget --spider -r -l0 -np -k http://www.yoursite.com/