Skip to content

Instantly share code, notes, and snippets.

View codemonkey85's full-sized avatar

Michael Bond codemonkey85

View GitHub Profile
@codemonkey85
codemonkey85 / objSerialization.cpp
Last active November 26, 2022 04:26
An example of how to serialize / deserialize a C++ struct to and from a disk file.
struct OBJECT{ // The object to be serialized / deserialized
public:
// Members are serialized / deserialized in the order they are declared. Can use bitpacking as well.
DATATYPE member1;
DATATYPE member2;
DATATYPE member3;
DATATYPE member4;
};
void write(const std::string& file_name, OBJECT& data) // Writes the given OBJECT data to the given file name.
import struct
import math
import os
import sys
if sys.version > '3':
buffer = memoryview
def getWord(b, k, n=4):
return sum(list(map(lambda c: b[k+c]<<(c*8),range(n))))
@codemonkey85
codemonkey85 / PKMDS_Mem_Map.cs
Last active August 29, 2015 14:01
Using MemoryMappedFile and DragDrop to swap Pokémon between applications
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.MemoryMappedFiles;
using System.IO;
package main
import (
"bytes"
"encoding/binary"
"flag"
"fmt"
"io"
"io/ioutil"
"math"
@codemonkey85
codemonkey85 / Google Voicemail
Created July 17, 2014 19:41
Google Script – Save Voice Mail as MP3 in Google Drive
/* Written by Amit Agarwal amit@labnol.org */
/* Tutorial: http://www.labnol.org/?p=25153 */
var folder, folder_name = "Google Voice";
var archive, gmail_label = "MP3";
/* Find Google Voice messages in Gmail */
var filter = "from:voice-noreply@google.com -label:" + gmail_label;
var threads = GmailApp.search(filter, 0, 10);
import java.util.Map;
import java.util.Comparator;
import java.util.Collections;
int index = 0;
// sprite sheet
PImage pokemon;
// current pokemon sprite
PImage current;
// current pie chart
--taken from http://benguild.com/2012/04/11/how-to-import-tasks-to-do-items-into-ios-reminders/#comment-1346894559
--set theFileContents to (read file "Users:n8henrie:Desktop:Reminders.txt") -- Change this to the path to your downloaded text file with your tasks in it! (Note the : instead of a / between folders) Or, just name them Reminders.txt and put them in your downloads folder
--set theLines to paragraphs of theFileContents
set theLines to {"task name 1", "task name 2"}
repeat with eachLine in theLines
tell application "Reminders"
set mylist to list "Your List Name"
tell mylist
make new reminder at end with properties {name:eachLine, due date:date "7/10/2014 3:00 PM"}
@codemonkey85
codemonkey85 / gist:4633acd399112c9ad58c
Created April 22, 2015 17:38
Flawed shuffle code - what is wrong with this?
internal static byte[,] shuffle_order = new byte[,]
{{0,1,2,3},{0,1,3,2},{0,2,1,3},{0,2,3,1},{0,3,1,2},{0,3,2,1},{1,0,2,3},{1,0,3,2},
{1,2,0,3},{1,2,3,0},{1,3,0,2},{1,3,2,0},{2,0,1,3},{2,0,3,1},{2,1,0,3},{2,1,3,0},{2,3,0,1},
{2,3,1,0},{3,0,1,2},{3,0,2,1},{3,1,0,2},{3,1,2,0},{3,2,0,1},{3,2,1,0}};
internal static byte[,] inv_shuffle_order = new byte[,]
{{0,1,2,3},{0,1,3,2},{0,2,1,3},{0,3,1,2},{0,2,3,1},{0,3,2,1},{1,0,2,3},{1,0,3,2},{2,0,1,3},
{3,0,1,2},{2,0,3,1},{3,0,2,1},{1,2,0,3},{1,3,0,2},{2,1,0,3},{3,1,0,2},{2,3,0,1},{3,2,0,1},
{1,2,3,0},{1,3,2,0},{2,1,3,0},{3,1,2,0},{2,3,1,0},{3,2,1,0}};
#!/usr/bin/env ruby
# Based on everwatch.rb by Brett Terpstra, 2011, a 2013 update by spetschu, and a 2014 update by regedor
# Write in Markdown in Evernote and Backup Markdown files in Dropbox
# Change the next two lines with your account number and the path to your backup folder
watch_folder = File.expand_path("/Users/USERNAME/Library/Containers/com.evernote.Evernote/Data/Library/Application Support/com.evernote.Evernote/accounts/www.evernote.com/YOUR-ACCOUNT-NUMBER/content/")
mark_folder = "~/Dropbox/Evernotes/"
counter = 0
@codemonkey85
codemonkey85 / Pythonista-Trello-Tasks.py
Last active March 30, 2016 01:48
A python script, meant to run on iOS via Pythonista and from Workflow, to get a list of all of the Trello cards assigned to you with the provided app key and token, as well as the provided board ID and username.
# coding: utf-8
# Workflow script available here: http://bit.ly/1PEvd1S
import platform
if platform.system() == 'Darwin':
if platform.machine().startswith('iP'):
import console
import clipboard
import webbrowser