Skip to content

Instantly share code, notes, and snippets.

var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
// if backingStorePixelRatio is less than devicePixelRatio, everything needs to be scaled up
var ratio = (context.webkitBackingStorePixelRatio < window.devicePixelRatio) ? (window.devicePixelRatio || 1) : 1;
if (ratio > 1) {
canvas.width *= ratio;
canvas.height *= ratio;
context.scale(ratio, ratio);
}
@vmus
vmus / Customize Button shape in ios 7.1
Last active November 2, 2018 02:26
(http://stackoverflow.com/questions/22345046/customize-button-shape-in-ios-7-1) Sub class the button and try which shape you want.... (answered Mar 12 at 10:06 by Spynet)
#import "YourButton.h"
#import <QuartzCore/QuartzCore.h>
@implementation YourButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
@vmus
vmus / hankaku.js
Created July 27, 2012 14:48
Japanese text normalization (fullwidth to halfwidth)
// Japanese text normalization (fullwidth to halfwidth)
function normalize(s) {
function zentohan(c) {
var z2h = {
'ガ':'ガ','ギ':'ギ','グ':'グ','ゲ':'ゲ','ゴ':'ゴ',
'ザ':'ザ','ジ':'ジ','ズ':'ズ','ゼ':'ゼ','ゾ':'ゾ',
'ダ':'ダ','ヂ':'ヂ','ヅ':'ヅ','デ':'デ','ド':'ド',
'バ':'バ','パ':'パ','ビ':'ビ','ピ':'ピ','ブ':'ブ',
'プ':'プ','ベ':'ベ','ペ':'ペ','ボ':'ボ','ポ':'ポ','ヴ':'ヴ',
'ァ':'ァ','ア':'ア','ィ':'ィ','イ':'イ','ゥ':'ゥ','ウ':'ウ','ェ':'ェ','エ':'エ','ォ':'ォ','オ':'オ',