Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Maiaroto tmaiaroto

View GitHub Profile
@tmaiaroto
tmaiaroto / System.php
Created February 21, 2012 16:29
A model class to help you work with some more advanced features of MongoDB using the Lithium PHP framework.
View System.php
<?php
/**
* A System model to work with MongoDB from a higher level.
* This model will executes various commands as well as store new commands.
* The system.js collection is used.
*
* Warning: There be dragons in here.
*
*/
namespace app\models;
@tmaiaroto
tmaiaroto / cron.php
Created April 20, 2012 18:12
Lithium Cron Wrapper
View cron.php
<?php
/**
* This script is meant to be executed via crontab.
* It should help you easily set li3 commands as cron jobs.
*
* You should put this in the root of your application.
* However, you don't need to, but you would then need to
* pass a --path= option with the path to your app.
* This is because the li3 console command must be called
* from a specific location.
@tmaiaroto
tmaiaroto / virtual.conf
Created August 9, 2012 18:48
Nginx Virtual Host Setup for OS X using Homebrew
View virtual.conf
#
# A virtual host using mix of IP-, name-, and port-based configuration.
# This is based on using Homebrew for OS X. You can use this in other
# cases though, but you'll likely need to adjust some of the paths below.
#
server {
# Replace this port with the right one for your requirements
# listen 80 [default|default_server]; #could also be 1.2.3.4:80
@tmaiaroto
tmaiaroto / README.md
Created October 20, 2012 22:29 — forked from mbostock/.block
Pie Chart
View README.md

This pie chart is constructed from a CSV file storing the populations of various age groups. The chart employs a number of D3 features:

@tmaiaroto
tmaiaroto / collection+json.md
Last active May 23, 2022 12:29
JSON Based Hypermedia Structures - Notes & Comparisons
View collection+json.md

Collection+JSON format

http://amundsen.com/media-types/collection/examples/

This format takes into consideration collections (much like Siren). It also takes into consideration versioning. However, I'm not certain version matters in the data set if it pertains to an API version. That is best left being in the API URL. It could pertain to collection version, but I'm not sure the point. Documentation says each collection should have a version - but says nothing more about meaning or why.

Items are clearly distinct in this format and are organizationally positioned separate from links.
This is by far the most collision free structure.

However, the data format itself is a bit strange...Every field being an array. Data is always an array of objects. I understand the flexibility this presents and am not 100% against it. I just believe it's perhaps not needed as things could change based on the client application.

@tmaiaroto
tmaiaroto / image-proxy.conf
Last active December 16, 2021 03:23
Nginx Image Filter Resize Proxy Service
View image-proxy.conf
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
@tmaiaroto
tmaiaroto / keybase.md
Created August 4, 2014 18:02
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am tmaiaroto on github.
  • I am tom_m (https://keybase.io/tom_m) on keybase.
  • I have a public key whose fingerprint is 5948 CBF7 08F2 5DD6 A8E4 2AAC 051A CEFF 7F30 0462

To claim this, I am signing this object:

@tmaiaroto
tmaiaroto / usc.go
Created November 7, 2014 20:25
Golang map of US state codes : full name
View usc.go
// A handy map of US state codes to full names
var usc = map[string]string{
"AL": "Alabama",
"AK": "Alaska",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
@tmaiaroto
tmaiaroto / upperlower.go
Created November 9, 2014 04:53
Golang: somewhat faster string uppercase / lowercase (for certain strings)
View upperlower.go
// See: https://groups.google.com/forum/#!topic/golang-nuts/Il2DX4xpW3w
// A slightly faster lowercase function.
func toLower(s string) string {
b := make([]byte, len(s))
for i := range b {
c := s[i]
if c >= 'A' && c <= 'Z' {
c += 'a' - 'A'
}
@tmaiaroto
tmaiaroto / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console