Skip to content

Instantly share code, notes, and snippets.

View mateusmaso's full-sized avatar

Mateus Maso mateusmaso

View GitHub Profile
@ShamylZakariya
ShamylZakariya / debounce.swift
Created September 4, 2014 21:01
Simple Swift Debouncer
func debounce( delay:NSTimeInterval, #queue:dispatch_queue_t, action: (()->()) ) -> ()->() {
var lastFireTime:dispatch_time_t = 0
let dispatchDelay = Int64(delay * Double(NSEC_PER_SEC))
return {
lastFireTime = dispatch_time(DISPATCH_TIME_NOW,0)
dispatch_after(
dispatch_time(
DISPATCH_TIME_NOW,
@cyu
cyu / twitter_application_only_token.rb
Last active November 18, 2016 23:50
How to get a Twitter application-only bearer token#
# https://dev.twitter.com/docs/auth/application-only-auth
require 'open-uri'
require "base64"
require 'net/http'
require 'json'
CONSUMER_KEY = 'MY_CONSUMER_KEY'
CONSUMER_SECRET = 'MY_CONSUMER_SECRET'
@vibegui
vibegui / compress-pdf-with-gs.md
Created August 30, 2013 14:39
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.
@ebidel
ebidel / Web Components Resources.md
Last active March 23, 2026 03:02
List of resources related to Web Components
@spikebrehm
spikebrehm / base.coffee
Created July 3, 2013 16:00
An example base model for Rendr, showing a way to use relations between models.
_ = require('underscore')
RendrBase = require('rendr/shared/base/model')
module.exports = class Base extends RendrBase
constructor: ->
super
@initRelations()
initRelations: ->
return unless @relations?
@ogrrd
ogrrd / dnsmasq OS X.md
Last active July 17, 2026 14:43
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

rivets.configure({
adapter: {
subscribe: function (obj, keypath, callback) {
var parts = [keypath];
var index = keypath.indexOf('.');
if (index > -1) parts = keypath.split('.');
this.subscribe_nested(parts, obj, callback);
},
subscribe_nested: function rivets_backbone_adapter_subscribe_nested(parts, obj, callback) {
@wkrsz
wkrsz / backbone-rivets.config.js
Last active December 18, 2015 04:49 — forked from wulftone/backbone-rivets.config.js
Some funky syntax for Rivets: model.@Attribute, model.attribute, model.computed().
// Bind to backbone attribute (read/write with get/set, subscribe to change:attribute event):
// data-text="model.@attribute"
//
// Bind to output of function (calls the function to get value, subscribes to 'change' event):
// data-text="model.computedProperty()
//
// Bind to attribute (subscribes to 'change' event):
// data-text="model.attr"
(function(rivets){
Controller = require('controller')
Post = require('app/models/post')
class List extends Controller
className: 'posts-list'
constructor: ->
super
# Post.all() returns a promise. Data from
# the server is fetched asyncronously.
@snatchev
snatchev / routes.rb
Last active December 16, 2015 07:09
DRYing up your Rails API routes. Rails' routing gives you the ability to add multiple contraints and scopes to routes. These conditions are and'ed together. Meaning all conditions must be true for the route to match. If you want to or them, to have any condition match, you are left with duplicated code. In this example, I wanted both http://api.…
Rails::Application.routes.draw do
def api_endpoints
controller :api do
resources :widget
post :register
get :help
end
end