Skip to content

Instantly share code, notes, and snippets.

@lvterry
lvterry / parse.js
Created October 23, 2019 05:54
Use Papaparse to parse csv file
$.get('/data.csv', success);
function success(data) {
var results = Papa.parse(data, {
header: true,
dynamicTyping: true
});
var length = results.data.length;
var container = document.getElementById('photos');
@lvterry
lvterry / getAssetThumbnail.swift
Created March 28, 2016 14:57
Convert PHAsset to UIImage with Swift
// it returns a square thumbnail.
func getAssetThumbnail(asset: PHAsset, size: CGFloat) -> UIImage {
let retinaScale = UIScreen.mainScreen().scale
let retinaSquare = CGSizeMake(size * retinaScale, size * retinaScale)
let cropSizeLength = min(asset.pixelWidth, asset.pixelHeight)
let square = CGRectMake(0, 0, CGFloat(cropSizeLength), CGFloat(cropSizeLength))
let cropRect = CGRectApplyAffineTransform(square, CGAffineTransformMakeScale(1.0/CGFloat(asset.pixelWidth), 1.0/CGFloat(asset.pixelHeight)))
let manager = PHImageManager.defaultManager()
@lvterry
lvterry / style.css
Created January 27, 2016 03:24
Disable body scroll on mobile safari
/* Add these styles to the body element when menu is displayed */
body.has-active-menu {
overflow: hidden;
position: fixed;
}

3.5 inch Retina display (Required)

  • 640 x 920 pixels for hi-res portrait (without status bar) minimum
  • 640 x 960 pixels for hi-res portrait (full screen) maximum
  • 960 x 600 pixels for hi-res landscape (without status bar) minimum
  • 960 x 640 pixels for hi-res landscape (full screen) maximum

4 inch Retina display (Required)

  • 640 x 1096 pixels for portrait (without status bar) minimum
  • 640 x 1136 pixels for portrait (full screen) maximum
  • 1136 x 600 pixels for landscape (without status bar) minimum

Launch Sublime Text from Mac OSX Terminal

Sublime Text provides an executable file in its app. Just symblink it to somewhere in the PATH.

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl