Skip to content

Instantly share code, notes, and snippets.

View goldalworming's full-sized avatar

arief nur andono goldalworming

View GitHub Profile
@goldalworming
goldalworming / async loop
Last active August 29, 2015 14:02
loop in node.js should use recursive or async (node-async) but if you use total.js framework, async feature already exist and this is the comparation of using non-node.js programmer's loop to better approach
rc.zrange(['cust', '0', '-1'], function(err, data) {
if (err) {
rc.quit();
self.throw500(err);
return;
}
var length = data.length;
ogr2ogr ProvinsiSimply.shp Provinsi.shp -simplify 0.001
ogr2ogr -f geoJSON provinsisimplyoutput.json ProvinsiSimply.shp
@goldalworming
goldalworming / getangularjspost
Created June 25, 2014 06:40
get angular post in codeigniter / php
public function post(){
$arraydata = json_decode(file_get_contents('php://input'));
}
@goldalworming
goldalworming / inserttooracle.php
Created June 26, 2014 04:17
insert date to oracle php
$objarray['tgl'] = date("Y-m-d",strtotime($arraydata->ACT_TGLENTRY));
$sql="insert into mart_dws_activity (ACT_GPART,ACT_BU_NAME,ACT_ID_ACT,ACT_JNSACT,ACT_PICTELKOM,ACT_TGLENTRY,ACT_RESULT,ACT_TLPRMH,ACT_PICCUST) values ('$gpart', '$bu_name', '$id', '$jns', '$pictelkom', to_date('$tgl','yyyy-mm-dd'), '$result', '$telprmh', '$piccust')";
@goldalworming
goldalworming / detectmobile.js
Created July 2, 2014 16:07
detect mobile in total.js
var regMobile = /iPad|iPhone|iPod|Android/g;
if (regMobile.test(controller.req.headers['user-agent']))
console.log('Is mobile device');
@goldalworming
goldalworming / totaljs-glupsauth.js
Last active August 29, 2015 14:03
straightforward glus auth without any library
framework.route('/login/gplus/', process_gplus,{timeout: 60000});
function process_gplus() {
var self = this;
var auth = self.module('authorization');
objgplus = {
client_id:'[yourclientid]',
client_secret:'[yourclientsecret]'
};
var timeoutPromise;
var delayInMs = 2000;
$scope.$watch("query", function () {
$timeout.cancel(timeoutPromise); //does nothing, if timeout alrdy done
timeoutPromise = $timeout(function(){ //Set timeout
$scope.loading = true;
returnFactory.query($scope.query).then(function (returns) {
$scope.returns = returns;
$scope.loading = false;
});
@goldalworming
goldalworming / stringtojscode
Created August 8, 2014 03:55
javascript code from string
var a = [1, 2, 3, 45]
var fn = new Function('vars', 'if (vars.length==5){return "benar";}else{return "salah"}');
fn(a);
@goldalworming
goldalworming / nodejsredis.js
Created August 13, 2014 02:45
comparing node-redis
var http = require("http"), server,
redis_client = require("redis").createClient();
server = http.createServer(function (request, response) {
response.writeHead(200, {
"Content-Type": "text/plain"
});
redis_client.get('id:'+'value', function(err, idclient) {
@goldalworming
goldalworming / complete_mysql_multiplequery.js
Last active August 29, 2015 14:05
query yang parameternya dari text
exports.install = function(framework) {
framework.route('/querymysql/', multiplequery,['post','json']);
};
function multiplequery(){
var self = this;
var auth = self.module('authorization');
self.post.newkode = function(){
return utils.GUID([9]);
}