Skip to content

Instantly share code, notes, and snippets.

@skylying
skylying / gist:9359493
Created March 5, 2014 01:31
bootstrap-Datetimepicker
<div id="datetimepicker1" class="input-append date">
<input class="form-control input-sm custom-input-sm" id="seedoc" data-format="dd/MM/yyyy" type="text" />
<span class="add-on">
<i data-time-icon="glyphicon glyphicon-calendar" data-date-icon="glyphicon glyphicon-calendar"></i>
</span>
</div>
@skylying
skylying / gist:9365324
Created March 5, 2014 11:13
三欄生日
<tr>
<td><label for="birthday">生日</label></td>
<td>
<input class="form-control input-sm custom-input-sm" id="birthday" type="text" placeholder="西元年份" />
<select class="form-control input-sm custom-input-sm" id="birthday">
<option value="">月份</option>
{% for i in 0..11 %}
<option value="">{{ i + 1 }}月</option>
{% endfor %}
</select>
@skylying
skylying / datetimepicker.js
Last active August 29, 2015 14:03
datetimepicker 的問題
(function ($) {
var smartPhone = window.orientation != undefined;
var DateTimePicker = function (element, options) {
this.id = dpgId++;
this.init(element, options)
};
var dateToDate = function (dt) {
if (typeof dt === "string") {
return new Date(dt)
}
@skylying
skylying / rAF.js
Last active August 29, 2015 14:18 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@skylying
skylying / ddr.ino
Created August 24, 2015 13:45
Arduino DDR sharing
/**
* Drum Drum Revolution
* Author Tim Lin for Arduino sharing @ Trend micro
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
// LED variables
@skylying
skylying / Q2.js
Created October 27, 2015 08:01
Validation
function validate(password) {
var length = password.length;
var invalidMessage = '';
var result = {
"isValid": true,
"message": ''
}
var rule = '';
if (length < 8) {
invalidMessage = 'You have to provide at least 8 characters'
@skylying
skylying / Q1.js
Last active October 27, 2015 08:58
Q1 (in javascript)
var raw = '"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH","JENNIFER","MARIA","SUSAN","MARGARET","DOROTHY","LISA","NANCY","KAREN","BETTY","HELEN","SANDRA","DONNA","CAROL","RUTH","SHARON","MICHELLE","LAURA","SARAH","KIMBERLY","DEBORAH","JESSICA","SHIRLEY","CYNTHIA","ANGELA","MELISSA","BRENDA","AMY","ANNA","REBECCA","VIRGINIA","KATHLEEN","PAMELA","MARTHA","DEBRA","AMANDA","STEPHANIE","CAROLYN","CHRISTINE","MARIE","JANET","CATHERINE","FRANCES","ANN","JOYCE","DIANE","ALICE","JULIE","HEATHER","TERESA","DORIS","GLORIA","EVELYN","JEAN","CHERYL","MILDRED","KATHERINE","JOAN","ASHLEY","JUDITH","ROSE","JANICE","KELLY","NICOLE","JUDY","CHRISTINA","KATHY","THERESA","BEVERLY","DENISE","TAMMY","IRENE","JANE","LORI","RACHEL","MARILYN","ANDREA","KATHRYN","LOUISE","SARA","ANNE","JACQUELINE","WANDA","BONNIE","JULIA","RUBY","LOIS","TINA","PHYLLIS","NORMA","PAULA","DIANA","ANNIE","LILLIAN","EMILY","ROBIN","PEGGY","CRYSTAL","GLADYS","RITA","DAWN","CONNIE","FLORENCE","TRACY","EDNA","TIFFANY","CARMEN","ROSA","CINDY","GRACE","WENDY",
@skylying
skylying / Q3.js
Created October 28, 2015 10:26
Q3
var rule = /\(([^)(]+)\)/;
var map = {
'*': 1,
'/': 1,
'+': 0,
'-': 0
}
function getHighLow(str) {
@skylying
skylying / html_injection.js
Created November 10, 2015 12:23
HTML Injection work around
function encodePasswordAsHtmlEntities(value) {
var encodedStr = value.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
return '&#'+i.charCodeAt(0)+';';
});
return encodedStr.replace(/"/gim, '&quot;');;
//$('#output').html(encodedStr.replace(/&/gim, '&amp;'));
}
@skylying
skylying / stopPropagation.html
Created November 15, 2015 11:06
stopPropagation
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xHTML1/DTD/xHTML1-transitional.dtd">
<HTML XMLns="http://www.w3.org/1999/xHTML" lang="gb2312">
<head>
<title> 阻止JS事件冒泡传递(cancelBubble 、stopPropagation)</title>
<meta name="keywords" content="JS,事件冒泡,cancelBubble,stopPropagation" />
<script>
function doSomething (obj,evt) {
alert(obj.id);
var e=(evt)?evt:window.event;
if (window.event) {