Skip to content

Instantly share code, notes, and snippets.

View arifsetiawan's full-sized avatar

arif setiawan arifsetiawan

View GitHub Profile
@arifsetiawan
arifsetiawan / uploadsimple.js
Created November 28, 2011 17:27
upload form
var express = require('express');
// express setup
var app = express.createServer();
app.use(express.bodyParser());
app.get('/', function(req, res){
res.writeHead(200, {'content-type': 'text/html'});
res.end(
'<form action="/upload" enctype="multipart/form-data" method="post">'+
@arifsetiawan
arifsetiawan / snaplist
Created June 18, 2012 09:52
horizontal page list view
ListView {
id: contentView
anchors.fill: parent
highlightRangeMode: ListView.StrictlyEnforceRange
orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem
clip: true
model: internalContentModel
BaseWidget::BaseWidget(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout * l = new QVBoxLayout(this);
l->setContentsMargins(0, 0, 0, 0);
qmlRegisterType<SPageStatus>("AegisLabs", 1, 0, "PageStatus");
QmlApplicationViewer * viewer = new QmlApplicationViewer(this);
function format(str){
var args = arguments;
return str.replace(/{(\d+)}/g, function(match, number){
return args[parseInt(number) + 1];
});
}
@arifsetiawan
arifsetiawan / search.js
Created December 19, 2012 07:56
riak-js search
db.saveBucket('textr', {search: true})
db.save('textr', 'text-00001', 'Riak Search is a distributed, full-text search engine that is built on Riak Core and included as part of Riak open source. Search provides the most advanced query capability next to MapReduce, but is far more concise; easier to use, and in most cases puts far less load on the cluster.')
db.save('textr', 'text-00002', 'Search indexes Riak KV objects as theyre written using a precommit hook. Based on the object’s mime type and the Search schema you’ve set for its bucket, the hook will automatically extract and analyze your data and build indexes from it. The Riak Client API is used to invoke Search queries that return a list of bucket/key pairs matching the query. Currently the PHP, Python, Ruby, and Erlang client libraries support integration with Riak Search.')
db.save('textr', 'text-00003', 'When collecting, parsing, and storing data like user bios, blog posts, journal articles, etc. to facilitate fast and accurate information retrieval i
@arifsetiawan
arifsetiawan / search-result
Created December 19, 2012 09:12
riak-js search result
// search 'indexes'
{ "docs" : [ { "fields" : { "value" : "Search indexes Riak KV objects as theyre written using a precommit hook. Based on the object?s mime type and the Search schema you?ve set for its bucket, the hook will automatically extract and analyze your data and build indexes from it. The Riak Client API is used to invoke Search queries that return a list of bucket/key pairs matching the query. Currently the PHP, Python, Ruby, and Erlang client libraries support integration with Riak Search." },
"id" : "text-00002",
"index" : "textr",
"props" : { }
},
{ "fields" : { "value" : "When Search is enabled on your Riak cluster, another set of vnodes, equal to the number of KV vnodes, will be started which will be used to handle Search requests. Search is enabled on a per-bucket basis by setting the search property to true. If search is enabled for a bucket, indexes are generated on all objects as they are written to it using the pre-commit hook. Index data stored on S
@arifsetiawan
arifsetiawan / result-origin
Last active December 17, 2015 15:39
QHttpMultipart result
{ currentFolderId: 'root',
documentName: 'somename',
tags: 'a,b',
document: '�PNG\r\n\u001a\n\u0000\u0000\u0000\rIHDR\u0000\u0000\u0004�\u0000\u0000\u0006r\b\u0002\u0000\u0000\u0000ɦvY\u0000\u0000\u0000\tpHYs\u0000\u0000\u0017\u0011\u0000\u0000\u0017\u0011\u0001�&�?\u0000\u0000\u0000\u001dtEXtSoftware\u0000GPL Ghostscript 8.61\u001a$Yu\u0000\u0000 \u0000IDATx���wX\u0014�\u001b\u0007�w��E@@E\u0004���ޱ�\u001a��آF1��\u0016��w��\u0014\u00135���؍���Ŏ4Q\u0014\u0015���v����y�\u001dǁh�|?ϓ\'������!����0!\u0004\u0001\u0000\u0000\u0000\u0000\u0000\u0000�;ҿ�\u0000\u0000\u0000\u0000\u0000\...
}
@arifsetiawan
arifsetiawan / example-express.cpp
Last active December 17, 2015 15:39
QMultipart example, express compliant
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHttpPart textPart;
textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\""));
textPart.setBody("my text");
QHttpPart imagePart;
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\"; filename=\"image.png\""));
QFile *file = new QFile("image.png");
@arifsetiawan
arifsetiawan / upload.js
Created May 23, 2013 08:54
Express upload
app.post('/upload', function(req, res) {
console.log(req.body);
console.log(req.files);
res.send('something');
})
@arifsetiawan
arifsetiawan / result
Last active December 17, 2015 15:39
QHttpMultipart result
// with filename
{ currentFolderId: 'root',
documentName: 'somename',
tags: 'a,b' }
{ document:
{ domain: null,
_events: {},
_maxListeners: 10,
size: 179769,
path: '/Users/arifsetiawan/Projects/Cymbidium/upload/temp/62a2d0f9b5ce9174ebe8e278d36bda3e.png',