Skip to content

Instantly share code, notes, and snippets.

@ric03uec
ric03uec / session.js
Created March 30, 2012 16:17
set setssion
app.dynamicHelpers({
session : function(req, res){
return req.session;
}
});
@ric03uec
ric03uec / topbar.jade
Created April 1, 2012 09:03
conditional topbar
-if(session.user)
div#logoutsection.pull-right
a#logout-btn.btn.btn-info.pull-right.top-bar-form-button(href='logout/') Logout
p#loginprompt.pull-right.login-prompt #{session.user.username}
small logged In
-else
ul.pull-right
li
a#signup-btn.btn.pull-right.top-bar-form-button(href='#signup-modal', data-toggle="modal") Sign Up
form.pull-right.form-horizontal.top-bar-form(method="post", id="loginForm")
@ric03uec
ric03uec / logoutHandler.js
Created April 1, 2012 09:15
logout route handler
/**
* Logout the current user and clear the session
*/
app.get('/logout', function(req, res){
logger.log('Serving request for url [GET] ' + req.route.path);
req.session.user = undefined;
res.redirect('/');
});
@ric03uec
ric03uec / dynamichelpers.js
Created April 1, 2012 09:24
dynamic helpers
app.dynamicHelpers({
session : function(req, res){
return req.session;
},
someInfo : function(req, res){
//getting, setting, and manipulation
return someAwesomeInfo;
},
@ric03uec
ric03uec / loginhandler.js
Created April 1, 2012 09:34
login handler
if(username && password){
$.post('/login', $(this).serialize(), function(response){
if(response.retStatus === 'success'){
$('#loginForm').hide();
$('#signup-btn').hide();
$(location).attr('href', '/');
}else if(response.retStatus === 'failure'){
$('#signup-error-modal').modal('show');
}
});
@ric03uec
ric03uec / inputbutton.jade
Created August 24, 2012 20:41
inputbutton.jade
//...some layout here
button#add-friends Add Friends
ul#friends-list
@ric03uec
ric03uec / main.js
Created August 24, 2012 20:49
main.js
//javascript for the main page//
var initView = function(){
//initialize a model
var Friend = Backbone.Model.extend({
name : null,
initialize : function(){
this.name = null;
}
});
$dd if=/dev/zero of=/root/myswapfile bs=1M count=1024
$chmod 600 /root/myswapfile
mkswap /root/myswapfile
swapon /root/myswapfile
@ric03uec
ric03uec / vmstat
Created September 28, 2013 23:15
system fluctuation on starting too many docker containers at once
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 726436 9584 9372 72132 0 0 0 66 94 259 6 5 89 0
2 0 915176 13468 8312 77440 100 5818 11028 5976 1605 1494 28 61 11 1
4 1 855756 40216 2940 52516 344 64056 32980 74284 2949 3885 24 72 5 1
1 0 908288 10860 2412 82680 2684 29272 26826 39244 1858 4379 23 57 21 0
4 2 908000 10196 2416 83600 194 0 632 0 181 472 10 10 80 0
0 0 907756 10124 2560 83680 238 0 312 2 149 403 5 7 88 0
$ free -k
total used free shared buffers cached
Mem: 502936 479724 23212 0 7872 89016
-/+ buffers/cache: 382836 120100
Swap: 1048572 940600 107972