Skip to content

Instantly share code, notes, and snippets.

View satyajeetkrjha's full-sized avatar
💭
Curious

Satyajeet Kumar Jha satyajeetkrjha

💭
Curious
  • New York ,USA
View GitHub Profile
@satyajeetkrjha
satyajeetkrjha / aecho.py
Created October 17, 2023 03:26 — forked from dabeaz/aecho.py
Live-coded examples from my PyCon Brasil 2015 Keynote
# aecho.py
from socket import *
import asyncio
loop = asyncio.get_event_loop()
async def echo_server(address):
sock = socket(AF_INET, SOCK_STREAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
@satyajeetkrjha
satyajeetkrjha / aproducer.py
Created October 14, 2023 02:56 — forked from dabeaz/aproducer.py
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@satyajeetkrjha
satyajeetkrjha / ecc.py
Created October 7, 2022 00:17 — forked from bellbind/ecc.py
[python]basics of elliptic curve cryptography
# Basics of Elliptic Curve Cryptography implementation on Python
import collections
def inv(n, q):
"""div on PN modulo a/b mod q as a * inv(b, q) mod q
>>> assert n * inv(n, q) % q == 1
"""
for i in range(q):
if (n * i) % q == 1:
@satyajeetkrjha
satyajeetkrjha / card.cpp
Created June 5, 2022 01:14 — forked from michaelsafyan/card.cpp
C++ Playing Cards
#include "card.h"
#include <sstream>
namespace playing_cards {
Card::Card(int value, Suit suit) : value_(value), suit_(suit) {}
Card::Card(const Card& o) : value_(o.value_), suit_(o.suit_) {}
Card::~Card() {}
@satyajeetkrjha
satyajeetkrjha / fft.cpp
Created February 17, 2022 16:13 — forked from hsiuhsiu/fft.cpp
[FFT] Fast Fourier Transform in c++ and basic applications #Algorithm #ACM
#include <complex>
#include <iostream>
#include <valarray>
#include <vector>
using namespace std;
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

@satyajeetkrjha
satyajeetkrjha / slim-redux.js
Created March 9, 2019 14:53 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {