Skip to content

Instantly share code, notes, and snippets.

View antiface's full-sized avatar

A.G. antiface

View GitHub Profile
import hashlib as hasher
import datetime as date
# Define what a Snakecoin block is
class Block:
def __init__(self, index, timestamp, data, previous_hash):
self.index = index
self.timestamp = timestamp
self.data = data
self.previous_hash = previous_hash
@prophetgoddess
prophetgoddess / pixelsort.py
Last active November 24, 2023 11:39
Python pixel sorting.
# The MIT License (MIT)
# Copyright (c) 2014 Lycaon (lycaon.me)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@antiface
antiface / pets.py
Last active August 29, 2015 14:06 — forked from jhamrick/pets.py
class Pet(object):
def __init__(self, name, species):
self.name = name
self.species = species
def getName(self):
return self.name
def getSpecies(self):
{
"created_at": "Fri Sep 19 12:20:23 +0000 2014",
"id": 512939257850511360,
"id_str": "512939257850511360",
"text": "\"I never used the Blackberry again.\" https://t.co/CYsbbBDtOh",
"source": "<a href=\"http://radio3.io/\" rel=\"nofollow\">radio3.io</a>",
"truncated": false,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
@scripting
scripting / gist:24a97569e8103799d942
Created September 19, 2014 12:50
An example of the metadata Twitter keeps about an individual tweet.
{
"created_at": "Fri Sep 19 12:20:23 +0000 2014",
"id": 512939257850511360,
"id_str": "512939257850511360",
"text": "\"I never used the Blackberry again.\" https://t.co/CYsbbBDtOh",
"source": "<a href=\"http://radio3.io/\" rel=\"nofollow\">radio3.io</a>",
"truncated": false,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
@scripting
scripting / gist:828144d4a9dda203164c
Created August 19, 2014 22:22
A routine that updates a Facebook post.
function fbUpdatePost (idPost, thePostText) {
FB.api (idPost, "post", {message: thePostText}, function (response) {
console.log ("fbUpdatePost: response == " + JSON.stringify (response, undefined, 4));
});
}
<html>
<head>
<title>Wordnik demo from JavaScript</title>
<script src="http://static.smallpicture.com/bootstrap/js/jquery-1.9.1.min.js"></script>
<script>
var baseUrl = "http://api.wordnik.com/v4/word.json/";
var apiKey = "a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5"; //demo key from developer.wordnik.com
function getSynonyms (theWord, callback) {
var url = baseUrl + theWord + "/relatedWords?useCanonical=true&relationshipTypes=synonym&limitPerRelationshipType=100&api_key=" + apiKey;
var jxhr = $.ajax ({
@kylebgorman
kylebgorman / wagnerfischerpp.py
Last active March 3, 2023 17:27
Wagner-Fischer Levenshtein distance, now with a means to generate all possible optimal alignments.
# Copyright (c) 2013-2022 Kyle Gorman
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
@marinhoarthur
marinhoarthur / Algorithm.py
Last active May 5, 2022 12:39
A simple genetic algorithm written in Python fully based on an article by Lee Jacobson from his blog theprojectspot.com
from Population import Population
from Individual import Individual
from random import random, randint
class Algorithm():
#Constants
Uniform_rate = 0.5
Mutation_rate = 0.015
Tournament_size = 5
@danilobellini
danilobellini / reson.py
Last active March 18, 2017 18:20
Trying to do a time-variant Butterworth filter using SciPy and AudioLazy. Also, a faster time-variant resonator (AudioLazy) for comparison. Both examples includes instantaneous frequency measurements (from Discrete Hilbert Transform).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Mon Sep 09 23:06:21 2013
# @author: Danilo J. S. Bellini
"""
AudioLazy time-variant resonator helping instantaneous frequency measurements.
"""
from __future__ import print_function
from audiolazy import (sHz, sinusoid, gauss_noise, line, z, inf, resonator,