Skip to content

Instantly share code, notes, and snippets.

@daniman
daniman / schema_validation_result_to_github_comment.sh
Last active April 6, 2021 05:20
A shell script that takes the output of `apollo service:check` and posts it as a comment on your GitHub PRs. This is useful in cases where you can't install the Apollo GitHub app or want increased visibility into the results of schema validation in your pull requests.
#!/usr/bin/env bash
# This guide walks through posting the output of `apollo service:check` to a comment on your GitHub PRs,
# using the GitHub GraphQL API (v4) and the Apollo CLI.
#
# This guide primarily covers how to post a comment to GitHub from the command line using `curl`. If you
# are using another service provider for your code management, you will need to read their API docs
# on how to authenticate and post a comment to pull requests in their system.
#
# Getting a result from Apollo schema validation in markdown format is as easy as running:
@daniman
daniman / pset4-side-channel-attack.py
Last active April 12, 2016 03:05
Code to conduct the side channel attack for 6.857's pset 3 problem 2b.
import requests
import gmpy2
import sys
import math
import json
from math import sqrt
n = 1024
R = 2**(n//2)
import salsa20
# import the distinguisher function and B and r paramaters from my_salsa
# B: number of 64-byte blocks to generate
# r: number of Salsa20 rounds
from distinguish import distinguish, B, r, random_dist
import os
from struct import pack, unpack
import numpy as np
import matplotlib.pyplot as plt
import time
@daniman
daniman / pset1-secret-message.py
Last active April 11, 2016 21:44
Code to decrypt the secret message in 6.857's first pset.
import ffield
F = ffield.FField(8) # 0 - 255
c1 = map(lambda x: int(x, 16), "50 90 5f 98 db 20 fb 0a 7a 1c 8b 71 14 f7 e4 b1 b2 8b 63 a6 f7 3d 8a 46 e2 c6 a7 51 1f 97 7e fe 71 b8 36 3c cd 20 89 df".split(' '))
c2 = map(lambda x: int(x, 16), "2a 5a fe 23 db bb 9e ba 5d 42 3b c8 f9 0b 97 18 1f b5 06 7e cf 18 d2 0b d5 f6 e5 75 d4 7f ea 65 27 b8 9a d4 ca cd de 37".split(' '))
c3 = map(lambda x: int(x, 16), "b5 2f 00 98 89 85 fb 8d d5 00 d1 df 26 33 91 ce d5 bb 9a 61 42 6a c9 21 58 57 a7 7b 47 57 55 21 f8 9b d9 d3 ca 41 de 1c".split(' '))
c4 = map(lambda x: int(x, 16), "11 4d 2a 70 2b 02 f3 48 d9 cc 7e c8 97 c4 7b f6 73 b5 b5 0b 69 65 ff 47 d5 c3 a7 7d 61 5b a6 a3 bb b8 8f d4 71 da 84 cb".split(' '))
c5 = map(lambda x: int(x, 16), "fd 5e be ea 45 3d 9e 48 a9 b6 f2 c2 26 f4 7f ea 1f e8 ba 79 7e 73 88 38 58 e3 a7 7b b5 4c 32 bc 91 85 4a d3 6b b3 0d b5".split(' '))
c6 = map(lambda x: int(x, 16), "50 2f b4 ed 6e 3d 63 9e 7a 1c a4 71 f9 f0 52 ce 0f 35 e5 02 2c 18 93 f7 f3 9c a7 7d b5 97 4d 00 7a 55 d9 d4 18 41 82 c6".