Skip to content

Instantly share code, notes, and snippets.

View kapillamba4's full-sized avatar

Kapil Lamba kapillamba4

View GitHub Profile
#include <bits/stdc++.h>
typedef long long ll;
typedef std::tuple<ll, ll, ll> hash_t;
using namespace std;
class RollingHash {
public:
hash_t p = {13, 31, 19};
hash_t hashes = {0, 0, 0};
hash_t pows = {1, 1, 1};
/*
* Source: http://www.zedwood.com/article/cpp-sha256-function/
*/
#include <string>
#include <cstring>
#include <fstream>
#include <iostream>
#define SHA2_SHFR(x, n) (x >> n)
http://www.spoj.com/problems/AHOCUR
http://www.spoj.com/problems/FINDSR/
http://www.spoj.com/problems/FILRTEST/
http://www.spoj.com/problems/EPALIN/
http://www.spoj.com/problems/PUCMM223
http://www.spoj.com/problems/SPIRALGR/
http://www.spoj.com/problems/DCEPC706/
http://www.spoj.com/problems/MINNUM
http://www.spoj.com/problems/NITT2
@kapillamba4
kapillamba4 / async-foreach.js
Created July 8, 2018 19:02 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@kapillamba4
kapillamba4 / .vimrc
Last active September 3, 2018 18:59
set nocompatible
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'dracula/vim'
Plugin 'Valloric/YouCompleteMe'
call vundle#end() " required
@kapillamba4
kapillamba4 / postgres-cheatsheet.md
Created June 23, 2018 08:58 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
{
"name": "project",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "Kapil <[email protected]>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"lint": "eslint --ext .js,.vue src",
@kapillamba4
kapillamba4 / git.migrate
Created June 15, 2018 16:07 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@kapillamba4
kapillamba4 / what-forces-layout.md
Created May 3, 2018 13:44 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()