Skip to content

Instantly share code, notes, and snippets.

View jagira's full-sized avatar
🙃

Jigar Patel jagira

🙃
View GitHub Profile
@jagira
jagira / securing_the_server.md
Created January 24, 2024 03:40
Server Security Basics

Securing the server

Securing a server is a continuous process as new vulnerabilities are discovered everyday. But you will be relatively safe if you take some basic security measures like locking root access, not allowing password authentication, setting up a basic firewall and log watching mechanism and enabling automatic updates.

1. Login as root and update package list and upgrade tools.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jagira
jagira / pg_backup_and_restore.sh
Created February 6, 2018 05:21
Commands to take backup and restore a PostgreSQL database
# Take backup
pg_dump -F c -v DATABASE_NAME -f FILENAME.sql
# Restore from backup
pg_restore --verbose --clean --no-owner --no-acl --dbname DATABASE_NAME FILENAME.sql
@jagira
jagira / db.rake
Created July 13, 2017 11:53 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@jagira
jagira / list_to_range.ex
Last active December 17, 2015 11:13
Generate a list of ranges from a list of characters
defmodule ListToRange do
def generate(list) do
generate(list, [])
end
def generate([_], accumulator) do
accumulator
end
@jagira
jagira / browse_controller.rb
Created April 4, 2013 16:36
Twitter Fetcher
class BrowseController < ApplicationController
# params - username, count
def tweets
@tweets = Twitter.fetch_tweets(params[:username], params[:count])
render json: @tweets
end
end
@jagira
jagira / raghu_coding_assignment.txt
Last active December 15, 2015 14:39
A small coding assignment to test developer's basic Ruby (and Sinatra/Rails) skills
* Write a small web service (using Sinatra, Padrino, Rails or Rack if you are adventurous) that fetches and returns 10 (or any user specified number) latest tweets for the specified username.
* Architect the app according to your own taste.
* Rough specs
- It should have only one controller endpoint. For example,
'/tweets'
- The endpoint should accept a twitter username and tweet count (default set to 10). For example,
@jagira
jagira / old_blogger_widget.html
Created October 7, 2011 07:32 — forked from ztay/gist:1269688
Blogger Widget (Old)
<b:if cond='data:blog.pageType == "index" || data:blog.pageType == "archive"'>
<a expr:href='data:post.url + "?pfstyle=wp"' style=" color:#6D9F00; text-decoration:none;" class="printfriendly" title="Printer Friendly and PDF"><img style="border:none;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print Friendly and PDF"/></a>
<b:else/>
<script src="http://cdn.printfriendly.com/printfriendly.js" type="text/javascript"></script><a href="http://www.printfriendly.com" style=" color:#6D9F00; text-decoration:none;" class="printfriendly" onclick="window.print(); return false;" title="Printer Friendly and PDF"><img style="border:none;" src="http://cdn.printfriendly.com/pf-button.gif" alt="Print Friendly and PDF"/></a>
</b:if>
@jagira
jagira / add_to_blogger.html
Created October 6, 2011 08:00
Add Widget aTo Blogger
<form method="POST" action="http://www.blogger.com/add-widget">
<!-- Place Widget Code as value for this input. The widget code must be escaped -->
<input type="hidden" name="widget.content" value="&lt;b:if cond='data:blog.pageType == &quot;index&quot;'&gt;&lt;a expr:href='data:post.url + &quot;?pfstyle=wp&quot;' style=&quot; color:#6D9F00; text-decoration:none;&quot; class=&quot;printfriendly&quot; title=&quot;Printer Friendly and PDF&quot;&gt;&lt;img style=&quot;border:none;&quot; src=&quot;http://cdn.printfriendly.com/pf-button.gif&quot; alt=&quot;Print Friendly and PDF&quot;/&gt;&lt;/a&gt;&lt;b:else/&gt;&lt;script src=&quot;http://cdn.printfriendly.com/printfriendly.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;&lt;a href=&quot;http://www.printfriendly.com&quot; style=&quot; color:#6D9F00; text-decoration:none;&quot; class=&quot;printfriendly&quot; onclick=&quot;window.print(); return false;&quot; title=&quot;Printer Friendly and PDF&quot;&gt;&lt;img style=&quot;border:none;&quot; src=&