This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def invMod(x, p): | |
return pow(x, p-2, p) | |
def addECC(x1,y1,x2,y2,a,b,p): | |
s = (invMod(x2-x1, p)*(y2-y1)) % p | |
if ((x1 - x2) % p == 0) and ((y1-y2) % p == 0): | |
s=(invMod(2*y1, p)*(3*x1*x1 + a)) % p | |
x3 = (s*s -x1 -x2) %p | |
y3 = (s*(x1-x3) -y1) % p | |
return x3,y3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Databinding example</h1> | |
<p>What is your name?</p> | |
<input type="text" ng-model="name"/> | |
<p ng-if="!!name">Hello {{name}}.</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, | |
// Match everything outside of normal chars and " (quote character) | |
NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g; | |
function encodeEntities(value) { | |
return value. | |
replace(/&/g, '&'). | |
replace(SURROGATE_PAIR_REGEXP, function(value) { | |
var hi = value.charCodeAt(0); | |
var low = value.charCodeAt(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p=2602970321841479 | |
g=2 | |
x=2064002103016912 | |
A=1376951019743626 | |
K=1443056703658992 | |
K_inv1 = power_mod(K, p-2, p) | |
K_inv2 = xgcd(p, K)[2] % p | |
K_inv3 = power_mod(A, p - 1- x, p) | |
print K_inv1* K % p | |
print K_inv2 * K % p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def safe_prime(bits): | |
found_safe_prime = False | |
ohshit = 0 | |
while (not found_safe_prime and ohshit < 1000000): | |
ohshit += 1 | |
q = 2*randint(2**(bits-1), 2**(bits))-1 | |
if power_mod(2,2*q, 2*q + 1) != 1: | |
continue | |
if not q.is_prime(False): | |
continue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random,copy | |
W1 = [[random.random()*.2, random.random()*.2, random.random()*.2] for i in range(3)] | |
W2 = [[random.random()*.2, random.random()*.2, random.random()*.2] for i in range(3)] | |
#an empty 3x3 matrix | |
def activation(a_float): | |
return round(a_float) | |
def apply_input(input_in, W): | |
input = copy.copy(input_in) | |
input.append(-1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def adj(A): | |
labels = [[-1 for i in A[0]] for j in A] | |
next_label = 0 | |
linked = {} | |
for row in range(len(A)): | |
for col in range(len(A[0])): | |
nbrs = [] | |
not_nbrs=[] | |
if row >= 1: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function xorIt($charOne, $charTwo) | |
{ | |
return $charOne ^ $charTwo; | |
} | |
function asciiValue($char) | |
{ | |
return ord($char); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"); | |
var express = require('express'); | |
var bodyParser = require('body-parser'); | |
console.log("Started server"); | |
var aRouter = express(); | |
var myServer = http.createServer(aRouter); | |
aRouter.use(bodyParser.json()); | |
aRouter.use(bodyParser.urlencoded({ extended: true })); | |
aRouter.use(express.static(__dirname + "/client")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"); | |
var express = require('express'); | |
console.log("Started server"); | |
var aRouter = express(); | |
var myServer = http.createServer(aRouter); | |
aRouter.get('/users/:userid', function(req, res){ | |
res.send("You asked for data from User "+req.params.userid); | |
}); |