This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def log(log_name): | |
def decorator(func): | |
def inner(self, nombre): | |
print("[%s] Logging a call to %s" % (log_name, func.__name__)) | |
return func(self, nombre) | |
return inner | |
return decorator | |
class Persona: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graph = { | |
("A", "yes"): "B", | |
("A", "no"): "C", | |
} | |
accepted_states = ("B", "C") | |
transitions = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[program:gogs] | |
command=/home/<GOGS-USER>/gogs/gogs web | |
autostart=true | |
user=<GOGS-USER> | |
directory=/home/<GOGS-USER>/gogs | |
environment=HOME="/home/<GOGS-USER>",USER="<GOGS-USER>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from functools import reduce | |
def to_fate(result): | |
if result < 3: | |
return '-' | |
elif result < 5: | |
return ' ' | |
else: | |
return '+' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabConfig(systemClassLoader=true) | |
@Grab('com.h2database:h2:1.4.180') | |
import groovy.sql.Sql | |
Sql sql = Sql.newInstance("jdbc:h2:/tmp/devDb", 'sa', '') | |
println "=================== TEST CONTENT" | |
println '>> You can invoke this script with two args to insert into test table (id, name)' | |
println '>> You can invoke this script with the argument CREATE or DESTROY to create or destroy the test table' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum EitherStatus { | |
LEFT, RIGHT | |
} | |
class Either { | |
EitherStatus status = EitherStatus.RIGHT | |
Map data | |
String toString() { | |
return "[${this.status}] > ${this.data}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def socket = new Socket('localhost', 5000) | |
socket.withStreams { input, output -> | |
println input.newReader().readLine() | |
output << 'Imma socket' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In config/application.rb | |
config.watchable_dirs['lib'] = [:rb] | |
# When requiring something, use require_dependency | |
# To use lib/myclass.rb | |
require_dependency 'myclass' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab("io.ratpack:ratpack-groovy:0.9.2") | |
import static ratpack.groovy.Groovy.* | |
import ratpack.handling.Handler | |
import ratpack.handling.Context | |
ratpack { | |
handlers { | |
get new TestHandler() | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab("io.ratpack:ratpack-groovy:0.9.2") | |
import static ratpack.groovy.Groovy.* | |
import ratpack.handling.Handler | |
import ratpack.handling.Context | |
import static groovy.json.JsonOutput.toJson | |
import static ratpack.registry.Registries.registry | |
ratpack { |