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
#compdef fab | |
_targets() { | |
_describe -t commands "fabric targets" target_list | |
} | |
output_levels=( | |
'status: Status messages, i.e. noting when Fabric is done running, if the user used a keyboard interrupt, or when servers are disconnected from. These messages are almost always relevant and rarely verbose.' | |
'aborts: Abort messages. Like status messages, these should really only be turned off when using Fabric as a library, and possibly not even then. Note that even if this output group is turned off, aborts will still occur – there just won’t be any output about why Fabric aborted!' | |
'warnings: Warning messages. These are often turned off when one expects a given operation to fail, such as when using grep to test existence of text in a file. If paired with setting env.warn_only to True, this can result in fully silent warnings when remote programs fail. As with aborts, this setting does not control actual warning behavior, only whether warning messages are printed or hidden.' |
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
from django import template | |
register = template.Library() | |
@register.filter(name="identify") | |
def identify(value): | |
""" | |
Arguments: | |
- `value`: some object, probably a model |
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 get_label(label,val): | |
if val!=1: | |
return label+"s" | |
return label | |
diff = somedate -datetime.now() | |
hours, remainder = divmod(diff.seconds, 3600) |
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 groovy.text.SimpleTemplateEngine | |
def text = '${firstName} ${lastName} is a member of the ${lodge}' | |
def binding = [firstName: "Fred", lastName: "Flintstone", lodge:"Water Buffaloes"] | |
def engine = new SimpleTemplateEngine() | |
template = engine.createTemplate(text).make(binding) | |
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 groovy.text.SimpleTemplateEngine | |
/* this causes | |
* groovy.lang.MissingPropertyException: No such property: firstName for class: bad_template | |
*/ | |
def text = "${firstName} ${lastName} is a member of the ${lodge}" | |
def binding = [firstName: "Fred", lastName: "Flintstone", lodge:"Water Buffaloes"] | |
def engine = new SimpleTemplateEngine() |
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 groovy.text.SimpleTemplateEngine | |
class Member{ | |
String firstName | |
String lastName | |
String lodge | |
} | |
def text = '${firstName} ${lastName} is a member of the ${lodge}' | |
def member = new Member(firstName: "Fred", lastName: "Flintstone", lodge:"Water Buffaloes") |
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
/* Check if all fields are blank */ | |
StringBuilder rInfoRows = new StringBuilder() | |
rInfoRows.append(params.get("field1")?.toString()?.trim()) | |
rInfoRows.append(params.get("field2")?.toString()?.trim()) | |
rInfoRows.append(params.get("field3")?.toString()?.trim()) | |
Boolean isRInfoPresent = Boolean.FALSE | |
if(!"".equals(rInfoRows.toString())){ | |
isRInfoPresent = Boolean.TRUE | |
} |
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
tag1 = et.find("the_tag['sID']='GUID'") | |
tag2 = tag1.find("the_tag['eID']='GUID'") | |
content = tag2.previousSibling.text() |
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
from lxml import etree | |
def bib2html(xmlString): | |
root = etree.fromstring(xmlString) | |
out = etree.Element("out") | |
for beg_verse in root.findall(".//verse[@sID]"): |
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 groovy.text.SimpleTemplateEngine | |
class Member{ | |
String firstName | |
String lastName | |
String lodge | |
} | |
def text = '${firstName} ${lastName} is a member of the ${lodge}' |