Skip to content

Instantly share code, notes, and snippets.

View ahlusar1989's full-sized avatar
🏀
Let's Go!

Saran Ahluwalia ahlusar1989

🏀
Let's Go!
View GitHub Profile
import java.util.function.Function;
import java.util.*;
import java.util.stream.*;
static <X, Y, Z> Map<X, Z> transform(Map<? extends X, ? extends Y> input,
Function<Y, Z> function) {
return input.keySet().stream()
.collect(Collectors.toMap(Function.identity(),
key -> function.apply(input.get(key))));
}
@ahlusar1989
ahlusar1989 / LRUCache.js
Created June 8, 2017 17:30 — forked from tpae/LRUCache.js
super simple JavaScript Implementation of LRUCache
// LRUCache.js - super simple JavaScript Implementation
// LRU stands for "Least Recently Used"
// https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
// -----------------------------------------
function LRUNode(key) {
this.key = key;
this.next = this.prev = null;
}
import { graphql } from 'react-apollo';
import { connect } from 'react-redux';
import { compose } from 'redux';
import {
change,
getFormSubmitErrors,
getFormValues,
reduxForm,
stopAsyncValidation,
@ahlusar1989
ahlusar1989 / router.js
Last active May 31, 2017 14:39
Router Custom
// Assuming you have a Component Dashboard, AnotherComponent, conditionally render based on props
const ROUTES = [
{
test: /\/another$/,
Component: Dashboard
},
{
test: /\/foo$/,
Component: Dashboard
},
{
"points": [
{
"x": 100,
"y": 100,
"oldx": 50,
"oldy": 150
},
{
"x": 200,
@ahlusar1989
ahlusar1989 / index.html
Created December 25, 2016 22:19
WebGL Man
<canvas id="canvas"></canvas>
<script src="http://webgl2fundamentals.org/webgl/resources/twgl-full.min.js"></script>
<script src="http://webgl2fundamentals.org/webgl/resources/webgl-lessons-helper.js"></script>
<script src="http://webgl2fundamentals.org/webgl/resources/3d-math.js"></script>
<script src="http://webgl2fundamentals.org/webgl/resources/flattened-primitives.js"></script>
@ahlusar1989
ahlusar1989 / index.html
Created December 25, 2016 17:53
OpenGL V1: Cube
<html>
<head>
<meta charset='utf-8'/>
</head>
<body style='margin:0px' onload='main()'>
<canvas id='your_canvas'
style='position: absolute; background-color: black;'></canvas>
</body>
</html>
/events?filter:collaborators_expire_at=2016-12-20&eventbrite_event_id=16160132391
app.use(function* (next) {
this.accountService = {};
for (const method in accountServiceClient) {
this.accountService[method] = function* () {
try {
return yield accountServiceClient[method].apply(null, arguments);
}
catch (e) {
requestLogger.error(e);
throw e;
@ahlusar1989
ahlusar1989 / int_additions.scala
Created September 4, 2016 14:22 — forked from herval/int_additions.scala
Manipulating maps with Monoids
object MindBlown extends App {
trait Monoid[A] {
def op(a1: A, a2: A): A
def zero: A
}
val intAddition = new Monoid[Int] {
override def op(a1: Int, a2: Int) = a1 + a2
override def zero = 0
}