Skip to content

Instantly share code, notes, and snippets.

Nikon D3300 - Syed's DSLR
canon 600D
Canon 70D Canon lens cheaper
Nikon D600
PS3 PS4
@srikanth4b9
srikanth4b9 / wishlist delete script
Created February 6, 2015 06:09
FlipKart Wishlist delete
$("body").delegate(".fk-item-wl-link", "mouseover", function() {
window.removeList = window.removeList || [];
var list = window.removeList;
var index = list.indexOf(this);
var $this = $(this);
if (index === -1) {
list.push(this);
$this.append('- Added to remove list');
} else {
list.splice(index, 1);
@srikanth4b9
srikanth4b9 / autobuy
Created February 6, 2015 06:10
Flipkart Auto Buy
setInterval(function() {
if (typeof clickedFlag == "undefined") {
clickedFlag = true;
i = 0;
}
if (clickedFlag != true) {
return;
}
console.log('Tried - ' + ++i + ' times');
var btn = $('.jbv.jbv-orange.jbv-buy-big');
@srikanth4b9
srikanth4b9 / gist:b475646038db3abf40f8
Created February 6, 2015 06:15
Dynamically Loading JS & CSS
function load_CSS(src, cb) {
var link = document.createElement('link');
link.type = 'text/css';
link.rel = 'stylesheet';
link.href = src;
if (cb) {
link.addEventListener('load', cb);
}
document.getElementsByTagName('head')[0].appendChild(link);
}
function getBinary(file){
var xhr = new XMLHttpRequest();
xhr.open("GET", file, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send(null);
return xhr.responseText;
}
function base64Encode(str) {
var CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@srikanth4b9
srikanth4b9 / gist:d1f6b8a4c4c6c5c89f05
Created February 11, 2015 11:39
Ember API, resources
Ember API Reference
=====================
## Debugging
- [Know thy Ember.App](http://emberjs.com/api/classes/Ember.Application.html)
- [Ember.run()](http://emberjs.com/api/classes/Ember.run.html)
- [Ember.run.later()](http://emberjs.com/api/classes/Ember.run.html#method_later)
- [Ember.run.debounce()](http://emberjs.com/api/classes/Ember.run.html#method_debounce)
- [Ember.assert()](http://emberjs.com/api/#method_assert)
- [Ember.debug()](http://emberjs.com/api/#method_debug)
@srikanth4b9
srikanth4b9 / gist:114b7cbd5f1978d2d803
Last active August 29, 2015 14:15
Even and Odd numbers order in array without using new array
console.clear();
var x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17];
for(var i = 0; i < x.length; i++){
if(x[i]%2!==0){
for(var j = i+1; j < x.length; j++){
if(x[j]%2==0){
var temp = x[j];
x[j] = x[i];
x[i] = temp;
break;
// Get a random number in a specific range
function randomInRange(max, min) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Get a random item from an array
function randomFromArray(items) {
return items[Math.floor(Math.random() * items.length)];
}
function User(){
var username, password;
function doLogin(user,pw) {
username = user;
password = pw;
// do the rest of the login work
}
var albums = [
{name: 'Beatles', title: 'White Album', price: 15},
{name: 'Zeppelin', title: 'II', price: 7}];
// make this work:
albums.sort(by('name'));
albums.sort(by('title'));
albums.sort(by('price'));
function by(propName) {
return function(obj1, obj2) {