Skip to content

Instantly share code, notes, and snippets.

View wushan's full-sized avatar

Tony Chiang wushan

View GitHub Profile
# HTTP - redirect all requests to HTTPS:
server {
listen 80;
server_name notable.wushan.io;
return 301 https://$host$request_uri;
}
# HTTPS - proxy requests on to local Node.js app:
server {
listen 443;
@wushan
wushan / print stars
Created February 22, 2017 15:23
Javascript 考題 - 印出星星
var limit = 10
var row = []
for (var i = 0; i < limit; i++) {
row.length = 0
//Space
for (var space = 0; space < (limit - i); space++) {
row.push(' ')
}
for (var stars = 0; stars < i; stars++) {
row.push('*')
@wushan
wushan / fit.js
Created February 21, 2017 07:07
根據外框比例計算 scale 程度
var canvas = window.canvas
// Scale Canvas to fit viewport
// var container = document.getElementById('artboard')
var container = document.querySelector('.canvas-wrapper')
var paintArea = document.getElementById('canvas')
// canvas.wrapperEl.style.transform = "scale(.8)"
;(function () {
// console.log(canvas)
// var aspectRatio = canvas.width / canvas.height
// Ratio = Canvas 寬(實際px) 與 artboard 寬的比值
@wushan
wushan / default.conf
Created November 19, 2016 14:44
NGiNX Configuration for Vue-Router in HTML5 Mode
server {
listen 80 default_server;
listen [::]:80 default_server;
root /your/root/path;
index index.html;
server_name you.server.com;
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="GET, PUT, POST, DELETE, HEAD, OPTIONS" />
<add name="Access-Control-Allow-Credentials" value="true"/>
<add name="Access-Control-Allow-Headers" value="X-Requested-With, origin, content-type, accept" />
</customHeaders>
@wushan
wushan / Rewrite Ruls for Vue.js SPA on IIS
Last active September 4, 2019 06:00
Rewrite Ruls for Vue.js SPA on IIS
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="backend" stopProcessing="true">
<match url="^(backend)(.*)$" />
<action type="None" />
</rule>
<rule name="Vuejs rules" stopProcessing="true">
<match url="(.*)" />
@wushan
wushan / _form.scss
Created June 8, 2016 07:19
Form element styles template for SCSS.
//ControlGroup
.controlgroup {
margin-bottom: .5em;
@extend .clear;
label {
display: block;
float: left;
line-height: $input-height;
width: $label-size;
}
@wushan
wushan / jquery.getbgimage.js
Created December 4, 2015 07:09 — forked from schmidsi/jquery.getbgimage.js
getBgImage: Simple Jquery Plugin to get the dimensions or other attributes from a css background-image
// Inspired by http://stackoverflow.com/questions/5106243/how-do-i-get-background-image-size-in-jquery, a simple jquery plugin who does the task
$.fn.getBgImage = function(callback) {
var height = 0;
var path = $(this).css('background-image').replace('url', '').replace('(', '').replace(')', '').replace('"', '').replace('"', '');
var tempImg = $('<img />');
tempImg.hide(); //hide image
tempImg.bind('load', callback);
$('body').append(tempImg); // add to DOM before </body>
tempImg.attr('src', path);