Skip to content

Instantly share code, notes, and snippets.

View Shridhad's full-sized avatar
:octocat:

Shridhar Deshmukh Shridhad

:octocat:
View GitHub Profile
@Shridhad
Shridhad / groupby.js
Last active April 17, 2019 11:06
groupBy array
/**
* PROBLEM: Group an array of objects by a common key value.
* For example - Group cars by color.
*
* Following method also handle if the value is an array.
**/
const groupBy = key => array => {
const addEle = (k, v, o) => o[k] = (o[k] || []).concat(v);
return array.reduce((output, obj) => {
@Shridhad
Shridhad / AndroidStyleTextInput
Created March 31, 2013 18:05
CSS for android-style text input
hr.android-style-text-input {
height: 10px;
border-color: #fff;
border-style: solid;
border-top-width: 0px;
}
@Shridhad
Shridhad / defaultPreventer
Last active January 3, 2016 00:29
Stop repeating event.preventDefult();
$(document).ready(function() {
function defaultPreventer(handler) {
return function(event) {
alert("preventing default");
event.preventDefault();
handler.apply(this, arguments);
}
};
function clickHandler(event) {
alert("Click Handler");
body {
background-color: green;
height: 1000px;
margin: 2px;
padding: 0px;
border: 1px solid red;
}
* {
box-sizing: border-box;
}
hr.android-style-text-input {
height: 10px;
border-color: #00FF00;
border-style: solid;
border-width: 2px;
border-top-width: 0px;
margin-top: -10px;
* {
box-sizing: border-box;
}
hr.android-style-text-input {
height: 10px;
border-color: #00FF00;
border-style: solid;
border-width: 2px;
border-top-width: 0px;
margin-top: -10px;
@Shridhad
Shridhad / index.html
Created March 27, 2013 16:06
A CodePen by Adam. Tear-able Cloth - Javascript cloth simulation.
<canvas id = "c" > </canvas>
<p>
Tear the cloth with your mouse.<br><br>
Right click and drag to cut the cloth.<br><br>
Reduce physics_accuracy if it's laggy, increase it for a better effect.
</p>
/*
Copyright (c) 2011 Damien Antipa, http://www.nethead.at/, http://damien.antipa.at
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@Shridhad
Shridhad / codepen_logger.js
Created October 24, 2015 13:22
Console Logger for Codepen
console.log = function(str) {
var html = "<div class='.log'>" + str + "</div><br />";
document.querySelector("body").innerHTML += html;
}
@Shridhad
Shridhad / dabblet.css
Created December 13, 2012 15:21
Untitled
.container {
width: 400px;
height: 500px;
background: #234234;
display: table;
margin: 10px auto;
transform: rotate(90deg);
}
.container div {
border: 1px solid red;