Skip to content

Instantly share code, notes, and snippets.

View ananyo2012's full-sized avatar
🎯
Focusing

Ananya Maiti ananyo2012

🎯
Focusing
View GitHub Profile
@ananyo2012
ananyo2012 / 9-2-2017-minutes.md
Created September 2, 2017 08:42
PyConf Hyderabad 2017 Minutes of Meeting - 2nd Sept, 2017

PyConf Hyderabad 2017

Minutes of Meeting - 2nd Sept, 2017

Venue

  • Ramesh looking after Venue
  • Dean confirmation required
  • Look for other options - JNTU, Golconda Hotel
  • Talk to Sharath regarding other places
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="AdminControllerTest" tests="32" time="2.978786315" failures="1" errors="0" skipped="0" assertions="111" timestamp="2017-06-16T22:59:34+05:30">
<testcase name="test_admin_should_demote_moderator_role_to_basic" time="0.548260567" assertions="2">
</testcase>
<testcase name="test_admin_should_promote_user_role_to_admin" time="0.038366581" assertions="2">
</testcase>
<testcase name="test_admin_should_promote_user_role_to_moderator" time="0.040179291" assertions="2">
</testcase>
<testcase name="test_admin_user_should_be_able_to_mark_a_node_as_spam" time="0.181041467" assertions="8">
</testcase>
@ananyo2012
ananyo2012 / test.rake
Created January 3, 2017 16:39
Custom rake task
# rake test:all
namespace :test do
desc "Run rails and jasmine tests"
task :all do
puts "Running Rails tests"
Rake::Task["test"].execute
puts "Running jasmine tests headlessly"
Rake::Task["spec:javascript"].execute
end
end
@ananyo2012
ananyo2012 / node.rb
Created January 3, 2017 04:14
Node model
class Node < ActiveRecord::Base
include NodeShared # This includes the NodeShared Concern
attr_accessible :title, :uid, :status, :type, :vid, :cached_likes, :comment, :path, :slug
self.table_name = 'node'
self.primary_key = 'nid'
has_many :node_selections, :foreign_key => :nid
has_many :answers, :foreign_key => :nid
@ananyo2012
ananyo2012 / node_shared.rb
Created January 3, 2017 04:04
Node Shared Concern
module NodeShared
extend ActiveSupport::Concern
def likes
self.cached_likes
end
def liked_by(uid)
self.likers.collect(&:uid).include?(uid)
end
@ananyo2012
ananyo2012 / unlike.html
Created January 1, 2017 04:26
jasmine fixture
<ul class="btn-group">
<li rel="tooltip" title="Helpful? Like it and get updates!" class="btn btn-default btn-sm btn-like" node-id="1" id="like-button-1"><span id="like-star-1" class="fa fa-star"></span> <span id="like-count-1">1</span></li>
</ul>
<script>
jQuery(document).ready(function() {
$('#like-button-1').on('click', clickliked);
})
@ananyo2012
ananyo2012 / jasmine_spec.js
Created December 31, 2016 16:55
Sample jasmine test
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});
$ python manage.py migrate
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/ananyo/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/ananyo/.local/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
    settings.INSTALLED_APPS
  File "/home/ananyo/.local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
@ananyo2012
ananyo2012 / search_query.rb
Created July 3, 2016 06:56
Ruby code for simple Search query
@notes = DrupalNode.where(
'type = "note" AND node.status = 1 AND title LIKE ?',
"%" + params[:id] + "%"
)
.joins(:drupal_tag)
.where('term_data.name LIKE ?', 'question:%')
.order('node.nid DESC')
.page(params[:page])
@ananyo2012
ananyo2012 / rss_snippet_2.js
Created July 3, 2016 06:52
Code snippet for fetching content of rss feed
$('#maps table').append('<tr class="feed-item-' + i '"></tr>');
var itemEl = $('#maps table .feed-item-' + i);
itemEl.append('<tr class="title"></tr>');
itemEl.find('.title').html(title);
itemEl.append('<tr class="description"></tr>');
itemEl.find('.description').html(description);