Skip to content

Instantly share code, notes, and snippets.

Vishal Telangre vishaltelangre

Block or report user

Report or block vishaltelangre

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View combine_pdfs_into_one.sh
"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o "output.pdf" *.pdf
@vishaltelangre
vishaltelangre / savon.rb
Last active Sep 16, 2019
Logging Savon SOAP requests/responses in Rails
View savon.rb
# initializers/savon.rb
# Savon Global configuration
Savon.configure do |config|
config.log = true
config.log_level = :debug
config.logger = Rails.logger
config.env_namespace = :soapenv
end
@vishaltelangre
vishaltelangre / nginx_assets.md
Last active Sep 12, 2019
Serving Static Assets via Nginx
View nginx_assets.md

Concept

  • People talk about two servers: a web server (e.g. Nginx, Apache, etc.) and a app server (e.g. Language specific servers like Unicorn, Node.js, Tomcat, Http-Kit, etc.). There are exceptions where app servers not required at all (as web server itself provides preprocessors for handling), but let's not talk about now.
  • Web servers are really fast and supports lot of standard and commonly used MIME-type requests. Concept of serving a file is -- forming and sending a response of bytes of data and labeling it with requested MIME-type by a client (e.g. web browser).
  • Every response format (in layman's language, a file) is recognized by it's MIME-type, for e.g. a PNG image file has "image/png" MIME-type. JavaScript file has "text/javascript". HTML responses (or files) has "text/html". Plain text files have "text/plain".
  • Modern Browsers supports a lot of standard MIME-types. Images, videos, text files (XML, HTML, SVG, JS), and they better know how to visualize it. Browser also knows unrec
@vishaltelangre
vishaltelangre / post_message_example.js
Last active Aug 8, 2019
window.postMessage example
View post_message_example.js
// recieve message
// event object contains:
// - data: message sent
// - origin (host from which the message was sent, e.g. http://blah.example.com)
// - source (reference to a Window object from which message was sent)
function postMessageHandler( event ) {
console.log("We've got a message!");
console.log("* Message:", event.data);
console.log("* Origin:", event.origin);
console.log("* Source:", event.source);
@vishaltelangre
vishaltelangre / auto_install_sublime_packages.markdown
Last active Jul 10, 2019
[Automate Packages Installation in Sublime Text 2] -- Automatically install Sublime Text 2 packages (some necessary ones, w/o fucking crap ones which makes sublime alike hell!)
View auto_install_sublime_packages.markdown
  • To install packages, every time pressing ' ctrl+shift+pPackage Control: Install Package is very cumbersome task... right?

  • After fresh installation of ST2, open it and ctrl+` and hit enter after pasting below line [(1)][1]:

  import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')
  • Restart ST2.

  • Open terminal, and navigate to Sublime's dir under your home folder by below command and create file w/ name Package Control.sublime-settings there in:

View upsert_all_postgres_issue.rb
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem "rails", github: "rails/rails"
@vishaltelangre
vishaltelangre / blur.css
Created Apr 17, 2014
cross browser blur filter using css
View blur.css
.blur {
-webkit-filter: blur(3px);
-moz-filter: blur(3px);
-ms-filter: blur(3px);
-o-filter: blur(3px);
/* FF doesn't support blur filter, but SVG */
filter: url("data:image/svg+xml;utf8,<svg height='0' xmlns='http://www.w3.org/2000/svg'><filter id='svgBlur' x='-5%' y='-5%' width='110%' height='110%'><feGaussianBlur in='SourceGraphic' stdDeviation='5'/></filter></svg>#svgBlur");
filter: progid: DXImageTransform.Microsoft.Blur(PixelRadius = '3');
filter: blur(3px);
}
@vishaltelangre
vishaltelangre / left_shift_and_right_shift_operators.md
Last active Aug 31, 2018
Left Shift (<<) and Right Shift (>>) Operators
View left_shift_and_right_shift_operators.md

Left Shift (<<) Operator

x << y == x * (2 ^ y)
Examples
1 << 5 == 1 * (2 ^ 5) == 32
@vishaltelangre
vishaltelangre / tools_i_use.md
Last active Mar 5, 2018
Tools I Use #tools_i_use
View tools_i_use.md

Shell

Git

You can’t perform that action at this time.