Skip to content

Instantly share code, notes, and snippets.

View vparihar01's full-sized avatar

Vivek Parihar vparihar01

View GitHub Profile
@vparihar01
vparihar01 / migrate-redis.py
Created November 26, 2018 06:12 — forked from thomasst/migrate-redis.py
Migrate Redis data on Amazon ElastiCache
"""
Copies all keys from the source Redis host to the destination Redis host.
Useful to migrate Redis instances where commands like SLAVEOF and MIGRATE are
restricted (e.g. on Amazon ElastiCache).
The script scans through the keyspace of the given database number and uses
a pipeline of DUMP and RESTORE commands to migrate the keys.
Requires Redis 2.8.0 or higher.
@vparihar01
vparihar01 / ffmpeg-cheatsheet.md
Created July 20, 2018 10:30 — forked from nickkraakman/ffmpeg-cheatsheet.md
FFmpeg cheat sheet for 360 video

FFmpeg Cheat Sheet for 360º video

Brought to you by Headjack

 
FFmpeg is one of the most powerful tools for video transcoding and manipulation, but it's fairly complex and confusing to use. That's why I decided to create this cheat sheet which shows some of the most often used commands.

 
Let's start with some basics:

  • ffmpeg calls the FFmpeg application in the command line window, could also be the full path to the FFmpeg binary or .exe file
Architecture: Rails 3.2, Solr 1.4 with sunspot_solr gem, Apache HTTP server as reverse proxy to
Rails app, Jquery UI
Note: I don't care about the distinction between autocomplete and autosuggest. I am implementing what some
people call autosuggest, and I'm calling it autocomplete.
Given the above existing architecture, I want to add an autocomplete field into my app for a single
attribute on a single model. It needs to be fast and secure (duh). The search target field could have
white space and the search input should allow it, e.g., if I search with "iker's gui" it should return

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
require 'oauth_util.rb'
require 'net/http'
o = OauthUtil.new
o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--';
o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977';
url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true';

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.

1. An issue popups in Github. A bug or a feature request.
2. Developer starts coding after understanding the issue. He makes sure to add issue number in the form of #XXX - XXX is issue number - to the commit message. This links issue with the commit that was made. It's important to know 'why the commit was made'.
3. A CI listens to pushes to the Github repo and runs all the specs and optionally deploys the code to one of the staging servers.
4. After developer is done with coding, s/he assigns the issue to another developer for code review.
5. Code reviewer makes sure that all the tests are passing along with presence of code and test coverage. Code reviewer can assign issue back to the developer if there is some issue with the code. Developer will start at step 1 again.
6. Code reviewer assigns issue to QA. If QA is not happy, s/he adds issues that were found as comment to the original issue or possibly create new issues depending upon severity of the problem s/he found out.
7. If QA is happy, she assigns th

Exposing an API

APIs are becoming an essential feature of modern web applications. Rails does a good job of helping your application provide an API using the same MVC structure you're accustomed to.

In the Controller

Let's work with the following example controller:

class ArticlesController < ApplicationController

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS