Skip to content

Instantly share code, notes, and snippets.

View abhishek77in's full-sized avatar

Abhishek Srivastava abhishek77in

View GitHub Profile
@abhishek77in
abhishek77in / convert_flv_to_mp4.md
Last active December 11, 2015 12:59
Convert video from MP4 format to FLV format.

Convert video from MP4 format to FLV format

$brew install ffmpeg
$ffmpeg -i input_file.mp4 -f flv output.flv
  • ffmpeg - runs the program
  • -i input_file.mp4 - input file
  • -f flv - force format followed by format
  • output.flv - output file
@abhishek77in
abhishek77in / git_patch.md
Last active December 12, 2015 00:09
Crate a git patch for a single commit, appy the patch

Creating a patch

git format-patch -1 commit-sha

Applying a patch

git apply PATCH_FILENAME
@abhishek77in
abhishek77in / vimrc
Last active December 14, 2015 13:19
My sweet n short vimrc (I use vundle)
set nocompatible " choose no compatibility with legacy vi
syntax enable
set encoding=utf-8
set showcmd " display incomplete commands
"" Whitespace
set nowrap " don't wrap lines
set softtabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set expandtab " use spaces, not tabs (optional)
set backspace=indent,eol,start " backspace through everything in insert mode
@abhishek77in
abhishek77in / dir_level_search_replace.md
Last active December 15, 2015 09:39
Directory level search and replace string

Using ack, xargs and sed in shell -

ack -l old_str | xargs sed -i -e "s/old_str/new_str/g"

Example ack -l excerpt | xargs sed -i -e "s/excerpt/description/g"

Using VIM -
Doing this will be quite complicated in vim as explained by Drew Neil in vimcasts.org

@abhishek77in
abhishek77in / find_methods_on_ruby_object.md
Last active December 15, 2015 09:39
Various ways of finding methods on a Ruby Object

Create an object ex: obj = String.new

  1. obj.methods - List all methods
  2. obj.methods.sort - List all methods in sorted order
  3. obj.methods.grep(REGEX) - List all methods matching a regular expression
  4. obj.methods - Object.methods - List all methods not present in parent object Object
  5. obj.respond_to :method_name - Check if object responds to a method
@abhishek77in
abhishek77in / info.hackernotes.md
Last active December 16, 2015 23:50
Info about HackerNotes

##Hacker Notes ?

Allow new developers to catch up right things from the start by collaborating on Hacker Notes. Improve Hacker Notes pages by voting on resources or adding new resources. Find, share and learn interesting stuff.

If you own a Github Repository - Add resources to your repository page. Share it with developers, link it to your project README or WIKI.

If you like a HackerNotes page best way to share it is link it to corresponding project WIKI or README.

Eg. https://github.com/etsy/statsd/wiki#blog-posts-and-links

@abhishek77in
abhishek77in / pages.hackernotes.md
Last active December 19, 2015 03:29
Hacker Notes pages
@abhishek77in
abhishek77in / pages.hackernotes.md
Last active December 19, 2015 05:19
Hacker Notes Javascript Frameworks, Web Servers
@abhishek77in
abhishek77in / DevOps Tips.md
Last active December 25, 2015 19:09
DevOps Tips

Restore postgres database from sql file -

psql <databasename> -U <username> < ~/Downloads/<filename>.sql

Find and replace a word in a directory -

find path-to-directory -type f -not -path "./directory/*" -exec sed -i '' 's/old-word/new-word/g' {} \;

To compress directory with Tar -

@abhishek77in
abhishek77in / endless-scroll.js
Last active December 26, 2015 21:59
Simple script for implementing endless scroll
var offset = 4;
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() > ($(document).height() - 150)) {
loadMore(offset);
offset = offset + 4;
}
});
function loadMore(offset) {