'전체 글'에 해당되는 글 93건

git reset --hard HEAD^

git push -f origin develop

'분류없음' 카테고리의 다른 글

[cpp] std::move는 단지 캐스팅일 뿐이라고?  (0) 2017.02.08
Same string but different length  (0) 2016.10.28
JIT vs Interpreter  (0) 2016.10.25
[encoding] javascript write to csv  (0) 2015.04.11
APNS python failure and feedback  (0) 2015.04.06
블로그 이미지

시간을 거스르는자

,

see: https://stackoverflow.com/questions/21177078/javascript-download-csv-as-file/23786965#23786965

key point is \uFEFF


version 1.

var encodedUri = 'data:text/csv;charset=UTF-8,\uFEFF'+encodeURI(comma_data);

var link = document.createElement("a");

link.setAttribute("href", encodedUri);

var name = 'gem_use.csv';

if (key == 'container_get') {

    name = 'gem_get.csv';

}

link.setAttribute("download", name);

link.click();


version 2. (<table></table> to excel file)

usage: tablesToOneExcelSheet(tables, sheets, today+filename, 'Excel');(tables => table element id list, sheet => name list of each table)

* Should use Blob to enable large file size.

var tablesToOneExcelSheet = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, tmplWorkbookXML = '<'+'?xml version="1.0"?><'+'?mso-application progid="Excel.Sheet"?><Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">'
+ '<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"><Author>NM</Author><Created>{created}</Created></DocumentProperties>'
+ '<Styles>'
+ '<Style ss:ID="Currency"><NumberFormat ss:Format="Currency"></NumberFormat></Style>'
+ '<Style ss:ID="Date"><NumberFormat ss:Format="Medium Date"></NumberFormat></Style>'
+ '</Styles>'
+ '{worksheets}</Workbook>'
, tmplWorksheetXML = '<Worksheet ss:Name="{nameWS}"><Table>{rows}</Table></Worksheet>'
, tmplCellXML = '<Cell{attributeStyleID}{attributeFormula}><Data ss:Type="{nameType}">{data}</Data></Cell>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(tables, wsnames, wbname, appname) {
var ctx = "";
var workbookXML = "";
var worksheetsXML = "";
var rowsXML = "";

for (var i = 0; i < tables.length; i++) {
if (!tables[i].nodeType) tables[i] = document.getElementById(tables[i]);
for (var j = 0; j < tables[i].rows.length; j++) {
if(i>0 && j==0) {
continue;
}
rowsXML += '<Row>';
for (var k = 0; k < tables[i].rows[j].cells.length; k++) {
var dataType = tables[i].rows[j].cells[k].getAttribute("data-type");
var dataStyle = tables[i].rows[j].cells[k].getAttribute("data-style");
var dataValue = tables[i].rows[j].cells[k].getAttribute("data-value");
dataValue = (dataValue)?dataValue:tables[i].rows[j].cells[k].innerHTML;
var dataFormula = tables[i].rows[j].cells[k].getAttribute("data-formula");
dataFormula = (dataFormula)?dataFormula:(appname=='Calc' && dataType=='DateTime')?dataValue:null;
ctx = { attributeStyleID: (dataStyle=='Currency' || dataStyle=='Date')?' ss:StyleID="'+dataStyle+'"':''
, nameType: (dataType=='Number' || dataType=='DateTime' || dataType=='Boolean' || dataType=='Error')?dataType:'String'
, data: (dataFormula)?'':dataValue
, attributeFormula: (dataFormula)?' ss:Formula="'+dataFormula+'"':''
};
rowsXML += format(tmplCellXML, ctx);
}
rowsXML += '</Row>';
}
}

ctx = {rows: rowsXML, nameWS: "Data"};
worksheetsXML += format(tmplWorksheetXML, ctx);

ctx = {created: (new Date()).getTime(), worksheets: worksheetsXML};
workbookXML = format(tmplWorkbookXML, ctx);
window.URL= window.URL || window.webkitURL;
var blob = new Blob([workbookXML], {type: 'application/vnd.ms-excel;base64'});
var blobUrl = window.URL.createObjectURL(blob);

var link = document.createElement("A");
// link.href = uri + base64(workbookXML);
link.href = blobUrl;
link.download = wbname || 'Workbook.xls';
link.target = '_blank';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
})();


'분류없음' 카테고리의 다른 글

[cpp] std::move는 단지 캐스팅일 뿐이라고?  (0) 2017.02.08
Same string but different length  (0) 2016.10.28
JIT vs Interpreter  (0) 2016.10.25
git pushed merge cancel  (0) 2015.04.13
APNS python failure and feedback  (0) 2015.04.06
블로그 이미지

시간을 거스르는자

,


https://pypi.python.org/pypi?%3Aaction=search&term=apns&submit=search


apns-client(0.2.1)

pushjack(0.3.0)

apns(2.0.1)

download count

(201503 1달동안)

1524

2041

4731

bulk tokens 보내기

O

O

O

invalid token handling

(invalid token 이 한 APNs connection에 섞여있을 경우)

send에 대한 return값으로 failed tokens 전달

(retry code 필요)

Exception처리로 몇번째 token이 invalid token인지 전달됨

(retry code 필요)

error handler thread에서 failed tokens retry 해줌

기타특징

async/sync send

GCM, APNS둘다 제공



  • pyapns(download count: 1664) 는 제외함: 기본적으로 푸시 보내는 방식이 별도의 APNSSever를 twisted(event-driven network engine)를 이용해서 띄워놓고 여기로 보내는 방식.
  • 참고로 android는 python-gcm 이 있는데, push jack은 토큰 하나씩 for문을 돌면서 하나씩 보내는데 비해 python-gcm은 한번에 보낸다. 그리고 에러처리는 실패한 토큰들을 모아서 다시보내기를 5번 반복하고 끝내는 방식으로 되어있다.


'python' 카테고리의 다른 글

gunicorn vs uwsgi  (0) 2017.01.20
flask async response  (0) 2017.01.04
functools.wraps에 대해  (0) 2015.04.15
Getting specific timezone timestamp from time string  (0) 2015.01.20
Shallow copy VS Deep copy  (0) 2014.08.27
블로그 이미지

시간을 거스르는자

,