Skip to content

Instantly share code, notes, and snippets.

@sivagao
sivagao / rt
Created March 22, 2013 03:19
jquery.feedback.js
(function() {
window.Feedback = (function(){
var _initialized;
function Feedback(){}
_initialized = false;
Feedback.init = function(options){
}
Feedback.prototype.default_options = {
@sivagao
sivagao / index.html
Created March 21, 2013 08:43
A CodePen by siva Gao.
<!doctype html>
<html>
<head>
<title>Rich Text Editor</title>
<script type="text/javascript">
var oDoc, sDefTxt;
function initDoc() {
oDoc = document.getElementById("textBox");
sDefTxt = oDoc.innerHTML;
@sivagao
sivagao / one_line_html.html
Created March 2, 2013 15:21
one line with data:text/html,<html></html>
data:text/html,<html lang="en"><head><style> html,body { height: 100% } #note { width: 100%; height: 100% } </style> <script> var note, html, timeout; window.addEventListener('load', function() { note = document.getElementById('note'); html = document.getElementsByTagName('html')[0]; html.addEventListener('keyup', function(ev) { if (timeout) clearTimeout(timeout); timeout = setTimeout(saveNote, 100); }); restoreNote(); note.focus(); }); function saveNote() { localStorage.note = note.innerText; timeout = null; } function restoreNote() { note.innerText = localStorage.note || ''; } </script> </head><body><h1>Notepad (type below, notes persist)</h1> <p id="note" contenteditable=""></p> </body></html>
#client端代码
#点击添加的时候
@socket.emit 'newItem', newItem if @socket
#点击加入的时候
joinList: ->
@socket = io.connect("http://localhost:3000")
@socket.on 'connect', =>
@socket.emit 'joinList', @$joinListName.val()
@socket.on 'syncItems', (items) =>
@sivagao
sivagao / py_downloader_list_urls.py
Last active December 14, 2015 08:59
py_downloader_list_urls.py. download a list of urls to a location if it does not exist.
import os
import urllib
def ensure_dir(f):
d = os.path.dirname(f)
if not os.path.exists(d):
os.makedirs(d)
DOWNLOADS_DIR = 'F:/1Codes/0Web/bootstrap-awesome' #change window splash
@sivagao
sivagao / listactions.js
Created February 27, 2013 18:56
listactions.(to learn how to define a ui component's plugin) easy way to do operations on many items selected in a list in a similar manner to how the Mail app on iOS works.
/**
* @class Ext.ux.plugin.ListActions
* @author Weston Nielson <wnielson@github>
*
* This plugin adds the ability to select multiple items in a list and then
* perform certain actions on the selected items.
*
* @example miniphone preview
* Ext.create('Ext.List', {
* fullscreen: true,
@sivagao
sivagao / app.js
Created February 27, 2013 18:50
easy way to do operations on many items selected in a list in a similar manner to how the Mail app on iOS works.
Ext.application({
name: 'MyApp',
requires: [
'Ext.MessageBox'
],
views: ['Main'],
launch: function() {
// Destroy the #appLoadingIndicator element
@sivagao
sivagao / views_home.js
Created February 27, 2013 18:32
Using sencha touch 1.x to create a springboard. vertical padding using {xtype: 'panel','height':'20'}; horizon padding using {xtype: spacer}
app.views.Home = Ext.extend(Ext.Panel, {
title: 'Home',
iconCls: 'home',
dockedItems: [
{
dock: 'top',
xtype: 'toolbar',
title: '<img class="logo" src="app/images/logo.png" />',
}
@sivagao
sivagao / Feeds.js
Created February 25, 2013 18:00
feed reader sencha touch js datalist
/**
* @author Andrea Cammarata (@AndreaCammarata)
* @class RSS.controller.Feeds
* @extends Ext.app.Controller
* Core controllers which handles all the
* Feeds and News routes and views.
* This class could be considered as the real application Engine.
*/
Ext.define('RSS.controller.Feeds', {
@sivagao
sivagao / example.js
Created February 22, 2013 12:51
Backbone: to indicate Backbone fetch progress , to override a method @ Collection, Model . //patching the fetch method on Collection.prototype to emit a fetch event.
Repos.Views.List = Backbone.View.extend({
initialize: function() {
// Display a loading indication whenever the Collection is fetching.
this.collection.on("fetch", function() {
this.html("<img src='/assets/img/spinner.gif'>");
}, this);
// Automatically re-render whenever the Collection is populated.
this.collection.on("reset", this.render, this);
}