Skip to content

Instantly share code, notes, and snippets.

View arifsetiawan's full-sized avatar

arif setiawan arifsetiawan

View GitHub Profile
@arifsetiawan
arifsetiawan / slim-route-middleware.php
Last active August 29, 2015 14:01
slim-route-middleware
<?php
error_reporting(E_ALL | E_STRICT);
//
// Require modules
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
require 'Slim/Log.php';
// Get Slim Extras from here https://github.com/codeguy/Slim-Extras
@arifsetiawan
arifsetiawan / git-workflow-one.md
Last active August 29, 2015 14:01
Git workflow #1

Git workflow #1

Create your working branch

Clone the repo

$ git clone https://[email protected]/someuser/great-website.git greatwebsite

A nodejs based server will archive user online-offline state and store all chat data. This will make client more light.

NOTE always set ts to current time when you push or set the data.

##Chat Apps with Firebase :

To create a chat, necessary firebase components :

  • User - Handle real time online-offline status changes of user.
@arifsetiawan
arifsetiawan / gist:10014113
Last active March 3, 2017 17:09
Firebase for chat

Update

archiving will be handled in server, so no push to offline necessary. This will make client more light.

NOTE always set ts to current time when you push or set the data.

Firebase for chat

To create a chat, necessary firebase components :

@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',
@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 / 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 / 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 / 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 / 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