Skip to content

Instantly share code, notes, and snippets.

nhm tanveer hossain khan (hasan) we4tech

Block or report user

Report or block we4tech

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@we4tech
we4tech / stage.js
Created Aug 6, 2011
Using node-control i've built my deployment script, it was fun and easy to do and go :)
View stage.js
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 Aug 11, 2011
Using node-control i've built my deployment script, it was fun and easy to do and go :)
View deploy.js
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 Nov 18, 2011
Haml issue with autoclosing
View autoclosing-issue
-- 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 Nov 28, 2011
spec for faq item model
View faq_item_spec.rb
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 Nov 28, 2011
spec for faq item model
View faq_item_spec.rb
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
View users_controller.php
<?php
class UsersController {
public function show() {
$user = UserFinder::find(1);
$this->assignVariable('user', $user);
}
}
View view.phtml
<h4>Hi, <?php echo $this->assignedVariables('user')->getName(); ?></h4>
@we4tech
we4tech / view.phtml
Created Dec 18, 2011
view file with fragment caching turned on
View view.phtml
<?php cache_fragment('user_welcoming_message'): ?>
<h4>Hi, <?php echo $this->assignedVariables('user')->getName(); ?></h4>
<?php end_cache_fragment; ?>
View user_finder.php
<?php
class UserFinder {
public static function find($id) {
return new LazyLoadedModel($id, new User());
}
}
View lazy_loaded_model.php
<?php
class LazyLoadedModel {
private $instance = null;
private $refId = null;
private $initiated = false;
public function __construct($refId, $user) {
$this->refId = $refId;
$this->instance = $user;
}
You can’t perform that action at this time.