Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View vishaltelangre's full-sized avatar

Vishal Telangre vishaltelangre

View GitHub Profile
require "nokogiri"
require "uri"
require "net/http"
UA = "Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/18.0 Firefox/18.0 FirePHP/0.7.1"
@cookie = {}
def request(address, method = :get, data = {})
uri = URI.parse(address)
http = Net::HTTP.new(uri.host, uri.port)
@vishaltelangre
vishaltelangre / savon.rb
Last active September 16, 2019 14:41
Logging Savon SOAP requests/responses in Rails
# 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 / dynamic_selector_name.scss
Last active December 15, 2015 00:59 — forked from nex3/gist:1163471
Setting selector name dynamically in SASS
@mixin active($selector) {
#{$selector} {
color:black;
}
}
#my-id {
@include active($selector: ".my-class")
}
/*
* TL;DR => Safari Select Box onchange Event Bug Fix
* Problem:
On keyboard event of select box (like searching for desired options),
safari doesn't fire the event even hitting enter key. Instead, it fires
the change event on again hitting enter key or clicking anywhere,
so as we can get the selected option's value. Same happen when clicking
on desired option. This is weird.
*/
if(navigator.userAgent.match(/safari/i)){
@vishaltelangre
vishaltelangre / module_pattern.js
Created March 26, 2013 13:38
Module Design Pattern in JS
var module = {};
(function(exports){
exports.notGlobalFunction = function() {
console.log('I am not global');
};
}(module));
@vishaltelangre
vishaltelangre / call_vs_apply.js
Created March 26, 2013 14:07
Difference between `call` and `apply` in JS
var myFunc = function(arg1, arg2) {
console.log(this, arg1, arg2); // guess what is `this` !
};
var newObject = {};
myFunc('foo', 'bar'); //outputs: Window "foo" "bar"
// .call takes unlimited number of arguments, and passes first argument as
// `this` (i.e. first parameter) and rest arguments as second parameter
// npm install rem read
var rem = require('rem'),
fs = require('fs'),
read = require('read');
var tw = rem.connect('twitter.com', '1.1'),
oauth = rem.oauth(tw);
// Add whichever API keys you want to test here.
// Including the iPhone/Android apps, these keys are configured as "desktop"
@vishaltelangre
vishaltelangre / example.js
Created March 27, 2013 05:13
Mediator Pattern
// Example 1
mediator.name = 'Doug';
mediator.subscribe('nameChange', function(arg) {
console.log(this.name);
this.name = arg;
console.log(this.name);
});
mediator.publish('nameChange', 'Jorn');
@vishaltelangre
vishaltelangre / custom_commands.zsh
Created March 28, 2013 09:06
Some long commands' shortcuts I often use
# Make and cd into directory
mcd() {
mkdir -p "$1" && cd "$1";
}
# Find text in any file
ft() {
find . -name "$2" -exec grep -il "$1" {} \;
}
@vishaltelangre
vishaltelangre / vishal.b
Last active December 15, 2015 15:09
Printing my name in brainfuck!
|9| |97| |108| |115| |0|
^
V i s NULL
a h
l
++++++++++[>+++++++++>+++++++++++>++++++++++++<<<-]>----.>-----.>-----.<-.<+++++++++++.>++++.>>.
V i s h a l