This file contains 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
.google-maps-responsive { | |
position: relative; | |
padding-bottom: 75%; // This is the aspect ratio | |
height: 0; | |
overflow: hidden; | |
} | |
.google-maps-responsive iframe { | |
position: absolute; | |
top: 0; |
This file contains 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
# List of selected categories | |
selected_categories = [Category.objects.get(name="TERRESTRE"), Category.objects.get(name="MOLUSCOS")] | |
# Products we want to filter based on the list of selected categories | |
products = Product.objects.filter(category__in = selected_categories) | |
# list is a tuple of tuples like ((id1, product_count1), (id2, product_count2), ... , (idn, product_countn)) | |
qs_count = Category.objects.values(‘id’).filter(product__in=products).annotate(Count('product')) | |
# Get the values |
This file contains 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
>>> Status = namedtuple('Status', 'open pending closed')._make(range(3)) | |
>>> Status.open, Status.pending, Status.closed | |
(0, 1, 2) | |
>>> class Status: | |
open, pending, closed = range(3) | |
>>> Status.open, Status.pending, Status.closed | |
(0, 1, 2) |
This file contains 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
#For example, you can run Python’s built-in server: | |
python -m SimpleHTTPServer 8888 & |
This file contains 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
[ | |
{ | |
"name": "SERES VIVOS", | |
"id": "192", | |
"photo": "http://www.antcontroldeplagas.es/wp-content/uploads/2013/02/hormigas-head.jpg", | |
"d": "Las hormigas son bonitas", | |
"children": [ | |
{ | |
"name": "ANIMALES", | |
"id": "193", |
This file contains 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
// An example of how to configure the CliBuilder to read command line arguments in Groovy. | |
def cli = new CliBuilder( usage: 'groovy launcher' ) | |
// Option help | |
cli.h(longOpt: 'help', 'usage information') | |
// Option script | |
cli.s(argName:'script', longOpt:'script', required: true, | |
args: 1, 'Script filename') |
This file contains 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
"title".center( 40, "-") |
This file contains 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
new File("simple.tab").withReader{r-> | |
line = r.readLine(); | |
println "first line: $line" | |
r.splitEachLine("\t"){fields-> | |
println "fields on line: $fields" | |
} | |
} |
This file contains 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
// Groovy: Reading XML with Java DocumentBuilder parsing with Java XPath | |
import javax.xml.parsers.DocumentBuilder; | |
import javax.xml.parsers.DocumentBuilderFactory; | |
import javax.xml.xpath.* | |
import org.w3c.dom.Document; | |
File f= new File( 'data.xml') | |
// Reading a Document Builder with Java style |
This file contains 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
mysql -e "show table status" | awk -F'\t' '\ | |
{\ | |
printf ("%-25s %15d\n", $1,$7); \ | |
s+=$7 \ | |
} \ | |
END{ print "resultado: ", s} \ | |
' |
OlderNewer