- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
<?php | |
$watermark = Image::factory(DOCROOT.'upload/kohana.png') | |
->resize(200, 200); | |
$this->request->set_header('content-type', 'image/jpeg'); | |
$this->request->response = Image::factory(DOCROOT.'upload/andyou.jpg') | |
->resize(800, 600) | |
->crop(500, 500) | |
->watermark($watermark, -1, -1, 80) |
#!/usr/bin/python | |
from BeautifulSoup import BeautifulSoup | |
import sys | |
soup = BeautifulSoup(sys.stdin.read()) | |
print soup.prettify() |
var page = new WebPage(), | |
address, output, size; | |
//capture and captureSelector functions adapted from CasperJS - https://github.com/n1k0/casperjs | |
capture = function(targetFile, clipRect) { | |
var previousClipRect; | |
var clipRect = {top: 0, left:0, width: 40, height: 40}; | |
if (clipRect) { | |
if (!isType(clipRect, "object")) { | |
throw new Error("clipRect must be an Object instance."); |
# Simple 16 step drum machine experiment with Node and CoffeeScript | |
# by Peter Cooper - @peterc | |
# | |
# Inspired by Giles Bowkett's screencast at | |
# http://gilesbowkett.blogspot.com/2012/02/making-music-with-javascript-is-easy.html | |
# | |
# Screencast demo of this code at http://www.youtube.com/watch?v=qWKkEaKL6DQ | |
# | |
# Required: | |
# node, npm and coffee-script installed |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
using WebGrease.Css.Extensions; | |
namespace App_Code | |
{ |
# vim style tmux config | |
# use C-a, since it's on the home row and easier to hit than C-b | |
set-option -g prefix C-a | |
unbind-key C-a | |
bind-key C-a send-prefix | |
set -g base-index 1 | |
# Easy config reload | |
bind-key R source-file ~/.tmux.conf \; display-message "tmux.conf reloaded." |
{ | |
"countries": [ | |
{ | |
"country": "Afghanistan", | |
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"] | |
}, | |
{ | |
"country": "Albania", | |
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"] | |
}, |
Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.
The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.
<script>
// require vue-resource...
new Vue({