Skip to content

Instantly share code, notes, and snippets.

View zulfajuniadi's full-sized avatar

Zulfa Juniadi zulfajuniadi

View GitHub Profile
@zulfajuniadi
zulfajuniadi / test
Created November 24, 2012 05:47
Test
Testing github gists
@zulfajuniadi
zulfajuniadi / helpers.js
Created November 26, 2012 15:55
meteor common helpers
function eventActions(arg){
var action = [
'created a new task.',
'started a task.',
'finished a task.',
'checked a task.',
'commented on a task.'
];
if(_.isNumber(arg)){
return action[arg];
function makeId()
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < 5; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
@zulfajuniadi
zulfajuniadi / jquery.connect.js
Last active November 22, 2017 16:44
jQuery Connect JS - A small script to make connections between two elements.
// jQuery Connect v0.0.1
// (c) Zulfa Juniadi <http://zulfait.blogspot.com/>
// Usage : var connection = $.connect('#elem1', '#elem2', {options});
// Documentation : http://zulfait.blogspot.com/2013/07/jquery-connect.html
// Source : https://gist.github.com/zulfajuniadi/5928559#file-jquery-connect-js
// Requires : jQuery v1.9+ (Older versions may work, but not tested)
// Suggests : jQuery UI (It works with draggable elements!)
// MIT License
;(function($) {
@zulfajuniadi
zulfajuniadi / gist:5935950
Last active December 19, 2015 09:49
PHP Compile Handlebars Templates on Modification
<?php
class HandlebarsCompile
{
private static $tmpFile = 'cache/handlebarscompile.txt';
private static $templateFiles = 'views/templates/*';
private static $outputFile = 'assets/js/templates.js';
public static function Check() {
$tmpFile = self::$tmpFile;
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
var form = $(this);
$.each(a, function() {
var input = form.find('[name="'+this.name+'"]');
var multiple = $(input).attr('multiple');
if (multiple) {
o[this.name] = o[this.name] || [];
Deps.autorun(function(){
Template.modal.html = function(){
return Template['modal' + Session.get('modalName')]();
}
})
showModal = function(templateName) {
Session.set('modalName', templateName);
setTimeout(function(){
!function(a,b,c,d){function e(d){if(!c[d]){if(!b[d]){if(a)return a(d);throw new Error("Cannot find module '"+d+"'")}var f=c[d]={exports:{}};b[d][0](function(a){var c=b[d][1][a];return e(c?c:a)},f,f.exports)}return c[d].exports}for(var f=0;f<d.length;f++)e(d[f]);return e}("undefined"!=typeof require&&require,{1:[function(a,b){var d,e,f,g,h,i=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};h=a("../lib/lodash.js"),g=a("./helpers"),e=a("./context"),f={},f.render=function(a,b,c,d){var i,j;return null==b&&(b=[]),null==c&&(c={}),null==d&&(d={}),i=d.debug&&console?g.consoleLogger:g.nullLogger,i("Transparency.render:",a,b,c,d),a?(h.isArray(b)||(b=[b]),a=(j=g.data(a)).context||(j.context=new e(a,f)),a.render(b,c,d).el):void 0},f.matcher=function(a,b){return a.el.id===b||i.call(a.classNames,b)>=0||a.el.name===b||a.el.getAttribute("data-bind")===b},f.clone=function(a){return d(a).clone()[0]},f.jQueryPlugin=g.chainable(function(a,b,c){var d,e,g,h;for(h=[],e=0,g=this.l
@zulfajuniadi
zulfajuniadi / API Example: \JomWeb\BakulPasar
Last active December 28, 2015 07:19
Auto crud generator proposed for GC Replacement. Request for Comments and Volunteers.
<?php
/* Base Controller Example */
class BaseController
{
protected function _format_name($column, $row)
{
return strtoupper($column);
}
@zulfajuniadi
zulfajuniadi / gist:7672430
Last active September 11, 2016 07:26
Add Callback to bootstrap popover
/* override bootstrap popover to include callback */
var showPopover = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function() {
showPopover.call(this);
if (this.options.showCallback) {
this.options.showCallback.call(this);
}
}