Skip to content

Instantly share code, notes, and snippets.

View infacq's full-sized avatar

Muhaimin infacq

  • Seri Kembangan, Selangor Malaysia
View GitHub Profile
@infacq
infacq / 1.js
Created September 18, 2013 08:56 — forked from mxriverlynn/1.js
var data = {
type: "something",
name: "whatever",
addresses: [
{
type: "read_address",
address: "1/2/3",
value: "10"
},
{
// Collecting all unique affected app version for a given data set
var jsonStats = [
{app_versions: ['1.2','1.2.3']},
{app_versions: null},
{app_versions: ['1.2','1.3']}
];
var app_versions = _.uniq(_.flatten(_.compact(_.map(jsonStats, function(day){return day.app_versions }))));
// ["1.2", "1.2.3", "1.3"]
// Bye bye stupid for loops!
@infacq
infacq / kenali_view
Last active December 25, 2015 04:09
paparanKu = Backbone.View.extend({
events: {
"click #elemenKu": "caraKu"
},
caraKu: function(){
alert("Tidak Menyesal Belajar BackboneJS!");
},
render: function(){
var modelKu = Backbone.Model.extend({});
modelDia = new modelKu();
modelDia.bind("change", function(model, collection){
alert("ada perubahanlah: " + model.get('some_attribute'));
});
modelDia.set({some_attribute: "nilai untuk sesuatu"});
@infacq
infacq / borang
Last active December 25, 2015 06:19
<form action="/login" id="login-form">
Nama pengguna: <input type="text" id="nPengguna"><br>
Kata Laluan: <input type="password" id="kLaluan"><br>
<button id="login">Masuk</button>
</form>
@infacq
infacq / el
Created October 11, 2013 08:36
el: $("#login-form")
events: {
"click #login": "login"
}
window.LoginView = new LoginView({model: new Pembenaran()});
RouterKu = Backbone.Router.extend({
routes: {
"sini/sana" : "bertindak"
},
bertindak: function(){
// lakukan sesuatu disini
}
});
@infacq
infacq / setup collection
Last active December 26, 2015 04:39
sampel guna backboneJS
window.Zoo = Backbone.Collection.extend({
model:Makhluk,
url:"./api/makhluk",
initialize: function() {
this.deferred = this.fetch();
}
});