Skip to content

Instantly share code, notes, and snippets.

View parvezmrobin's full-sized avatar

Parvez M Robin parvezmrobin

View GitHub Profile
@parvezmrobin
parvezmrobin / bitarray.py
Last active November 25, 2022 03:18
Simply and efficient python implementation of bit-array
from __future__ import annotations
class BitArray(bytearray):
mask_for = [2**i for i in range(8)]
inverse_mask_for = [256 - 2**i for i in range(8)]
valid_values = (0, 1)
def __init__(self, source, *args, **kwargs) -> None:
if isinstance(source, int):
source = source/8
@parvezmrobin
parvezmrobin / access-github-graphql-api.py
Created October 22, 2021 17:56
Access GitHub GraphQL API From Python Using GQL
from gql import gql
def create_graphql_query(repo: str, commit_id: str):
"""
Create a GraphQL query
Documentation: https://docs.github.com/en/graphql
"""
return gql(f'''query {{
search(
/**
* Parvez M Robin
* [email protected]
* Date: Apr 04, 2019
*/
import React from 'react';
import CreatableSelect from 'react-select/creatable';
import PropTypes from 'prop-types';
@parvezmrobin
parvezmrobin / intercepting http response.js
Last active September 18, 2020 15:08
Intercept / Log anything you write to your express response from anywhere from any file. Just add the following code to your `app.js`.
app.use((request, response, next) => {
// wheather `req.write` / `req.send` / `req.json`, express calls underlying `socket.write`
// thus intercepting `socket.write`
const backup = response.socket.write;
let code;
function newWriter(...args) {
for (const arg of args) {
if (typeof arg === 'string') {
import React, {createContext, useState} from 'react';
import firebase from '../firebase';
export const ChatContext = createContext();
const ChatContextProvider = (props) => {
//Firebase settings
const DB = firebase.firestore();
const chatRef = DB.collection("chats");
console.log("1");
setTimeout(() => {
console.log("2");
setTimeout(() => {
console.log("3");
}, 0);
console.log("4");
}, 0);
City Gender Income Illness
Dallas Male 40367 No
Dallas Female 41524 Yes
Dallas Male 46373 Yes
New York City Male 98096 No
New York City Female 102089 No
New York City Female 100662 No
New York City Male 117263 No
Dallas Male 56645 Yes
const _ = require('lodash');
const parser = s => {
const parts = s.split(':');
return parts[0] * 60 + +parts[1]
};
const doesOverlap = (slot, booking) => {
if (!slot || !booking) {
return false;
package main
func main() {
var marks = map[string]int{
"sakeef": 95,
"oishie": 82,
"robin": 61,
"mim": 43,
}
println(marks["sakeef"], marks["oishie"], marks["robin"], marks["mim"])
package main
func main() {
var marks = map[string]int{}
marks["sakeef"] = 95
marks["oishie"] = 82
marks["robin"] = 61
marks["mim"] = 43
delete(marks, "sakeef")