This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# tweet-1.0 | |
# @author deepakkumar | |
# replace the user and passwd with your username and password | |
# the log will be available in file tweetlog in the current directory | |
import os | |
import sys | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Roulette | |
def method_missing(name, *args) | |
person = name.to_s.capitalize | |
3.times do | |
number = rand(10) + 1 | |
puts "#{number}..." | |
end | |
"#{person} got a #{number}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard[--soft] commit-id | |
git commit # if there is something needs to be changed | |
git push origin branch-name -f # -f will forcefully rewrite the history on remote branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apache Benchmarking tool - ab | |
ab can simulate a high load on the server. | |
eg: ab -n 1000 -c 10 -g test_data_1.txt http://www.your-domain.com/index.html | |
commonly used options | |
-n number of requests. Default is 1 which is useless. | |
-c concurrent requests. Default 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set count = 0 | |
for i in 192.168.150.{1..255} | |
do | |
ping -c2 -t2 $i > /dev/null | |
if [ $? -eq 0 ] | |
then | |
echo "$i is up" | |
set count = $count + 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Getip: This program takes a hostname as argument and outputs its ip address | |
Usage: ./getip <hostname> | |
Program Name: getip.c | |
Author Deepak Kumar | |
Email: deepakkumarnd@gmail.com | |
*/ | |
#include<stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git rev-parse --abbrev-ref HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rails new app_name --skip-active-record | |
Gemfile | |
gem 'mongoid', github: 'mongoid/mongoid' | |
$ rails g mongoid:config | |
Gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lib/role_constraint.rb | |
class RoleConstraint | |
def initialize(*roles) | |
@roles = roles | |
end | |
def matches?(request) | |
@roles.include? request.env['warden'].user.try(:role) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ tar -zcvf logs.tar.gz *.log | |
or | |
$ tar -zcvf logs.tar.gz folder_name | |
$ tar -zcvf data.tgz *.doc #gzip | |
$ tar -zcvf pics.tar.gz *.jpg *.png #gzip | |
$ tar -jcvf data.tbz2 *.doc #bzip2 |
OlderNewer