Skip to content

Instantly share code, notes, and snippets.

@sandipransing
sandipransing / ncert.rb
Created April 4, 2023 05:41 — forked from nileshtrivedi/ncert.rb
Ruby script to download all NCERT book PDFs
# NCERT books are excellent but being altered for political or other reasons
# See: https://twitter.com/SouthAsiaIndex/status/1518062204058103809
# To download the entire current set, run this script with Ruby
require 'httparty'
source = HTTParty.get('https://ncert.nic.in/textbook.php').force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
# book names are like aeen1dd.zip
# First letter tells the class number a to l is class 1 to class 12. m stands for class 11 and 12 combined
=begin
The MIT License (MIT)
Copyright (c) 2015 Sandip Ransing
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@sandipransing
sandipransing / .gitconfig
Created April 30, 2015 07:15
Useful git aliases
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate
ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
lnc = log --pretty=format:"%h\\ %s\\ [%cn]"
diff --git a/app/controllers/episodes_controller.rb b/app/controllers/episodes_controller.rb
index e845969..0a9c282 100644
--- a/app/controllers/episodes_controller.rb
+++ b/app/controllers/episodes_controller.rb
@@ -8,12 +8,18 @@ class EpisodesController < ApplicationController
else
@episodes = Episode.search_published(params[:search], params[:tag_id])
end
+ if params[:nsfw].present?
+ session[:nsfw] = params[:nsfw] == 'show' ? true : nil
require 'rubygems'
require 'nokogiri'
require 'fileutils'
require 'date'
require 'uri'
# usage: ruby import.rb my-blog.xml
# my-blog.xml is a file from Settings -> Basic -> Export in blogger.
data = File.read ARGV[0]
@sandipransing
sandipransing / simpleFormat.js
Created October 10, 2013 07:56
jQuery extension to have `simple_format` function just like we have in `rails`. jquery ".html(text)" method ignores \n (newline) chars that can be solved here. simpleFormat will replace newline chars with line breaks.
// **Example Usage**
// $.simpleFormat("this is first \n here is next line")
// OR
// $(".note").simpleFormat()
(function($) {
$.simpleFormat = function(str) {
str = str.replace(/\r\n?/, "\n");
str = $.trim(str);
if (str.length > 0) {
@sandipransing
sandipransing / storyjs-embed.js
Created October 8, 2013 06:38
TimelineJS related issue -> "Storyjs-embed.js loads jQuery 1.7.2 if jQuery 1.10.X is loaded" https://github.com/NUKnightLab/TimelineJS/issues/482 Solution: Essentially we need to split the jQuery version based on DOT and then compare for major and minor versions as shown below: ```javascript f = $.map(jQuery.fn.jquery.split('.'), Number); a = $.…
/*!
StoryJS
Designed and built by Zach Wise at VéritéCo
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*//* **********************************************
Begin LazyLoad.js
********************************************** *//*jslint browser: true, eqeqeq: true, bitwise: true, newcap: true, immed: true, regexp: false *//*
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@sandipransing
sandipransing / layout file in rails
Created July 12, 2011 10:27
layout file in rails
cat app/views/layouts/homepage.html.haml
- content_for :layout_head do
%script{:type=>"text/javascript", :src=>"http://maps.google.com/maps/api/js?sensor=false"}
- google_apis = 'https://ajax.googleapis.com/ajax/libs'
= javascript_include_tag "#{google_apis}/jquery/1.4.4/jquery.min.js"
= javascript_include_tag "#{google_apis}/jqueryui/1.8/jquery-ui.min.js"
= javascript_include_tag %w(rails application), :cache => false
= javascript_include_tag %w(placeholder maps.tooltip gmap jquery.qtip.min)
= javascript_include_tag "/javascripts/easySlider1.7.js"
@sandipransing
sandipransing / heroku db pull error
Created June 29, 2011 15:05
heroku db pull error
heroku db:pull mysql://root@localhost/otz_production --app otz-production
Loaded Taps v0.3.23
Warning: Data in the database 'mysql://root@localhost/otz_production' will be overwritten and will not be recoverable.
! WARNING: Potentially Destructive Action
! This command will affect the app: otz-production
! To proceed, type "otz-production" or re-run this command with --confirm otz-production
> otz-production
Receiving schema