Skip to content

Instantly share code, notes, and snippets.

View datt's full-sized avatar
🏠
Working from home

Dattatraya Dongare datt

🏠
Working from home
View GitHub Profile
/**
* Read the JavaScript cookies tutorial at:
* http://www.netspade.com/articles/javascript/cookies.xml
*/
/**
* Sets a Cookie with the given name and value.
*
* name Name of the cookie
* value Value of the cookie
@datt
datt / ajax.js
Last active December 17, 2015 09:49
common function for sending an ajax request.
/**NOTE : Define, This method makes an ajax request*/
function sendAjaxRequest (options) {
var defaults;
defaults = {
dataType: "script",
requestType: "get",
data: {},
url: "/",
@datt
datt / Gemfile
Last active December 17, 2015 09:49
Using Internationalization(I18n) in javascript of Rails application.
#NOTE Rails I18n translations on the Javascript.
gem 'i18n-js','2.1.2'
@datt
datt / ffmpeg.rb
Last active December 17, 2015 09:58
useful ffmpeg commands
#1. Getting resolution of video using ffmpeg
# after running following command you will get output in format 640x480
`ffmpeg -i #{path_to_video} 2>&1 | grep 'Video:' | cut -d \, -f 3 | sed -e 's/\[PAR//g' -e 's/x/:/g' | cut -d ' ' -f 2`
#2. Extracting preview(single) image for video
`ffmpeg -i #{path_to_video} -f image2 -ss 1 -vframes 1 #{path_to_video}/preview_0000.jpg`
#3. Extracting images from a video for a duration
`ffmpeg -i #{path_to_video} -r 25 -sameq -t #{duration} -s #{resolution} -vf -ss #{start_point} #{IMAGE_FILES_PATH}prefix_%d.jpeg`
@datt
datt / git.sh
Last active December 17, 2015 19:29
Useful git commands
######## 1.Create a branch without parent
# useful when scenario is: Suppose if you are on develop branch and you want to create a branch say feature having no code of develop branch. How can you do that?
git checkout --orphan feature
# this creates branch without parent, you can now pull remote feature into this branch.
######## 2. Add changes to previous commit or editing a git commit
# first add files you want to add in commit
git add . OR git add modified files
@datt
datt / jwplayer5_ova_plugin.js
Last active December 19, 2015 22:39
Configuring the ova plugin for openx inline video ad serving.
/**There are two ways of configuring ads in OVA
i) By using zone id : */
jwplayer("videoContainer").setup({
modes:[{type: 'html5'},{type:'flash',src: "/jwplayer/player.swf"}],
autostart: 'true',
allowscriptaccess: 'always',
playlist: [
{
"provider": "rtmp"
@datt
datt / base_creator.rb
Last active December 29, 2015 13:09
The common creator methods can be written in base creator which can be again overridden by other creators. An example of using creator is also given. To know more about Creator follow (https://github.com/datt/Creators)
class BaseCreator < Creators::Base
EXTRA_PARAMS = [:action, :controller, :format,:utf8,:authenticity_token]
def initialize(raw_params, model)
super(raw_params,model)
end
def refine_params
@params.deep_symbolize_keys.delete_if{|k,v| EXTRA_PARAMS.include? k }
@datt
datt / displayjwplayer.js
Last active December 29, 2015 17:29
Initialize jwplayer for showing video on a element.
function displayVideo(elementID, options) {
var defaults;
defaults = {
height: 347,
width: 624,
swfPath: '/jwplayer/jwplayer.flash.swf',
controls: false,
autostart: true
};
var settings = $.extend({}, defaults, options);
@datt
datt / postgres_useful_commands.sh
Last active April 2, 2017 13:37
useful database commands for dump i.e. backup and restore postgresql and mongodb
#resetting the password of postgresql
sudo -u postgres psql postgres
postgres=# \password postgres
# restoring postgres dump database
pg_restore -c -i -U postgres -h localhost -d database_name -v "dump_file" -W
pg_restore --verbose --host localhost --username postgres --clean --no-owner --no-acl --dbname database_name dump_file.dump
# for mac: full path is required.
Applications/Postgres.app/Contents/Versions/9.4/bin/pg_restore -c -i -U postgres -h localhost -d database_name -v "dump_file" -W
@datt
datt / gist:7986091
Created December 16, 2013 12:16 — forked from dhh/gist:1014971
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end