Skip to content

Instantly share code, notes, and snippets.

View lamb-mei's full-sized avatar

羊小咩 lamb-mei

  • Taiwan / Taipei
View GitHub Profile
@lamb-mei
lamb-mei / UIImageView+topAlignmentAndAspectFit
Created December 15, 2018 16:25 — forked from megimix/UIImageView+topAlignmentAndAspectFit
UIImageView with Aspect Fit and Alignment To Top. thanks to (http://stackoverflow.com/a/27569222/1267174)
extension UIImageView {
func topAlignmentAndAspectFit(to view: UIView) {
self.contentMode = .scaleAspectFill
self.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(self)
self.addConstraints(
[NSLayoutConstraint(item: self,
attribute: .height,
relatedBy: .equal,
@lamb-mei
lamb-mei / scapeCostco.js
Created October 16, 2017 10:37 — forked from clonn/scapeCostco.js
擷取 costco 商品資料,如果商品沒有貨, result 的結果會是已售完
var request = require('request');
var cheerio = require('cheerio');
var url = 'https://www.costco.com.tw/Baby-Care-Kids-Toys/Toys/Infant-%26-Preschool/VTech-Sit-To-Stand-Ultimate-Alphabet-Train/p/105123';
request(url, function(err, res, body){
var $ = cheerio.load(body);
var result = $('.stock-status').text().trim();
@lamb-mei
lamb-mei / ball.js
Created May 4, 2016 02:29 — forked from jpbyrne/ball.js
A simple Breakout clone created using JavaScript
function Ball(x, y, radius, color) {
this.x = x;
this.y = y;
this.dx = 10;
this.dy = 10;
this.dxRange = this.dx * 2;
this.radius = radius;
@lamb-mei
lamb-mei / sed_snippets.sh
Created April 21, 2016 17:19 — forked from r2k0/sed_snippets.sh
sed examples
##FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
# triple space a file
@lamb-mei
lamb-mei / ViewController.swift
Created October 21, 2015 02:03
Simple Barcode Scanning with Swift
import UIKit
import AVFoundation
class ViewController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
let session : AVCaptureSession = AVCaptureSession()
var previewLayer : AVCaptureVideoPreviewLayer!
var highlightView : UIView = UIView()
@lamb-mei
lamb-mei / index.html
Last active August 29, 2015 14:14 — forked from davidwkeith/index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!-- iframe used for attempting to load a custom protocol -->
<iframe style="display:none" height="0" width="0" id="loader"></iframe>
@lamb-mei
lamb-mei / index.js
Last active August 29, 2015 14:10 — forked from edokeh/index.js
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@lamb-mei
lamb-mei / index.js
Last active August 29, 2015 14:10 — forked from shycool/index.js
//
// _oo0oo_
// o8888888o
// 88" . "88
// (| -_- |)
// 0\ = /0
// ___/`---'\___
// .' \\| |// '.
// / \\||| : |||// \
// / _||||| -:- |||||- \
@lamb-mei
lamb-mei / javascript_resources.md
Last active August 29, 2015 14:06 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@lamb-mei
lamb-mei / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console