Skip to content

Instantly share code, notes, and snippets.

View Najaf's full-sized avatar

Ali Najaf

View GitHub Profile
<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 / test-gist.lhs
Created July 19, 2012 08:02
A test gist
A literal haskell gist file
> someHaskellCode :: a -> [a]
@Najaf
Najaf / test-gist.md
Created July 19, 2012 08:04
A test gist

A literal haskell gist file

someHaskellCode :: a -> [a]

@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 / 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 / -
Created January 2, 2014 16:50
def test_gist_from_cli
puts "hello world"
end
puts 'hello world'
namespace :admin do
task :list_users do
User.all.each { |u| puts [u.name, u.email, u.created_at].join(' | ') }
end
task :show_stats do
puts Stats.todays_traffic
end
end
require 'fileutils'
# constants for site generation
PUBLIC_DIR = 'public/'
CONTENT_DIR = 'content/'
LAYOUT = 'views/layout.erb'
namespace :site do
task :clear do
FileUtils.rm_rf "#{PUBLIC_DIR}/*"
#! /usr/bin/env ruby
require "twitter"
require 'csv'
require 'regexp'
# Twitter setup was here...
#Gets the last 10 tweets from a given user from the twitter API
screen_name = String.new ARGV[0]