Skip to content

Instantly share code, notes, and snippets.

priceRanges = {
"highSpike": [
{
"2": {
"low": 77,
"high": 99
},
"3": {
"low": 81,
"high": 154
@nonopolarity
nonopolarity / TurnipPrices.cpp
Last active August 25, 2020 23:52 — forked from Treeki/TurnipPrices.cpp
AC:NH turnip price calculator
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
// munged from https://github.com/simontime/Resead
namespace sead
{
if (document.querySelector("#my-tmp-audio") === null) {
let aDiv = document.createElement("div"); // can edit gist?
aDiv.innerHTML = "<audio controls autoplay id='my-tmp-audio' style='display: none'></audio>";
document.body.appendChild(aDiv);
}
<table>
<tbody>
{
data.map((record, i) => <tr key={i}>
<td>{record.id}</td>
<td>{record.name}</td>
</tr>)
}
</tbody>
</table>
@nonopolarity
nonopolarity / stopwatch.sh
Last active July 31, 2017 11:54 — forked from rawaludin/stopwatch.sh
simple stopwatch in bash
# add to your ~/.bashrc
function stopwatch() {
local BEGIN=$(date +%s)
while true; do
local NOW=$(date +%s)
local DIFF=$(($NOW - $BEGIN))
local MINS=$(($DIFF / 60 % 60))
local SECS=$(($DIFF % 60))
@nonopolarity
nonopolarity / gist:3729869
Created September 15, 2012 21:29
the hierarchy of scrollview
2012-09-15 14:20:27.621 DrawingFun[16907:303] Hierarchy:
2012-09-15 14:20:27.621 DrawingFun[16907:303] <NSView: 0x100604ba0> frame: {{0, 0}, {480, 360}}
2012-09-15 14:20:27.621 DrawingFun[16907:303] <NSScrollView: 0x100605140> frame: {{30, 14}, {400, 300}}
2012-09-15 14:20:27.621 DrawingFun[16907:303] <NSClipView: 0x100608220> frame: {{1, 1}, {398, 298}}
2012-09-15 14:20:27.621 DrawingFun[16907:303] <StretchView: 0x1001399a0> frame: {{0, -3}, {800, 600}}
2012-09-15 14:20:27.622 DrawingFun[16907:303] <NSScroller: 0x10011a070> frame: {{383, 1}, {16, 298}}
2012-09-15 14:20:27.622 DrawingFun[16907:303] <NSScroller: 0x10011aa40> frame: {{1, 283}, {398, 16}}
@nonopolarity
nonopolarity / gist:3729857
Created September 15, 2012 21:26
print out view and its subviews hierarchy
-(void) printSubviews:(NSView *) view withLevel:(int) level {
NSLog(@"%*s%@ frame: %@", level * 4, "", view, NSStringFromRect(view.frame));
for (NSView *sv in [view subviews]) {
[self printSubviews:sv withLevel:level+1];
}
}
-(void) printSubviews:(NSView *) view {
NSLog(@"Hierarchy:");
@nonopolarity
nonopolarity / loop.m
Created September 2, 2012 05:11
Objective-C looping through array using a block
NSArray *array = @[
@"hello",
@"world",
[NSNull null],
@123,
@123.456
];
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger i, BOOL *stop) {
NSLog(@"obj %d is %@", i, obj);
@nonopolarity
nonopolarity / loop.m
Created September 2, 2012 04:11
Objective-C 2.0 for ... in loop, using Fast Enumeration, looping through dictionary key-value pairs and values
NSDictionary *dictionary = @{
@"hello" : @"world",
@12 : @"foo",
@123.456 : @56,
@"how are you" : @1
};
for (id key in dictionary) {
NSLog(@"key is %@ and value is %@", key, [dictionary objectForKey:key]);
}
@nonopolarity
nonopolarity / loop.m
Created September 2, 2012 04:05
Objective-C 2.0 for ... in loop, using Fast Enumeration, with number literals
NSArray *array2 = @[
@"hello",
@"world",
[NSNull null],
@123,
@123.456
];
for (id obj in array2) {
NSLog(@"the obj is %@", obj);