Skip to content

Instantly share code, notes, and snippets.

from concurrent.futures import ProcessPoolExecutor, wait
from multiprocessing import Manager
from argparse import ArgumentParser
from concurrent.futures import Future
from typing import List, Dict
import fastparquet
import os
import pandas as pd
import numpy as np
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "dumb_agent",
"type": "python",
"request": "launch",
@sikanrong
sikanrong / universal-interceptor.ts
Created April 26, 2020 18:10
An Angular Universal interceptor which handles HTTP requests to relative routes to local files. Fixes prerender errors for Angular applications which do this.
import {Injectable, Inject, Optional} from '@angular/core';
import {
HttpInterceptor,
HttpHandler,
HttpRequest,
HttpHeaders,
HttpResponse,
HttpErrorResponse
} from '@angular/common/http';
import {Request} from 'express';
@sikanrong
sikanrong / nvimrc.vim
Created January 25, 2020 23:47
My Neovim Configuration
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
iex(14)> ring = HashRing.new() |> HashRing.add_node(:a) |> HashRing.add_node(:b)
#<Ring[:a, :b]>
iex(15)> [:foo, :bar, :baz, :flop] |> Enum.each(fn(k) -> IO.puts(HashRing.key_to_node(ring, k)) end)
b
b
b
a
:ok
iex(16)> ring = HashRing.add_node(ring, :c)
#<Ring[:a, :c, :b]>
//https://www.geeksforgeeks.org/check-if-a-given-number-is-sparse-or-not/
/*
* check_sparse.c
*
* Created on: Aug 2, 2018
* Author: sikanrong
*/
//https://www.geeksforgeeks.org/rotate-bits-of-an-integer/
/*
* rotate_bits.c
*
* Created on: Aug 2, 2018
* Author: sikanrong
*/
#include <stdio.h>
//https://www.geeksforgeeks.org/calculate-square-of-a-number-without-using-and-pow/
//Calculate a number's square without using /, *, or pow().
#include <stdio.h>
int main(){
int n;
printf("Please enter an integer: ");
//Smallest power of 2 greater than or equal to n
//https://www.geeksforgeeks.org/smallest-power-of-2-greater-than-or-equal-to-n/
var smallestPowerOfTwo = function(x){
var bitPlaces = 0;
while(x){
bitPlaces++;
x >>= 1;
}
return 1 << bitPlaces;
//Bitwise programming interview question
var isPowerOfFour = function(x){
var bitIdx = 0;
var currentIdx = 0;
var bitCount = 0;
while(x){
if(x & 1){
bitCount++;