Skip to content

Instantly share code, notes, and snippets.

@ajgappmark
ajgappmark / ecc.py
Last active August 29, 2015 14:16 — forked from bellbind/ecc.py
# 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:
#!/usr/bin/env python
# encoding: utf8
from unicodedata import normalize
from string import ascii_letters
from random import randint
# Miller-Rabin probabilistic primality test (HAC 4.24)
# returns True if n is a prime number
# n is the number to be tested
# t is the security parameter
#!/usr/bin/env python
#Copyright (C) 2009 Nikitas Stamatopoulos
# Modified by endolith@gmail.com 2009-10
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
@ajgappmark
ajgappmark / ruby-dbus-and-banshee.rb
Last active September 12, 2015 12:23 — forked from markoa/ruby-dbus-and-banshee.rb
ruby-dbus play with Banshee
#!/usr/bin/env ruby
require 'dbus'
bus = DBus::SessionBus.instance
banshee_service = bus.service("org.bansheeproject.Banshee")
banshee = banshee_service.object("/org/bansheeproject/Banshee/PlayerEngine")
puts banshee.introspect
@ajgappmark
ajgappmark / n_queens.py
Created October 9, 2015 08:13 — forked from teh/n_queens.py
Solve n-queens with pycosat.
# Solve n-queens problem with picosat
import pycosat
import numpy
import itertools
def get_cnf(N):
cnf = []
# * convert to object because pycosat expects 'int's
# * add 1 because 0 is reserved in pycosat
@ajgappmark
ajgappmark / gist:afbca177d1087013873c
Created March 6, 2016 08:56 — forked from ebuckley/gist:1842461
python code to encode/decode morse code
morseAlphabet ={
"A" : ".-",
"B" : "-...",
"C" : "-.-.",
"D" : "-..",
"E" : ".",
"F" : "..-.",
"G" : "--.",
"H" : "....",
"I" : "..",
@ajgappmark
ajgappmark / mongoose-cheatsheet.md
Created February 25, 2016 01:26 — forked from subfuzion/mongoose-cheatsheet.md
mongoose cheatsheet

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');
@ajgappmark
ajgappmark / google_drive_util.py
Created December 5, 2016 14:30 — forked from macieksk/google_drive_util.py
A simple Python module to upload files to Google Drive file upload. Needs a file 'client_secrets.json' in the directory . The file can be obtained from https://console.developers.google.com/ -- under APIs&Auth/Credentials/Create Client ID for native application
## Simple Python module to upload files to Google Drive
# Needs a file 'client_secrets.json' in the directory
# The file can be obtained from https://console.developers.google.com/
# under APIs&Auth/Credentials/Create Client ID for native application
# To test usage:
# import google_drive_util
# google_drive_util.login()
# google_drive_util.test()
@ajgappmark
ajgappmark / gist:b285c1c2f159be1c8e3136b787c36ac3
Created December 23, 2016 13:41 — forked from learncodeacademy/gist:5f84705f2229f14d758d
Getting Started with Vagrant, SSH & Linux Server Administration
@ajgappmark
ajgappmark / pyscript.py
Created June 17, 2017 13:16 — forked from nhoffman/pyscript.py
Python script template
#!/usr/bin/env python
"""A simple python script template.
"""
from __future__ import print_function
import os
import sys
import argparse