Skip to content

Instantly share code, notes, and snippets.

View kracekumar's full-sized avatar

Kracekumar kracekumar

View GitHub Profile
@kracekumar
kracekumar / exam_group.rb
Created May 14, 2011 15:43
exam_group_error
Exam Columns (0.7ms) SHOW FIELDS FROM `exams`
Subject Load (0.1ms) SELECT * FROM `subjects` WHERE (`subjects`.`id` = 11 AND (`subjects`.`is_deleted` = 0))
ActionView::TemplateError (undefined method `_delete' for #<Exam:0xb6c53be8>) on line #69 of app/views/exam/_exam_marks_form.rhtml:
66: <td class="col-1">
67: <div class="label-field-pair2">
68: <div class="text-input-bg2">
69: <%= exam_form.check_box :_delete %>
70: </div>
71: </div>
@kracekumar
kracekumar / post.rb
Created May 14, 2011 18:45
Not getting first_name working getting undefined method `first_name' for nil:NilClass
#model
class Post < ActiveRecord::Base
belongs_to :author, :class_name => 'User'
has_many :comment, :class_name =>'PostComment'
has_many:post_tags
has_many:post_views
has_many:post_ratings
has_many:post_likes
validates_presence_of :title,:content
@kracekumar
kracekumar / copy youtube videos.sh
Created May 23, 2011 08:12
Example to copy flash file
kracekumar@python-lover:~$ cd /proc
kracekumar@python-lover:/proc$ ps aux |grep 'flash'
1000 2420 1.9 1.9 245488 57768 ? Sl 13:25 0:05 /usr/lib/firefox-4.0.1/plugin-container /usr/lib/adobe-flashplugin/libflashplayer.so -omnijar /usr/lib/firefox-4.0.1/omni.jar 2341 true plugin
1000 2628 0.0 0.0 4152 860 pts/0 S+ 13:30 0:00 grep --color=auto flash
kracekumar@python-lover:/proc$ cd 2420
kracekumar@python-lover:/proc/2420$ ls
attr coredump_filter io mounts personality stat
autogroup cpuset latency mountstats root statm
auxv cwd limits net sched status
cgroup environ loginuid oom_adj schedstat syscall
diff -ur recipes-orig/recipes//AubergineAndChickpeaSkillet.txt recipes/AubergineAndChickpeaSkillet.txt
--- recipes-orig/recipes//AubergineAndChickpeaSkillet.txt 2010-11-19 06:19:14.000000000 +0530
+++ recipes/AubergineAndChickpeaSkillet.txt 2011-06-03 00:43:06.005929000 +0530
@@ -1,4 +1,4 @@
-Aubergine and Chickpea Skillet is a colorful and tasty dish suitable
+Eggplant and Chickpea Skillet is a colorful and tasty dish suitable
for vegans. It is important to use fresh basil in this recipe.
Ingredients
@@ -6,7 +6,7 @@
kracekumar@python-lover:~/openhatch/contrib$ python2.6 bootstrap.py
kracekumar@python-lover:~/openhatch/contrib$ ./bin/buildout
Traceback (most recent call last):
File "./bin/buildout", line 15, in <module>
import site # imports custom buildout-generated site.py
File "/home/kracekumar/openhatch/contrib/parts/buildout/site.py", line 564, in <module>
main()
File "/home/kracekumar/openhatch/contrib/parts/buildout/site.py", line 547, in main
known_paths = addsitepackages(known_paths)
File "/home/kracekumar/openhatch/contrib/parts/buildout/site.py", line 262, in addsitepackages
@kracekumar
kracekumar / enthought_error.py
Created June 19, 2011 08:45
again same error but this virtual env is installed
(contrib)kracekumar@python-lover:~/openhatch/contrib$ mkvirtualenv --no-site-packages openhatch
New python executable in openhatch/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts Creating /home/kracekumar/.virtualenvs/openhatch/bin/predeactivate
virtualenvwrapper.user_scripts Creating /home/kracekumar/.virtualenvs/openhatch/bin/postdeactivate
virtualenvwrapper.user_scripts Creating /home/kracekumar/.virtualenvs/openhatch/bin/preactivate
virtualenvwrapper.user_scripts Creating /home/kracekumar/.virtualenvs/openhatch/bin/postactivate
(openhatch)kracekumar@python-lover:~/openhatch/contrib$ python bootstrap.py
Generated script '/home/kracekumar/openhatch/contrib/bin/buildout'.
@kracekumar
kracekumar / mongo.db
Created June 24, 2011 13:25
mongodb limit func with +ve and -ve int arg
> db.idiot.find()
{ "_id" : ObjectId("4e04889e91c0859fa2c3effa"), "name" : "idiot" }
{ "_id" : ObjectId("4e048f5b91c0859fa2c3f011"), "a" : 2, "b" : 5 }
> db.idiot.update({a=2},{$inc:{a:2}},false,true)
Fri Jun 24 18:53:02 SyntaxError: missing : after property id (shell):0
> db.idiot.update({a:2},{$inc:{a:2}},false,true)
> db.idiot.find()
{ "_id" : ObjectId("4e04889e91c0859fa2c3effa"), "name" : "idiot" }
{ "_id" : ObjectId("4e048f5b91c0859fa2c3f011"), "a" : 4, "b" : 5 }
> db.idiot.find().limit(1)
@kracekumar
kracekumar / howdiditwork.py
Created June 27, 2011 19:01
really I din't undersdtand
>>> def one():
... return range(1,45)
...
>>> def two():
... return range(2,34)
...
>>> random.choice([one,two])()
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]
>>> [one,two]()
Traceback (most recent call last):
@kracekumar
kracekumar / a.txt
Created July 2, 2011 21:56
error 17: unable to mount partition
kracekumar@python-lover:~$ sudo fdisk -l
Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf897e57b
Device Boot Start End Blocks Id System
@kracekumar
kracekumar / searchTwitterGen.py
Created October 4, 2011 03:29
searchTwitterGen() seems to broken, correct me if I am wrong
kracekumar@python-lover:~$ ipython
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
Type "copyright", "credits" or "license" for more information.
IPython 0.10.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.