Skip to content

Instantly share code, notes, and snippets.

View kracekumar's full-sized avatar

Kracekumar kracekumar

View GitHub Profile
create_table :post_tags do |t|
t.references :posts
t.references :tags
t.timestamps
end
#post_controller.rb
class PostController < ApplicationController
filter_access_to :all
before_filter :login_required
def add
@posts=Post.new(params[:posts])
@posts.author = current_user
if request.post? and @posts.save
#post/add server log
Processing PostController#add (for 127.0.0.1 at 2011-03-26 11:19:43) [POST]
Parameters: {"commit"=>"► Publish Post", "action"=>"add", "authenticity_token"=>"A+JmgkBKiCxrpqk1H0n6HZJp6PnwaZFJCPjOp9N0jG0=", "controller"=>"post", "posts"=>{"title"=>"Python django", "content"=>"<p>Is django better</p>"}}
User Columns (1.2ms) SHOW FIELDS FROM `users`
User Load (0.1ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
CACHE (0.0ms) SELECT * FROM `users` WHERE (`users`.`id` = 1)
privileges_users Columns (0.6ms) SHOW FIELDS FROM `privileges_users`
Privilege Load (0.1ms) SELECT * FROM `privileges` INNER JOIN `privileges_users` ON `privileges`.id = `privileges_users`.privilege_id WHERE (`privileges_users`.user_id = 1 )
Post Columns (1.4ms) SHOW FIELDS FROM `posts`
#child.py
#! /usr/bin/env python
import subprocess
import sys
try:
processes=int(raw_input("NO of child process:"))
pid_list=[]
for x in xrange(processes+1):
text="echo " + str(x)
echo=subprocess.Popen(text,stdout=subprocess.PIPE,shell=True,stdin=subprocess.PIPE)
class OnlineExamController < ApplicationController
def index
@user=current_user
@employee=Employee.find_by_employee_number(@user.username)
# flash[:notice]="#{@employee.id}"
@subjects=EmployeesSubject.find_all_by_employee_id(@employee.id)
@subject_name=Array.new
@batch_details=Array.new
@display_details=Array.new
@count=0
gnome-terminal -e './node.py'
gnome-terminal -e './cluster.py'
gnome-terminal -e './outlier.py'
this is a shell script and all the py file still remain in terminal
#timetable_controller.rb
class TimetableController < ApplicationController
before_filter :login_required
before_filter :protect_other_student_data
filter_access_to :all
mysql> select * from batches;
+----+----------------+-----------+---------------------+---------------------+-----------+------------+
| id | name | course_id | start_date | end_date | is_active | is_deleted |
+----+----------------+-----------+---------------------+---------------------+-----------+------------+
| 1 | 11 A Bio group | 1 | 2011-04-13 00:00:00 | 2012-04-13 00:00:00 | 1 | 0 |
+----+----------------+-----------+---------------------+---------------------+-----------+------------+
1 row in set (0.03 sec)
mysql> select * from subjects;
+----+--------------------+------+----------+----------+--------------------+-------------------+------------+---------------------+---------------------+
#controller
class UploadMaterialController < ApplicationController
def index
end
def upload
@user = current_user
@upload=UploadMaterial.new(params[:upload_material])
@upload[:author]=current_user
name=@upload[:name].original_filename
directory="public/uploads/materials"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Happy School </title>
<link href="/stylesheets/application.css?1302694012" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/_styles/ui.all.css?1302694012" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/upload_material/upload.css?1302723052" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/modalbox.css?1302694012" media="screen" rel="stylesheet" type="text/css" />