Skip to content

Instantly share code, notes, and snippets.

@chrillo
chrillo / highResCanvas.js
Created December 6, 2011 09:17
Creates a dpi agnostic html canvas for high res images for mobile phones like iphone 4 retina display
/*
This method creates a html canvas and automatically scales it fit the mobile devices display dpi. You can code everything for 320 px and it still looks pixel perfect on high res displays like iPhone 4 or newer Android devices.
iPhone 3Gs has 320 x 480 devicePixelRatio = 1, Android phone has 480 x 800 devicePixelRatio=1.5, iPhone 4 has 480 x 960 devicePixelRatio = 2
code like this creates a circle of the same size on all devices without pixeling
*/
@alotaiba
alotaiba / google_speech2text.md
Created February 3, 2012 13:20
Google Speech To Text API

Google Speech To Text API

Base URL: https://www.google.com/speech-api/v1/recognize
It accepts POST requests with voice file encoded in FLAC format, and query parameters for control.

Query Parameters

client
The client's name you're connecting from. For spoofing purposes, let's use chromium

lang
Speech language, for example, ar-QA for Qatari Arabic, or en-US for U.S. English

@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@blackxored
blackxored / client.coffee
Created July 2, 2012 04:44
Token authentication with Devise and Backbone
jQuery.ajaxSetup(
beforeSend: (xhr) ->
xhr.setRequestHeader('X-Auth-Token',
App.Session.getAuthenticationToken())
)
# ...
class App.Session
# ...
getAuthenticationToken: ->
@franc
franc / spineforge.thor
Created July 8, 2012 16:27
thor script for building Spine.js & Trigger.io Forge app
class Spineforge < Thor
include Thor::Actions
# thor spineforge:fuse ios
desc "fuse ios/android","builds and runs app"
def fuse(platform)
#cd spineapp
@spineapp_dir = File.dirname(__FILE__)
@forge_dir = @spineapp_dir + '/../'
inside @spineapp_dir do
@lengarvey
lengarvey / assets_location_nginx.conf
Created September 25, 2012 01:14
Access control allow origin header for nginx
location /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
}
## {{{ http://code.activestate.com/recipes/532908/ (r3)
#! /usr/bin/env python
"""
pyText2Pdf - Python script to convert plain text files into Adobe
Acrobat PDF files with support for arbitrary page breaks etc.
Version 2.0
Author: Anand B Pillai <abpillai at gmail dot com>
@LeaVerou
LeaVerou / dabblet.css
Created March 4, 2013 00:01
Switch-style checkboxes.
/**
* Switch-style checkboxes.
* Inspired by Espresso’s “Tools” switch
*/
input[type="checkbox"]:not(:checked),
input[type="checkbox"]:checked { /* :checked here acting as a filter for older browsers */
position: absolute;
opacity: 0;
}
@delong8
delong8 / time.py
Last active October 25, 2017 15:59
python 拿当前的时间戳 秒数和毫秒数,time的经度跟系统相关,windows小数点后3位,linux后面6位
import time
from datetime import datetime, date
# 今天
datetime.datetime.today().date().isoformat()
# 通过日期对象生成时间戳
int(time.mktime(datetime.now().timetuple()))
# 通过时间戳生成日期对象,timestamp 的时间戳以秒为单位
@aprock
aprock / RoundedTransformation.java
Created August 12, 2013 18:08
Rounded Corner Image Transformation for square's Picasso
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
// enables hardware accelerated rounded corners
// original idea here : http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/