Skip to content

Instantly share code, notes, and snippets.

View erinlin's full-sized avatar

YuShan Lin (Erin) erinlin

View GitHub Profile
@erinlin
erinlin / gist:4002108
Created November 2, 2012 15:42
Corona: storyboard template
----------------------------------------------------------------------------------
--
-- scene name
--
----------------------------------------------------------------------------------
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
-------------------------------------------------------------------------
@erinlin
erinlin / Solarized-erin (Dark).tmTheme
Created November 2, 2012 15:57
Color scheme for Sublime Text 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Solarized-erin (dark)</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@erinlin
erinlin / group.lua
Created November 2, 2012 18:44
Corona: extends Group example
-------------------------------------------------
--
-- extends Group example
--
-------------------------------------------------
local group = {}
local group_mt = { __index = group } -- metatable
-------------------------------------------------
@erinlin
erinlin / slideEvent.lua
Created November 15, 2012 05:35
Corona: slide event example
-------------------------------------
-- group slide event
-- Erin Lin
-------------------------------------
local isActive = true
local slide = function(event)
if not isActive then return end
local W = display.contentWidth * .5
local dis = 40
local pos = (event.xStart < W and "L") or "R"
@erinlin
erinlin / gist:4368572
Created December 24, 2012 09:34
Titanium-SSL httpClient
var login = function(args){
xhr.open( 'GET', args.url );
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type', 'application/json');
//TODO
var txt = Ti.Utils.base64encode( args.username + ':' + args.password).getText();
xhr.setRequestHeader('Authorization','Basic '+ txt);
var content = '';
var boundary = '---------------------------170062046428149';
content += '--'+ boundary + '\r\n';
content += 'Content-Disposition: form-data; name="uploadToken"\r\n';
content += '\r\n';
content += upload_token + '\r\n';
content += '--'+ boundary + '\r\n';
content += 'Content-Disposition: form-data; name="destFolderPath"\r\n';
content += '\r\n';
@erinlin
erinlin / onEdit
Created June 19, 2013 14:24
google apps script - Serve Google Spreadsheet as JSONP
//http://me.dt.in.th/page/SpreadsheetToJSONP
function onEdit(e) {
var value = SpreadsheetApp.getActiveSpreadsheet().getSheets()
.filter(function(sheet) { return sheet.getName() != "JS" })
.map(function(sheet) {
return { name: sheet.getName(),
values: sheet.getDataRange().getValues() };
});
SpreadsheetApp.getActiveSpreadsheet()
.getSheetByName("JS").getRange("B1").setValue(JSON.stringify(value));
@erinlin
erinlin / statemachine.lua
Last active March 14, 2016 06:39
coronaSDK-coroutine-statemachine
--[[
statemachine.lua
Copyright (c) 2013 Erin Lin
erinylin.blogspot.com
Licensed under the MIT license.
Usage:
local sm = require("statemachine")
local process = sm.new(function(self, time)
@erinlin
erinlin / statemachine-example01
Last active December 19, 2015 07:09
statemachine-example01
local sm = require("statemachine")
local process = sm.new(function(self, time)
self:sleep(100)
print("hello")
self:sleep(100)
print("hehe...")
self:sleep(100)
print("end")
end)
@erinlin
erinlin / statemachine-example02
Last active December 19, 2015 07:09
statemachine-example02
local sm = require("statemachine")
local process = sm.new(function(self, time)
local txt = display.newText( "Press Me", display.contentCenterX, display.contentCenterY, native.systemFont, 32)
txt:addEventListener("touch", function(evt)
self:continue()
end)
self:waiting()
txt.text = "Hello!"
end)