Skip to content

Instantly share code, notes, and snippets.

View pahnin's full-sized avatar

phanindra srungavarapu pahnin

View GitHub Profile
@pahnin
pahnin / google-translate-fix-srt-translation.sh
Created October 4, 2016 18:00
commands to fix mess created by google translate while translating srt file
sed -i -E "s/\->/\-\->/g" Mafiosa.S01E05.Episode.#1.5.en.srt
sed -i -E "s/(0-9)?\.[0-9]/,\1/g" Mafiosa.S01E05.Episode.#1.5.en.srt
sed -i -E "s/: /:/g" Mafiosa.S01E05.Episode.#1.5.en.srt

when trying to install updates, it threw error since keys were not updated. so fixing keys

update key rings package

sudo pacman -Sy gnupg archlinux-keyring manjaro-keyring

get official keys from devs

sudo gpg --recv-keys 247B52CC 11C7F07E 59152F77 5C0102A6 604F8BA2 AC97B894 5DCB998E B35859F8 663CA268 8DF53602 A42D53A2

register an official key from developer

sudo pacman-key --lsign-key 59152F77

@pahnin
pahnin / diamond.rb
Created September 23, 2013 09:14
print diamond in ruby, this might not be the best implementation
(-2..2).each do |k|
k.abs.times do
print " "
end
(3-(k.abs)).times do
print "* "
end
puts "\n"
end
@pahnin
pahnin / wierd_output.rb
Created September 17, 2013 18:59
output 1 2 3 4 5 6 6 7 8 9
c=0
(1..4).each do |n|
d=c
c=n-1
e=n+d
n.times do
print e
e=e+1
end
print "\n"
@pahnin
pahnin / convert_to_csv.rb
Last active December 22, 2015 17:19
converts txt file to csv with names and phone numbers
#!/usr/bin/env ruby
lines = IO.readlines("phonebook.txt").map do |line|
lm = line.gsub(/-|\s/,'').match(/([a-zA-Z]+)(\d+)/)
"#{lm[1]},#{lm[2]}" unless lm.nil?
end
File.open("Gulties.csv","w") do |file|
file.puts lines
end
@pahnin
pahnin / convert_vid.sh
Created July 6, 2013 12:13
Bash script to convert multiple video files to mp3s using ffmpeg.. Don't know if someone already written similar or better script, this is just for my self satisfaction also I'll be glad if it is useful for others
#!/bin/bash
# Script License: GPL
# Dependensies: ffmpeg (You need ffmped installed in your system)
# Usage: "Takes single/multiple file paths as input and converts them to mp3"
# Example: "./convert_vid.sh Downloads/Amsterdam\ Imagine\ Dragons.flv Downloads/BrownRang.mp4" converts 'Downloads/Amsterdam Imagine Dragons.flv' and 'Downloads/BrownRang.mp4' to 'Downloads/Amsterdam Imagine Dragons.flv.mp3' and 'Downloads/BrownRang.mp4.mp3'
if [ $# -gt 0 ]; then
while test $# -gt 0
do
@pahnin
pahnin / isbn.rb
Last active December 17, 2015 12:09
ISBN13 barcode
#! /bin/env ruby
def isbn(inp)
switch=true
sum=0
inp.to_s.split('').each do |i|
if switch
sum=sum+i.to_i
switch=false
else
sum=sum+(i.to_i)*3
@pahnin
pahnin / IntelligentCaptcha.rb
Created January 1, 2013 20:01
One can use this code to generate random questions which is returned in a text format and shall be converted to image form and validate the answer response with the answer. Test run this code at http://www.programr.com/Ruby/IntelligentCaptcha
class Captcha
def initialize
@numbers=[1,2,3,4,5,6,7,8,9]
@numbers_alpha={
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
@pahnin
pahnin / hubscanner.rb
Created September 5, 2012 15:10
Dc hub scanner for LAN
#This Script is released under Gnu GPL
require 'socket'
require 'timeout'
class Hubscan
def initialize
@init_ip=192
@end_ip=216
@verbose=false
@pahnin
pahnin / captcha.rb
Created June 18, 2012 15:18
ruby programm to return array of text and its value, can be used as alterantives to captcha. Example: [4, "four divided by one"] , [0, "eight minus eight"] , [6, "two plus four"]
class Captcha
def initialize
@numbers=[1,2,3,4,5,6,7,8,9]
@numbers_alpha={
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",