Skip to content

Instantly share code, notes, and snippets.

@pythonhacker
pythonhacker / ttldict.py
Created October 12, 2016 05:54
A Python dictionary type with keys having specific time to live (TTL)
import threading
import time
class TTLDict(dict):
""" A dictionary with keys having specific time to live """
def __init__(self, ttl=5):
self._ttl = ttl
# Internal key mapping keys of _d
# to times of access
@pythonhacker
pythonhacker / state.py
Last active June 22, 2022 07:01
Example of State Pattern in Python implementing showing a minimal State Machine
"""
The State design pattern.
In Python this is done dynamically by changing the __class__ attribute.
Author : Anand B Pillai <anandpillai@letterboxes.org>
License: Public Domain
Ref: http://harkablog.com/dynamic-state-machines.html
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 18, 2024 23:22
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@r-lyeh-archived
r-lyeh-archived / distance.cc
Created June 30, 2015 15:20
point-to-point distance algorithms survey
// point-to-point distance algorithms survey
// - rlyeh, public domain.
// possible output {
// manhattan_distance: 0.608632s. (result: 6)
// octagonal_distance: 0.651783s. (result: 3.52249)
// baptista_distance: 1.10458s. (result: 4.79492)
// baptista_distance_b: 1.09981s. (result: 4.64063)
// euclidean_distance: 1.25s. (result: 4.47214)
// euclidean_distance_fast: 1.03207s. (result: 4.5)
@JohnnyonFlame
JohnnyonFlame / raycurse.c
Last active April 6, 2022 20:23
A small raycasting prototype in C using the pdcurses library.
#include <stdio.h>
#include <curses.h>
#include <math.h>
float pos[2] = {(6 * 32) + 16.f, (6 * 32) + 16.f};
int dir = 0;
int is3d = 1;
char dungeon[17][17] =
{
var CELL_SIZE = 30,
MAP_SIZE = 20,
VISUAL_FRAME_COUNT = 10,
INFINITY = Infinity,
MAP = [
[2, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@asmaloney
asmaloney / Packaging_Example.sh
Last active September 14, 2023 14:45
This is an example of script to package up and create a DMG for a Mac OS X app. Details may be found here: http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
#!/bin/bash
# by Andy Maloney
# http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
# make sure we are in the correct dir when we double-click a .command file
dir=${0%/*}
if [ -d "$dir" ]; then
cd "$dir"
fi
@chaitanyagupta
chaitanyagupta / re-sign-ios-app.md
Last active October 20, 2023 08:28
How to re-sign an iOS app with another developer account

WARNING These steps are probably out dated and will not work.

To re-sign an iOS app with another developer account, ensure that the following are in place first.

  1. Distribution certificate of the other developer account
  2. A provisioning profile from the other developer account

Note that the Apple requires bundle IDs to be globally unique, even across accounts. So a bundle ID i.e. CFBundleIdentifier from one account can't be used in a different account, even though the team id/prefix would be different.

Ensure that the new distribution certificate is in your keychain and the new provisioning profile on your disk.

@reagent
reagent / .gitignore
Last active November 8, 2023 08:53
Curses Windowing Example
demo
*.swp
@XVilka
XVilka / TrueColour.md
Last active July 9, 2024 23:28
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!