Skip to content

Instantly share code, notes, and snippets.

Agnel Waghela agnel

View GitHub Profile
@agnel
agnel / __mixins.js
Last active Mar 19, 2018
A collection of _.js mixins
View __mixins.js
_.mixin({
isHash: function(object) {
return _.isObject(object) && !_.isArray(object);
},
capitalize: function(string) {
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
},
@agnel
agnel / load_libs_in_console.js
Last active Sep 13, 2017
load any js library into developers console using fetch
View load_libs_in_console.js
// load angular
fetch('https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js')
.then(response => response.text())
.then(text => eval(text))
// load $
fetch('http://code.jquery.com/jquery-2.1.0.js')
.then(response => response.text())
.then(text => eval(text))
@agnel
agnel / multiple_ajax_request.js
Created Jun 9, 2017
Multiple Ajax requests using jQuery.when
View multiple_ajax_request.js
var requests = [];
var responses = [];
var urls = []; // sample urls
$.each(urls, function(url) {
requests.push( $.get(url, getQueryParams(), function(resp){ responses.push(resp) }) );
});
// here this is the object to which the arguments is to be passed
@agnel
agnel / egghead-lesson-urls-code.js
Last active Jun 9, 2017
Extract Egghead.io Lesson urls from the DOM
View egghead-lesson-urls-code.js
/**
* Paste this in the console of a lesson page
*
* @return [Array] List of urls for a course
*/
$.map($('.up-next-list-item'), function(el) { return $(el).attr('href') });
/**
* Paste this on the courses page
* Tip: convert the list to String by append .join('\n')
@agnel
agnel / simple_sort.rb
Created Oct 5, 2016 — forked from emad-elsaid/simple_sort.rb
simple sorting algorithms with ruby this is a small practice for implementing simple sorting algorithms using ruby, i grabed the Pseudocode from their respective wikipedia pages and converted them to ruby, one new thing i have learned from this simple practice is swapping arrays elements in single line of code.
View simple_sort.rb
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
#
# this script is a small practice in implementing
# simple sorting algorithms in ruby, i converted
# the sorting algorithms from wikipedia pages
class Array
# Insertion sort is a simple sorting algorithm that builds
# the final sorted array (or list) one item at a time.
@agnel
agnel / contiguous_subarray.rb
Last active Sep 13, 2016
Ruby Program to find contiguous subarray within a one dimensional array of numbers (containing at least one positive number) which has the largest sum
View contiguous_subarray.rb
# Question:
# Write a RoR program to find the contiguous subarray within a onedimensional
# array of numbers (containing at least one positive number) which has the largest sum.
# For example, for the sequence of values −2, 1, −3, 4, −1, 2, 1, −5, 4; the contiguous
# subarray with the largest sum is 4, −1, 2, 1, with sum 6.
# The program should run as follows <bold is user entry>:
# Enter the array :
# -2 1 -3 4 -1 2 1 -5 4
# => [-2, 1, -3, 4, -1, 2, 1, -5, 4]
# Largest SubArray
@agnel
agnel / Guardfile
Last active May 2, 2019
Setting up MiniTest, RSpec, Spring and Guardfile
View Guardfile
guard :minitest, spring: true, all_on_start: false do
# with Minitest::Unit
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
watch('config/routes.rb') { 'test' }
watch(%r{^app/models/(.*?)\.rb$}) do |matches|
"test/models/#{matches[1]}_test.rb"
end
watch('app/views/layouts/application.html.erb') do
@agnel
agnel / marray.rb
Created Feb 16, 2016 — forked from borowskiio/marray.rb
Produce PHP-style multidimensional array, e.g arr[1][2][3] = 'foobar'
View marray.rb
# Produce PHP-style multidimensional array.
#
# Example
#
# arr = Marray.new
#
# arr[1][2][3] = "foo"
# => "foo"
#
# arr[1][2][3]
@agnel
agnel / dabblet.css
Created Jul 6, 2012 — forked from daneden/dabblet.css
Search Suggestions
View dabblet.css
/*
Search Suggestions
Original design by Visual Idiot - http://dribbble.com/shots/377281-Search-Suggestions
*/
html {
min-height: 100%;
background: -webkit-linear-gradient(#dbddde, #b6babb);
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
You can’t perform that action at this time.