Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View we4tech's full-sized avatar

Hossain Khan we4tech

View GitHub Profile
@we4tech
we4tech / stage.js
Created August 6, 2011 08:21
Using node-control i've built my deployment script, it was fun and easy to do and go :)
var control = require('control'),
script = process.argv[1],
perform = control.perform,
task = control.task;
var ProjectConfig = {
rootDir: 'staging',
git: 'git://github.com/we4tech/restaurant-review.git',
branch: 'master',
serverPort: 4000
@we4tech
we4tech / deploy.js
Created August 11, 2011 18:56
Using node-control i've built my deployment script, it was fun and easy to do and go :)
var control = require('control'),
script = process.argv[1],
perform = control.perform,
task = control.task;
/**
* Project related configuration
*/
var ProjectConfig = {
// Keep it simple word so we could use it for Rails environment too.
@we4tech
we4tech / autoclosing-issue
Created November 18, 2011 22:10
Haml issue with autoclosing
-- HAML
#new_schedule{title: "Add Schedule"}
%form
%fieldset.ui-helper-reset
%label{for: "tab_title"} Title
%input#tab_title.ui-widget-content.ui-corner-all{type: "text", name: "tab_title", value: ""}
-- Converted HTML
<div id='new_schedule' title='Add Schedule'>
<form>
@we4tech
we4tech / faq_item_spec.rb
Created November 28, 2011 13:55
spec for faq item model
require 'spec_helper'
describe FaqItem do
context 'validations' do
it 'should validate the presence of question' do
should validate_presence_of(:question)
end
it 'should validate the presence of answer' do
@we4tech
we4tech / faq_item_spec.rb
Created November 28, 2011 13:58
spec for faq item model
require 'spec_helper'
describe FaqItem do
context 'validations' do
it 'should validate the presence of question' do
should validate_presence_of(:question)
end
it 'should validate the presence of answer' do
@we4tech
we4tech / users_controller.php
Created December 18, 2011 12:49
users_controller.php
<?php
class UsersController {
public function show() {
$user = UserFinder::find(1);
$this->assignVariable('user', $user);
}
}
@we4tech
we4tech / view.phtml
Created December 18, 2011 12:51
view file
<h4>Hi, <?php echo $this->assignedVariables('user')->getName(); ?></h4>
@we4tech
we4tech / view.phtml
Created December 18, 2011 12:58
view file with fragment caching turned on
<?php cache_fragment('user_welcoming_message'): ?>
<h4>Hi, <?php echo $this->assignedVariables('user')->getName(); ?></h4>
<?php end_cache_fragment; ?>
@we4tech
we4tech / user_finder.php
Created December 18, 2011 13:00
user finder
<?php
class UserFinder {
public static function find($id) {
return new LazyLoadedModel($id, new User());
}
}
@we4tech
we4tech / lazy_loaded_model.php
Created December 18, 2011 13:05
lazy loaded model
<?php
class LazyLoadedModel {
private $instance = null;
private $refId = null;
private $initiated = false;
public function __construct($refId, $user) {
$this->refId = $refId;
$this->instance = $user;
}