This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Memory | |
# sizes are guessed, I was too lazy to look | |
# them up and then they are also platform | |
# dependent | |
REF_SIZE = 4 # ? | |
OBJ_OVERHEAD = 4 # ? | |
FIXNUM_SIZE = 4 # ? | |
# informational output from analysis | |
MemoryInfo = Struct.new :roots, :objects, :bytes, :loops |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<!--[if IE 6]> | |
<html id="ie6" dir="ltr" lang="zh-TW"> | |
<![endif]--> | |
<!--[if IE 7]> | |
<html id="ie7" dir="ltr" lang="zh-TW"> | |
<![endif]--> | |
<!--[if IE 8]> | |
<html id="ie8" dir="ltr" lang="zh-TW"> | |
<![endif]--> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(w){ | |
// doi.viewController(config) | |
// config.viewDelegate | |
var homeController = doi.ViewController(function(){ | |
// doi.view.TableView(config) | |
// config.tableViewDelegate | |
// config.tableViewDatasource | |
var tableView = doi.view.TableView({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task :my_task => :environment do | |
File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid } if ENV['PIDFILE'] | |
Model.perform_task! | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Product implements Cachable{ | |
public Product(String type, String key){ | |
mType = type; | |
mKey = key; | |
} | |
public String cacheId() { | |
return mKey; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Initialization | |
cacheStore = new CacheStore(getContext()) { | |
@Override | |
public String storeName() { | |
return "ProductsStore"; | |
} | |
}; | |
// store value | |
cacheStore.put(TYPE, KEY, VALUE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new APIRequest( new APIClient(HomeActivity.this), APP_SERVER+"/download_pdf", APIRequest.GET) | |
.withDefaultParams(defaultParamsHashMap()) | |
.addParam("format", "json") | |
.addParam("id", pdfId) | |
.addHeaderParam("Referer", APP_REFERER); | |
.startDownload(CACHE_ID, DOWNLOAD_FOLDER, new APIDataRequestHandler(){ | |
@Override | |
public void before(){ | |
showProgressBar(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new APIRequest( new APIClient(HomeActivity.this), APP_SERVER+"/latest_news", APIRequest.GET) | |
.withDefaultParams(defaultParamsHashMap()) | |
.addParam("format", "json") | |
.addParam("limit", 10) | |
.addHeaderParam("Referer", APP_REFERER); | |
.startWithCache(CacheStategy.RESPONSE_VERSION, CACHE_GROUP_KEY, CACHE_KEY,new JSONRequestHandler(){ | |
@Override | |
public String getVersion(HttpEntity response){ | |
return versionFromResponse(response); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new APIRequest( new APIClient(HomeActivity.this), APP_SERVER+"/search", APIRequest.GET) | |
.withDefaultParams(defaultParamsHashMap()) | |
.addParam("format", "json") | |
.addParam("q", searchTerm) | |
.addHeaderParam("Referer", APP_REFERER); | |
.start(new JSONRequestHandler(){ | |
@Override | |
public void before(){ | |
showProgressBar(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateTableS3Uploads < ActiveRecord::Migration | |
def up | |
create_table :s3_uploads do |t| | |
t. :url | |
t.timestamps | |
end | |
end | |
def down | |
drop_table :s3_uploads | |
end |