Skip to content

Instantly share code, notes, and snippets.

View piyushchauhan2011's full-sized avatar
🔥
Working

Piyush Chauhan piyushchauhan2011

🔥
Working
View GitHub Profile
<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);
@piyushchauhan2011
piyushchauhan2011 / .vimrc
Last active December 1, 2016 05:26
My old mac vimrc
syntax on
set number
set autoindent
set expandtab
set shiftwidth=2
set softtabstop=2
set backspace=2
autocmd FileType python setlocal shiftwidth=2 tabstop=2
@piyushchauhan2011
piyushchauhan2011 / CSharpImageProcessing.cs
Created October 8, 2016 10:51
Image Processing algorithms with CSharp and Xamarin IDE on osx
using System;
using System.Drawing;
using System.IO;
namespace ImageProcessing
{
class MainClass
{
static void RunImage()
{

#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.