Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Bakita JoshuaJB

View GitHub Profile
@JoshuaJB
JoshuaJB / main.c
Created Jun 3, 2015
Pebble Accelerometer Variance Demo Scaffold
View main.c
#include <pebble.h>
Window *my_window;
TextLayer *text_layer;
// isqrt_impl and isqrt provided by Siu Ching Pong on stackoverflow
uint32_t isqrt_impl(uint64_t const n, uint64_t const xk) {
uint64_t const xk1 = (xk + n / xk) / 2;
return (xk1 >= xk) ? xk : isqrt_impl(n, xk1);
}
@JoshuaJB
JoshuaJB / main.c
Created Jun 3, 2015
Pebble Accelerometer Average Demo Scaffold
View main.c
#include <pebble.h>
// NOTE: See http://developer.getpebble.com/docs/c/Foundation/Event_Service/AccelerometerService/ for docs
Window *my_window;
TextLayer *text_layer;
static void display_acceleration(AccelData * data, uint32_t num_samples);
// TODO: Write accelerometer event handler
// TODO: All all the data points together for each axis, then divide by the number of samples
View EncryptPasswordGUIInterface.cpp
#include <string>
#include "sha.h"
void EncryptPassword(const std::string& username, std::string& password)
{
const int DIGESTSIZE = SHA_DIGEST_SIZE;
const int ITERATIONS = 1337;
static const byte salt_base[DIGESTSIZE] = {
244, 243, 249, 244, 32, 33, 34, 35, 10, 11, 12, 13, 14, 15, 16, 17,
@JoshuaJB
JoshuaJB / options.xml
Created Sep 18, 2013
Options menu for 0AD.
View options.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
==========================================
- Options Window -
==========================================
-->
<objects>
<script file="gui/common/functions_civinfo.js"/>
@JoshuaJB
JoshuaJB / patch
Created Dec 26, 2013
Patch to enable profiling using yappi on the WFG 0 A.D. lobby bot.
View patch
Index: source/tools/XpartaMuPP/XpartaMuPP.py
===================================================================
--- source/tools/XpartaMuPP/XpartaMuPP.py (revision 14390)
+++ source/tools/XpartaMuPP/XpartaMuPP.py (working copy)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
"""
-
+import yappi
@JoshuaJB
JoshuaJB / app.js
Last active Aug 29, 2017
Basic Pebble App with WebSockets
View app.js
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*/
var UI = require('ui');
@JoshuaJB
JoshuaJB / gen_graphs_full.py
Created Mar 31, 2020
Full graph generation code for Sims, Bakita, and Anderson, ECRTS 2019
View gen_graphs_full.py
#!/usr/bin/python3
import matplotlib.pyplot as plt
import numpy
def read_sample(file):
"""Lazy function (generator) to read a file piece by piece.
Default chunk size: 1k."""
while True:
line = file.readline()
if line == b"*****\n":
You can’t perform that action at this time.