Skip to content

Instantly share code, notes, and snippets.

View jgujgu's full-sized avatar

jgu jgujgu

  • Denver
View GitHub Profile
@DakotaLMartinez
DakotaLMartinez / Dockerfile
Created December 3, 2017 23:01
Sharetribe Dockerfile
FROM ruby:2.3.4
MAINTAINER Sharetribe Team <team@sharetribe.com>
ENV REFRESHED_AT 2016-11-08
RUN apt-get update \
&& apt-get dist-upgrade -y
#
@jakekdodd
jakekdodd / README.md
Created February 20, 2015 16:30
Example of kafka-python producer using Avro

Notes:

  • This uses the python loremipsum generator. You can replace g.generate_sentence() with your own string or generator of choice
  • Make sure to replace schema_path in the script with your own schema path
  • No guarantees that this is the best way to loop over records and publish them to Kafka, just a demo. Before adapting this script, take a look at the Avro documentation...the writer might not need to be instantiated for every record, for example. I'm just not sure.

Instructions

  1. Create a Kafka topic to test this on (default in the script is 'test')
  2. Replace schema_path with the path to user.avsc
  3. Open up a console Kafka consumer (see the 'quick start' section in Kafka's documentation)
@gisminister
gisminister / README.md
Last active April 11, 2024 18:52
Markercluster pie charts

The map shows traffic accidents recorded in Oslo, Norway, for the year 2013.

The Leaflet Markercluster plugin is wonderful. Since the markerclusters are divIcons you can put whatever you want inside them using the iconCreateFunction. I wanted my clusters to reveal more information than just the marker count and figured a pie chart would do the job. So I told the iconCreateFunction to do some D3 magic and this is the result.

The example is a bit more complicated than necessary due to how my dataset is structured. But if you take a look at the defineClusterIcon() function you'll see that I use d3.nest() to build a dataset for the pie chart based on a given property from all the cluster's children. Then I pass this dataset over to the bakeThePie() function together with instructions on how to style the chart. The function returns svg markup which in turn is placed inside the divIcon.

Feel free to suggest improvements.

@jcasimir
jcasimir / friendly_urls.markdown
Created September 11, 2011 15:48
Friendly URLs in Rails

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.