Skip to content

Instantly share code, notes, and snippets.

View giiska's full-sized avatar
🌴
On vacation

Null giiska

🌴
On vacation
  • Godada
View GitHub Profile
@giiska
giiska / several ways to add,get,filter-when-save derived attributes for backbone model.md
Last active August 29, 2015 14:03
several ways to add/get/filter-when-save derived attributes for backbone model

set attributes mannuly

// Cons: make code too redundant
var MyModel = Backbone.Model.extend({
    initialize: function() {
        this.updateDerivedAttributes();
        this.on('change:start_at', this.updateDerivedAttributes, this);
    },
 updateDerivedAttributes: function() {
// ==UserScript==
// @name socialbase content list replace url
// @namespace http://use.i.E.your.homepage/
// @version 0.1.1
// @description enter something useful
// @match http://socialbase.hk/socialbase/content/*
// @copyright 2014+, bammoo
// ==/UserScript==
require(['jquery'], function($) {
@giiska
giiska / a.js
Created July 7, 2014 06:19
Using custom headers with Backbone.sync backbone restful token
/*
* Using AMD/RequireJS
*
* The `auth` module handles OAuth and stores the
* access token that needs to be sent in a header
*/
define(['api/auth'], function (auth) {
'use strict';
/*
@giiska
giiska / 0readme.md
Last active August 29, 2015 14:03
set Django debug mode for site running inside virtualbox/vagrant

When visit Virtual Box site, the client ip is gateway of virtual machine, not your dev machine ip.

Check the true client ip

  • Add import pdb;pdb.set_trace() to any Django view, and open the view in chrome
  • Switch to termianl, request.META.get('REMOTE_ADDR', None) at the break point
  • The result is the true client ip address
@giiska
giiska / 0readme.md
Last active August 29, 2015 14:02
fixed width column with fluid row container by bootstrap grid system