Skip to content

Instantly share code, notes, and snippets.

View andy0130tw's full-sized avatar
🍌
why no 🍆

Andy Pan andy0130tw

🍌
why no 🍆
View GitHub Profile
@andy0130tw
andy0130tw / CookieObject.js
Last active August 29, 2015 13:56
CookieObject
//CookieObject v1 by Andy Pan
// You can use the small piece of code to r/w
// > Cookies, not losing its structure of an object.
// > All complex contents will be automatically
// > en(de)code, but simple contents won't
// > so that you can access them without pain.
// Assume JSON.parse() and JSON.stringify().
// Use it with jquery.cookie by carhartl:
@andy0130tw
andy0130tw / ui.html
Created June 1, 2014 16:20
HTML Drag'n'Drop Quick Example
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
function noop(e){
//e.stopPropagation();//取消drag預設動作
#define MAX 1000000
#define MULTI 1000
#include<cstdio>
#include<iostream>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> point;
int n,f;
ll sum[MAX+1];
@andy0130tw
andy0130tw / crsc2014.gbapi.php
Last active August 29, 2015 14:03
CRSC2014 Guestbook Backend
<?php
//Comment for easier reading
// Override default SQLite constructor to
// open the file at first.
class MyDB extends SQLite3{
function __construct(){
$this->open('dbstore/gb.sqlite');
}
}
@andy0130tw
andy0130tw / gbtest.html
Last active August 29, 2015 14:03
The frontend of CRSC2014 guestbook for Yu-Ren Pan! (For debugging only)
<!DOCTYPE html>
<html>
<head>
<title>Guestbook Test</title>
<script src="res/js/jquery-1.10.2.min.js"></script>
<script>
$(function(){
$("#gb_form").submit(function(){
$("#gb_submit").attr("disabled","disabled");
sendForm();
@andy0130tw
andy0130tw / bs.dropdown.slide.js
Last active August 29, 2015 14:04
Bootstrap (v3.2.0) Dropdown Slide Effect using jQuery. The first revision is the original one and it's only for comparing code.
/* ========================================================================
* Bootstrap: dropdown.js v3.2.0
* http://getbootstrap.com/javascript/#dropdowns
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
@andy0130tw
andy0130tw / backbone.localstorage.js
Created July 23, 2014 08:17
Backbone LocalStorage Model
var StorageBase=Backbone.Model.extend({
constructor: function(){
Backbone.Model.apply(this,arguments);
//check if the storage can be used
this.supportLocalStorage=!!localStorage;
this.prefix="lm.v2.";
var self=this;
var addPrefix=function(k){
@andy0130tw
andy0130tw / sidebar.js
Last active August 29, 2015 14:05
Facebook sidebar recreation.(I simply don't know its name...) Using RequireJS and jQuery, but you can easily grab useful parts!
/**
* @file UI.sidebar
* Facebook sidebar recreation
*/
define(["jquery"],function($){
//from http://stackoverflow.com/a/17961266/2281355
var isAndroid = navigator.userAgent.indexOf('Android') >= 0;
var webkitVer = parseInt((/WebKit\/([0-9]+)/.exec(navigator.appVersion) || 0)[1],10) || void 0;
@andy0130tw
andy0130tw / gist.js
Created October 7, 2014 13:15
JavaScript Function Isolation
var root=this;
function getIsolationScript(){
//getting key of global attrs
var buffer="";
for(var x in root)buffer+="try{var "+x+"=void 0}catch(e){}";
//the name of the top-level variable
// should be manually set.
buffer+="var window={}";
return buffer;
@andy0130tw
andy0130tw / gram-schmidt.c
Last active August 29, 2015 14:10
Gram-Schmidt Method
/**
* Written by Andy Pan
* Language: C
* Algorithm: Gram-Schmidt Method
* Creation Date: 2014/12/6
* Last Modified: 2014/12/7
**/
#include<stdio.h>
#include<math.h>