Skip to content

Instantly share code, notes, and snippets.

View Najaf's full-sized avatar

Ali Najaf

View GitHub Profile
@Najaf
Najaf / -
Created January 2, 2014 16:50
def test_gist_from_cli
puts "hello world"
end
@Najaf
Najaf / mechanize-cheat-sheet.rb
Last active October 15, 2019 11:17
Mechanize Cheat Sheet, take a look at the real documentation here: http://mechanize.rubyforge.org/
# Initialize Mechanize Agent
agent = Mechanize.new
# Visit a web page
agent.get 'http://localhost:3000/'
# get the url of the current page
agent.page.uri #=> http://localhost:3000
# agent remembers the scheme + host, so no need to supply it when navigating somewhere else
@Najaf
Najaf / gist:5431024
Last active December 16, 2015 11:58
Quick tip for implementing access control
# So your PicsController probably looks something like this:
class PicsController < ApplicationController
def update
@pic = Pic.find(params[:id])
@pic.update_attributes(params[:pic])
end
end
# You want to change that to this:
class PicsController < ApplicationController
@Najaf
Najaf / test-gist.md
Created July 19, 2012 08:04
A test gist

A literal haskell gist file

someHaskellCode :: a -> [a]

@Najaf
Najaf / test-gist.lhs
Created July 19, 2012 08:02
A test gist
A literal haskell gist file
> someHaskellCode :: a -> [a]
<html>
<head></head>
<body>
<h1>My Web Page</h1>
<?php include 'sidebar.html' ?>
<h2>A title</h2>
<p>Some content</p>
</body>
</html>
@Najaf
Najaf / sidebar.html
Created October 16, 2010 12:50
Test gist
<ul>
<li>
<a href='/home.php'>Home</a>
</li>
<li>
<a href='/about.php'>About</a>
</li>
<li>
<a href='/contact.php'>Contact</a>
</li>
<?php
//calling this with the above files (layout.php + page.php) in the working directory
render_page('page', array(
'title' => "About The Shakes",
'content' => "<p>Bringing the boys to the yard since 1976</p>"
));
//would then render this =>
<?php
function render_page($page, $params = array(), $layout = 'layout') {
extract($params);
$__page = "{$page}.php";
include "{$layout}.php";
}
<h3><?= $title ?></h3>
<div id='content'>
<?= $content ?>
</div>