Skip to content

Instantly share code, notes, and snippets.

View krrishd's full-sized avatar
🤯

Krish Dholakiya krrishd

🤯
View GitHub Profile
@krrishd
krrishd / objectToArray.js
Last active August 29, 2015 14:05
For when Angular is dumb and doesn't allow filtering of object maps.
$scope.objectToArray = (function() {
function convert(object) {
var keys = Object.keys(object);
var array = [];
keys.forEach(function(i) {
array.push(object[i]);
});
return array;
}
return function(object) {
@krrishd
krrishd / how-gocontribute-works.markdown
Last active November 7, 2015 00:22
How goContribute Works

How goContribute Works

EDIT (November 6th 2015): It has actually been barely functional, if that, since the GitHub API rate limits me, disallowing me from collecting the volume of repository data that this needs to be able to serve more than one query in 10 minutes. That being said, since this probably doesn't get visited, it might end up working for you as long as no one used it within 10 minutes of you.

goContribute is my entry to the Third Annual GitHub Data Challenge.

In essence, it takes two primary factors:

  • Your language of proficiency/preference
  • Your prioritization of
@krrishd
krrishd / http.js
Last active August 29, 2015 14:04
Simple XHR stuff. Probably already done in a neater way, but I was just experimenting and wanted simplicity of the highest degree. Essentially it's a combo of my post.js and get.js
/*
* By Krish Dholakiya (itskrish.co, git.io/krish)
* MIT Licensed.
*
* GET('http://example.com/index.html', function(response) {
* var responseFromServer = response;
* });
* POST('http://example.com', {'keyOne': 'valueOne', 'keyTwo': 'valueTwo'}, function(response) {
* var responseFromServer = response;
* });
@krrishd
krrishd / post.js
Last active August 29, 2015 14:04
For when I don't want to use jQuery or Angular to do a trivial POST HTTP request, neither do I care for raw XHR.
/*
* By Krish Dholakiya (itskrish.co, git.io/krish)
* MIT Licensed.
*
* POST('http://example.com', {'keyOne': 'valueOne', 'keyTwo': 'valueTwo'}, function(response) {
* var responseFromServer = response;
* });
*
* TODO: use some sort of promise rather than callbacks
*/
@krrishd
krrishd / get.js
Last active August 29, 2015 14:04
For when I don't want to use jQuery or Angular to make GET HTTP requests, neither do I care for raw XHR.
/*
* By Krish Dholakiya (itskrish.co, git.io/krish)
* MIT Licensed.
*
* GET('http://example.com/index.html', 'html') => returns DOM object
* GET('http://example.com/api.json', 'json') => returns parsed JSON object
*
* TODO: add more types (XML, etc)
* CDN url: https://cdn.rawgit.com/krrishd/f17247fcd6ff2335ca5f/raw//b5c2f93d8d3246dabe07cf9b6e73d71631f907b2
*/
@krrishd
krrishd / stringReverse.js
Created June 20, 2014 00:29
String.prototype.reverse() - A random snippet I made in the console
String.prototype.reverse = function() {
var reversed = [];
for(i=0; i< this.length; i++) {
reversed[this.length - i] = this[i];
}
var rev_str = "";
for(e=0;e<reversed.length;e++) {
rev_str += reversed[e];
}
rev_str = rev_str.replace('undefined', '');
@krrishd
krrishd / rss2json.js
Last active November 24, 2017 08:56
rss2json
/*
* Example Usage:
*
* $.get('http://cors.io/sprunge.us/ILRc', function(data) {
* window.xmlData = data;
* window.domParser = new DOMParser();
* window.parsedXML = domParser.parseFromString(window.xmlData, 'text/xml');
* window.jsonFeed = rss2json(parsedXML);
* });
*
@krrishd
krrishd / consoleSwag.js
Last active August 29, 2015 14:00
console.swag - a small library to help style your console outputs with css properties
console.swag = function(item, style) {
var cStyle =
"line-height: " + "35px; " +
"padding: " + "10px; " +
"border-radius: " + "3px; " +
"background-color: " + (style.bg || "rgba(0,0,0,.8)") + "; " +
"color: " + (style.color || "white") + "; " +
"font-size: " + (style.fSize || "1.2em") + "; " +
"font: " + (style.font || "sans-serif") + "; " +
"text-shadow: " + "1px 1px 3px " + (style.tShadow || "rgba(0,0,0,1)");
-----BEGIN PGP MESSAGE-----
Version: Keybase OpenPGP v0.1.1
Comment: https://keybase.io/crypto
wcFMA7Bm20dxr6FUARAAjlfHIUZ1SBwj08OJgYocIetmxzHMkqhmg2rOyVRGihQD
B+r6TgY2sfFE94LUYuJsgyDKHdol99wiuw4X/mKsaOZOomQNy2bA/cwfPjvLQBbH
twkhFQDHmcF7C4BfW7/uVGyPblqy+rgyozR5kRzMf1lajuxCrPTikueJ7dBjSpfi
4rP24SAn6cR5z1nxNHw82Q6uKnUlg6TfKW3Cn1nOAAs/nn4ohDDxSoGXgNQ2r6pM
MFgfHerYm7jRR1FTRkQdPJrWStrsqHU0NiHerTrqFCNbRKvuhsnr8QCTiAqfjeTR
cZy96HDmXhk/E2n8rK66o2x5YC2lb4bL/s622lPQ9iOrXd/aQ2FYgBB79BjmVfA4
@krrishd
krrishd / keybase.md
Created March 28, 2014 22:23
Keybase Verification

Keybase proof

I hereby claim:

  • I am krrishd on github.
  • I am krrishd (https://keybase.io/krrishd) on keybase.
  • I have a public key whose fingerprint is 9BBF 10C1 0D9C 89AD C0CA 7062 8936 5571 C6F8 2966

To claim this, I am signing this object: