Skip to content

Instantly share code, notes, and snippets.

🤔

JHSN Chrstm

🤔
Block or report user

Report or block Chrstm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Chrstm
Chrstm / elasticsearch_array.py
Last active Apr 12, 2019
How to use array of general datatype in elasticsearch-dsl-py?
View elasticsearch_array.py
from elasticsearch_dsl import DocType, Index, Integer, Text, Q
from elasticsearch_dsl.connections import connections
import time
post_index = Index('test_post')
class PostDoc(DocType):
author_id = Integer() # List[Integer]
@Chrstm
Chrstm / mt_recover.py
Created Dec 2, 2018
recover python random state (Mersenne Twister)
View mt_recover.py
import random
class MT19937Recover:
"""Reverses the Mersenne Twister based on 624 observed outputs.
The internal state of a Mersenne Twister can be recovered by observing
624 generated outputs of it. However, if those are not directly
observed following a twist, another output is required to restore the
internal index.
See also https://en.wikipedia.org/wiki/Mersenne_Twister#Pseudocode .
@Chrstm
Chrstm / rsa_lsb_oracle_attack.py
Last active Aug 18, 2019
RSA LSB Oracle Attack
View rsa_lsb_oracle_attack.py
def lsb_oracle_attack(n, e, c, lsb_oracle):
'''
RSA LSB Oracle Attack
:param lsb_oracle: lsb_oracle(x) == pow(x, d, n) % 2
:return: m or None if not found
'''
l, r, k2 = 0, 1, 1
while n * l // k2 + 1 < n * r // k2:
m = l + r
l <<= 1
@Chrstm
Chrstm / clean_up_codeforces_problemset.js
Created Feb 15, 2018
Clear easy problems of Codeforces Problemset
View clean_up_codeforces_problemset.js
// ==UserScript==
// @name Clean up Codeforces problemset
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Clear easy problems of Codeforces Problemset
// @author JHSN
// @match http://codeforces.com/problemset
// @match http://codeforces.com/problemset/
// @match http://codeforces.com/problemset/page/*
// @grant none
You can’t perform that action at this time.