- Local dir to remote bucket sync
- Local dir to remote bucket copy with gzip content encoding header
- Remote to remote bucket copy
$ aws s3 sync \
Number.prototype.pad = function(size) { | |
var s = String(this); | |
while (s.length < (size || 2)) {s = "0" + s;} | |
return s; | |
} | |
(1).pad(3) // => "001" | |
(10).pad(3) // => "010" | |
(100).pad(3) // => "100" |
function quickSort(arr){ | |
if(arr.length < 2) | |
return arr; | |
var pivot = arr[Math.floor(arr.length/2)]; | |
var middle = arr.filter(function (data) {return data == pivot;}); | |
var lows = quickSort(arr.filter(function (data) {return data < pivot;})); | |
var highs = quickSort(arr.filter(function (data) {return data > pivot;})); | |
// Convert from decimal to binary | |
(11).toString(2) // “1011" | |
// Convert from decimal to hexadecimal | |
(255).toString(16) // ‘ff' | |
// Convert from binary to decimal | |
parseInt("1011", 2); // 11 | |
// Convert from binary to hexadecimal |
const CANCEL = Symbol(); | |
class CancellationToken { | |
constructor() { | |
this.cancelled = false; | |
} | |
throwIfCancelled() { | |
if (this.isCancelled()) { |
#!/bin/sh | |
BUCKET="james-odoherty.com" | |
set -e | |
bundle exec middleman build | |
find ./build \( -iname '*.html' -o -iname '*.css' -o -iname '*.js' -o -iname '*.txt' \) -exec gzip -9 -n {} \; -exec mv {}.gz {} \; | |
aws s3 rm s3://$BUCKET --recursive | |
aws s3 sync build/ s3://$BUCKET/ --acl=public-read --delete --cache-control="max-age=1576800000" --exclude "*.html" --exclude "*.css" --exclude "*.js" --exclude "*.txt" |
// The hacky bit of this approach is that this module uses | |
// jQuery, but it is not referenced here. This is because I | |
// am populating it in the test via global namespace. | |
// | |
// In the browser this still works because I am adding jQuery | |
// via a Browserify transform (browserify-global-shim). | |
function someModule() { | |
} | |
modules.export = someModule; |
<!DOCTYPE html> | |
<html> | |
<body> | |
<!-- 1. The <iframe> (and video player) will replace this <div> tag. --> | |
<div id="player"></div> | |
<div>Current Time: <span id="time"></span></div> | |
<script> | |
// 2. This code loads the IFrame Player API code asynchronously. | |
var tag = document.createElement('script'); |
RestFul API를 사용하며 json을 많이 사용하게 됨에 따라 요즈음의 request의 Content-Type은 대부분이 application/json인 것이 많다.
아니면 파일 첨부를 위해 multipart/*를 사용한다. application/x-www-form-urlencoded는 form에서 default로 사용되는 것 이외에는 사실 잘 사용하지 않는 편으로 보인다.
요새 자주 사용하지 않지만, 하지만 여전히 application/x-www-form-urlencoded를 사용하는 경우가 존재한다.
Content-Type이 다름에 따라 뭐가 달라지겠느냐 하겠지만 다른 점이 분명히 있다.
function getData() { | |
var deferred = $.Deferred(); | |
$.ajax({ | |
'url': 'http://google.com', | |
'success': function(data) { | |
deferred.resolve('yay'); | |
}, | |
'error': function(error) { | |
deferred.reject('boo'); |