Skip to content

Instantly share code, notes, and snippets.

View patrick91's full-sized avatar

Patrick Arminio patrick91

View GitHub Profile
@patrick91
patrick91 / AnimatedRegion.js
Created February 20, 2013 10:24
Backbone Marionette View Transition
var AnimatedRegion = Backbone.Marionette.Region.extend({
show: function(view) {
this.ensureEl();
view.render();
this.close();
if (this.currentView && this.currentView !== view) {
return;
}
function scaleImage($img, w, h, targetWidth, targetHeigth) {
var ratio = targetWidth / w;
var height = h * ratio;
var width = w * ratio;
if (targetHeigth && height > targetHeigth) {
ratio = targetHeigth / h;
height = targetHeigth;
@patrick91
patrick91 / jquery.autofitinput.js
Created December 11, 2013 17:17
Resize input according to its content.
(function ($) {
$.fn.autoFitInput = function (o) {
function getTestSubject(input, text) {
var testSubject = $('#input-tester');
if (testSubject.length === 0){
testSubject = $('<pre id="input-tester" />').appendTo('body').css({
position: 'absolute',
top: -9999,
left: -9999,
{% load cms_tags sekizai_tags compressed static %}
{% if not request.is_ajax %}{% include "base_head.html" %}{% endif %}
<div class="main">
{% block base_content %}{% endblock %}
</div>
{% if not request.is_ajax %}{% include "base_foot.html" %}{% endif %}
body {
color: #424242;
font: 21px/32px "Courier New";
}
h1 {
font-weight: normal;
font-family: Garamond;
@patrick91
patrick91 / .gitignore
Created October 29, 2014 20:33
Android studio .gitignore
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
@patrick91
patrick91 / BasicAuthInterceptor.java
Created February 20, 2015 21:39
Picasso Basic Auth
import android.util.Base64;
import com.squareup.okhttp.Interceptor;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import java.io.IOException;
public class BasicAuthInterceptor implements Interceptor {
String username;
def merge(range1, range2):
"""
returns a merged range if range can be merged,
otherwise returns False.
we suppose that range1[0] <= range2[0]
"""
if range1 == range2:
return range1
aws iam upload-server-certificate \
--server-certificate-name MixTheCitySha2 \
--certificate-body file://mixthecity.com.crt \
--private-key file://mixthecity.com.plain.key \
--certificate-chain file://sub.class1.server.sha2.ca.pem \
--path /cloudfront/mix-the-city/
@patrick91
patrick91 / config.go
Last active September 15, 2018 11:43 — forked from agtorre/config.go
Store OAuth2 Token Using Datastore
// Config is a custom oauth2 config that is used to store the token
// in the datastore
type Config struct {
*oauth2.Config
}
// StoreToken is called when exchanging the token and saves the token
// in the datastore
func (c *Config) StoreToken(ctx context.Context, token *oauth2.Token) error {
log.Infof(ctx, "storing the token")