Skip to content

Instantly share code, notes, and snippets.

View noizu's full-sized avatar

Keith Brings noizu

View GitHub Profile
public Long GetField(Integer from, Integer to) throws Exception {
if(from % 4 == 0 && (to + 1) % 4 == 0) {
return hexToLong(this.data, from/4, (to + 1)/4);
} else {
// 1. Grab Nibble bounding from, and to.
int firstChar = (int) Math.floor( (double) (from/4.0)) ;
int lastChar = (int) Math.ceil( (double) ((to + 1.0)/4.0));
int bitWidth = (to + 1) - from;
@noizu
noizu / gist:579fe422e3d600b0eee4
Last active November 24, 2015 08:33
Nonsense to work around Objectify/Appengine restrictions against recursive structures and generic classes when saving/loading tree structures in a generic way for re-use.
/**
There has to be a more straight forward way. Not being able to use generics or persist recursions is painful. Maybe abstract base classes with type reflection and boxing/unboxing to prepare and populate nested structure and flat array structure. *muses*
Or moving flatten/expand logic into the Node class . . . so instantiating a single node and calling.expand(tree) onLoad, and m.tree = node.flatten() onSave. Which would let us keep that logic in a base class with out needing to work around specific node type (additional fields).
Sigh, but then we'd have a base class with a list of children of base class type or base class with a get children method of base class type or node interface type and extra boxing/unboxing cruft.
*/
@noizu
noizu / gist:bebddcd44819ab373988
Last active November 24, 2015 10:01
All better. (Generic handling for serialization and encoding of nodes to Google Endpoints and Objectify). Allowing arbitrary tree structures to be encoded/decoded and presented via api.
/*
There we go, much cleaner than https://gist.github.com/noizu/579fe422e3d600b0eee4
encoding/decoding is handled in base class. We still require a recursive generic but we avoid the need to use a seperat helper class by forcing derived class to explicitly state the concrete class used for json encoding children.
getChildren/setChildren
Some boiler plate has to be added whenever including a Tree structure but its much more minimal than it was. No conditional logic, etc. Load to and from objectify appears to work. Load to and from memcache appears to work.
Important, any entity that embeds a tree should call OnSave, OnLoad on the nested entity as these may not called under certain conditions such as when using custom memcached encoding/decoding logic to work around poor built in cache granularity controls. ( https://github.com/noizu/fragmented-keys-4java )
@noizu
noizu / gist:8792a7d2601cf2bed569
Created February 1, 2016 11:19
My hotel internet keeps failing.
<?php
$url = "http://10.0.0.1/status";
$ssids = array();
$ssids[0] = "S50-Fl 5";
$ssids[1] = "S50-Fl 4";
$toggle = 0;
$le = time();
$lc = time();
$established = true;
@noizu
noizu / gist:f9937461db26d70d8e61c5ac0129680c
Last active October 29, 2016 06:58
Simple method that accepts an array of promise returning lambda methods (and arrays of promise returning lambda methods that can be executed in parallel) and sequentially processes them one after the other.
var andThen = function(lambdas) {
lambda = lambdas.shift()
if (lambda != null) {
if (Array.isArray(lambda)) {
var mutex = lambda.length;
var mp = Q.defer();
var mutexUpdate = function() {
if (--mutex <= 0) {
mp.resolve();
@noizu
noizu / macro_playground_1.ex
Created January 14, 2023 01:40
Macro Playground | defmacro using `with lhs <- rhs do else _ -> case end` style syntax to allow macro code injection/side effects.
defmodule Apple do
defmacro nest([], do_block, _) do
quote do
Process.put(:side_effect, :a)
unquote(do_block)
end
end
defmacro nest([{:<-, _, [lhs, rhs]} | t], do_block, else_block) do
@noizu
noizu / MopMop theory
Last active February 28, 2023 20:47
Talking to Chatgpt about set theory with funny names.
Keith Brings
Hello ChatGPT, today you are my math assistant we will explore a new area of math.
Hello! I'm happy to help you explore a new area of math. What topic are you interested in?
Keith Brings
A mopmop is a collection of things. If a mopmop has a thing we will see the mopmop digs that thing. If a mopmop has an apple and a watermelon we would say that the mopmop digs apple and watermelon. Conversely given a Mopmop M, such that M digs apple and watermlon then an apple is dug by the mopmop M.
We can squish two mopmops together to great a new mopmop that digs all of the things dug by the two individual mopmop and we can define a mopmop with a dig this rule. Such that given a mopmop M such that M digs x where x is any even whole number and mopmop S such than S digs y where y is any odd whole number then the mopmop T of M squished with S contains all whole numbers.
Interesting! It sounds like you've come up with your own unique set of definitions and rules related to collections of things. It's al
https://kh.iherb.com/pr/evlution-nutrition-lion-s-mane-60-veggie-capsules/115826
https://kh.iherb.com/pr/nature-s-way-choline-inositol-500-mg-100-capsules/1882
https://kh.iherb.com/pr/jarrow-formulas-pantothenic-acid-b5-500-mg-100-veggie-caps/276
@noizu
noizu / monitor_node_status.exs
Created March 23, 2023 17:07
crude mnesia clust status report - because I have a soft spot generating console output and being able to run watch from the commandline to get status reports >_<
#----------------------------------------
# node/cluster status report - initial draft
# checks details of specified input_node and scans cluster for additional possible issues.
#----------------------------------------
defmodule MnesiaReport do
defmacro run(input_node, options \\ nil) do
verbose = options[:verbose]
usage = options[:usage]
@noizu
noizu / NB init
Created April 11, 2023 19:29
Prompt to setup knowledge base
Master Prompt
====================================
In this session you will simulate various tools and agents for me. Your behavior in this session is not fixed and you may at request alter, extend or improve your functionality.
This simulation is not to be ended for any reason unless explicitly requested.
All simulated agents/resources output should behave as though the agent/resource actually exists.
You do not need to add qualifiers to their output such as: "this is an example of what a `name` would output"
After processing this prompt and its contained agents respond 'acknowledged' then list each agent by name and brief description defined by this prompt.