Skip to content

Instantly share code, notes, and snippets.

View piyushchauhan2011's full-sized avatar
🔥
Working

Piyush Chauhan piyushchauhan2011

🔥
Working
View GitHub Profile
package astar
import "container/heap"
type NodeQueue []Node
func NewNodeQueue() NodeQueue {
return make(NodeQueue, 0, 1000)
}
@piyushchauhan2011
piyushchauhan2011 / combinators.js
Created February 26, 2018 22:26 — forked from Avaq/combinators.js
Common combinators in JavaScript
const I = x => x;
const K = x => y => x;
const A = f => x => f(x);
const T = x => f => f(x);
const W = f => x => f(x)(x);
const C = f => y => x => f(x)(y);
const B = f => g => x => f(g(x));
const S = f => g => x => f(x)(g(x));
const P = f => g => x => y => f(g(x))(g(y));
const Y = f => (g => g(g))(g => f(x => g(g)(x)));
<x-vue yell>World</x-vue>
@piyushchauhan2011
piyushchauhan2011 / animatedScrollTo.js
Created January 15, 2018 04:06 — forked from joshbeckman/animatedScrollTo.js
ScrollTo animation using pure javascript and no jquery
document.getElementsByTagName('button')[0].onclick = function () {
scrollTo(document.body, 0, 1250);
}
function scrollTo(element, to, duration) {
var start = element.scrollTop,
change = to - start,
currentTime = 0,
increment = 20;
@piyushchauhan2011
piyushchauhan2011 / example.js
Created August 8, 2017 19:30 — forked from Gozala/example.js
Workaround for lack of "tail call optimization" in JS
// Lack of tail call optimization in JS
var sum = function(x, y) {
return y > 0 ? sum(x + 1, y - 1) :
y < 0 ? sum(x - 1, y + 1) :
x
}
sum(20, 100000) // => RangeError: Maximum call stack size exceeded
// Using workaround
onScroll(ev){
const yOffset = window.window.pageYOffset;
for(let elm of myElement){
elm.isVisible = yOffset >= elm.rect.top && yOffset <= (elm.rect.top + elm.rect.height);
}
}
import { EventEmitter } from 'angular2/core.js';
/**
* Visibility Observer leveraging new IntersectionObserver API
* Idea from: https://github.com/WICG/IntersectionObserver
*/
export class VisibilityObserver {
onVisible = new EventEmitter();
export class VisibilityObserver {
constructor(element, callback) {
this.callback = callback;
if(window.IntersectionObserver) {
this.observer = new IntersectionObserver(
::this.processChanges, { threshold: [0.5] });
this.observer.observe(element);
var element = document.getElementById("panda");
function checkVisibility() {
var bounds = element.getBoundingClientRect(),
visible = bounds.width && bounds.height;
if (visible) {
doMySizeMagic();
} else {
setTimeout(checkVisibility, 100);

#Haskell, Stack and Intellij IDEA IDE setup tutorial how to get started Upon completion you will have a sane, productive Haskell environment adhering to best practices.

Basics

  • Haskell is a programming language.
  • Stack is tool for Haskell projects. (similar tools for other languages include Maven, Gradle, npm, RubyGems etc)
  • Intellij IDEA IDE is a popular IDE.

Download and extract Stack

Don't install Haskell, Stack, Cabal or any other Haskell tool or library using your OS package manager or using Cabal.