Skip to content

Instantly share code, notes, and snippets.

View AndyNovo's full-sized avatar

Andy Novocin AndyNovo

View GitHub Profile
<?php
$salt = openssl_random_pseudo_bytes(40, $was_strong);
if (!$was_strong){
die("Oh no...");
}
echo bin2hex($salt);
?>
import random
import urllib2
f=file('quotes.txt','r')
quotes = [l.strip() for l in f]
f.close()
quotes = [w + chr(random.randint(ord('A'),ord('Z'))) if len(w) % 2 == 1 else w for w in quotes]
res = urllib2.urlopen('https://raw.githubusercontent.com/first20hours/google-10000-english/master/google-10000-english-usa.txt')
words = res.read().split()
<?php
session_start();
if (!isset($_SESSION["bananas"])){
$_SESSION["bananas"] = 1;
$_SESSION["recent_bunch"] = 1;
} else {
$this_bunch = rand(1,5);
$_SESSION["bananas"] += $this_bunch;
import hashlib
def superHash(secret, salt, iterations):
result = "0"
for i in range(iterations):
result = hashlib.sha256(result + secret + salt).hexdigest()
return result
print superHash("pass123","saltybananas", 1234567)
<?php
function generate_rack($n){
$tileBag = "AAAAAAAAABBCCDDDDEEEEEEEEEEEEFFGGGHHIIIIIIIIIJKLLLLMMNNNNNNOOOOOOOOPPQRRRRRRSSSSTTTTTTUUUUVVWWXYYZ";
$rack_letters = substr(str_shuffle($tileBag), 0, $n);
$temp = str_split($rack_letters);
sort($temp);
return implode($temp);
};
<?php
$myrack = "AAABNN";
$racks = [];
for($i = 0; $i < pow(2, strlen($myrack)); $i++){
$ans = "";
for($j = 0; $j < strlen($myrack); $j++){
//if the jth digit of i is 1 then include letter
if (($i >> $j) % 2) {
$ans .= $myrack[$j];
import hashlib, cProfile
f=file('dictionary.txt','r')
words = [word.strip() for word in f]
f.close()
secretHash=hashlib.sha512("banana").hexdigest()
def checkDictionary(secret):
return [word for word in words if hashlib.sha512(word).hexdigest() == secret]
<?php
//this is the basic way of getting a database handler from PDO, PHP's built in quasi-ORM
$dbhandle = new PDO("sqlite:scrabble.sqlite") or die("Failed to open DB");
if (!$dbhandle) die ($error);
//this is a sample query which gets some data, the order by part shuffles the results
//the limit 0, 10 takes the first 10 results.
// you might want to consider taking more results, implementing "pagination",
// ordering by rank, etc.
#include <iostream>
#include <stdlib.h>
#include <cassert>
using namespace std;
struct Cat {
int lives;
int id;
Cat(int in_id){
lives = 9;
<!DOCTYPE html>
<html>
<head>
<script src="http://polygit.org/components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="ninja.html">
</head>
<body>
<ninja-killa></ninja-killa>
<ninja-killa></ninja-killa>
<ninja-killa></ninja-killa>