Skip to content

Instantly share code, notes, and snippets.

@MichaelEvans
MichaelEvans / blips_controller.rb
Created December 29, 2011 15:21
JS Displayed, Not Executed
class BlipsController < ApplicationController
before_filter :login_required
respond_to :js
def create
@blip = current_user.blips.build(params[:blip])
@blip.created_at = Time.now
#respond_to do |format|
@MichaelEvans
MichaelEvans / gist:2702535
Created May 15, 2012 15:13
Map _ to Shift + Space
xmodmap -e 'keycode 65 = space underscore'
# ----------------- OAUTH CONSUMER ------------------
consumer = OAuth::Consumer.new('anonymous', 'anonymous', {
:site => 'https://www.google.com',
:request_token_path => '/accounts/OAuthGetRequestToken',
:access_token_path => '/accounts/OAuthGetAccessToken',
:authorize_path => '/accounts/OAuthAuthorizeToken'
})
# ----------------- NEW OAUTH TOKEN ------------------
request_token = consumer.get_request_token({}, {:scope => 'https://www.google.com/analytics/feeds'})
@MichaelEvans
MichaelEvans / mail_template.html
Created May 21, 2013 20:36
Test email with Schema for Gmail
<html>
<head>
<title>Did you enjoy Iron Man?</title>
<script type="application/ld+json">
{
"@context": "schema.org",
"@type": "EmailMessage",
"action": {
"url": "http://www.youtube.com/watch?v=NPoHPNeU9fc"
},
/**
* Creates a 'ghost' bitmap version of the given source drawable (ideally a BitmapDrawable).
* In the ghost bitmap, the RGB values take on the values from the 'color' argument, while
* the alpha values are derived from the source's grayscaled RGB values. The effect is that
* you can see through darker parts of the source bitmap, while lighter parts show up as
* the given color. The 'invert' argument inverts the computation of alpha values, and looks
* best when the given color is a dark.
*/
private Bitmap createGhostIcon(Drawable src, int color, boolean invert) {
int width = src.getIntrinsicWidth();
import sys
from PIL import Image, ImageDraw
try:
import cv
except ImportError:
print 'Could not import cv, trying opencv'
import opencv.cv as cv
import android.content.Context;
import android.graphics.Bitmap;
import android.renderscript.Allocation;
import android.renderscript.Element;
import android.renderscript.RenderScript;
import android.renderscript.ScriptIntrinsicBlur;
import com.squareup.picasso.Transformation;
public class BlurTransform implements Transformation {
#!/usr/bin/perl
use Mysql;
use strict;
use vars qw($school_name);
use vars qw($pass);
require "./cgi-lib.pl";
// Copyright 2012 Square, Inc.
package com.squareup.widgets;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.widget.ImageView;
/** Maintains an aspect ratio based on either width or height. Disabled by default. */
public class AspectRatioImageView extends ImageView {