Skip to content

Instantly share code, notes, and snippets.

View 0xhiroki's full-sized avatar
🦀

Hiroki Hori 0xhiroki

🦀
  • Brooklyn, NY
  • 14:01 (UTC -04:00)
View GitHub Profile
Verifying my Blockstack ID is secured with the address 15X7pH3z1J5aTHzeDwZrwiGsMgW8DUzcky https://explorer.blockstack.org/address/15X7pH3z1J5aTHzeDwZrwiGsMgW8DUzcky

Keybase proof

I hereby claim:

  • I am 0xhiroki on github.
  • I am hiroki (https://keybase.io/hiroki) on keybase.
  • I have a public key ASA0YUqWPQVW6egHZQt1OLYmzS4I-AGuT921pa94i_YqlQo

To claim this, I am signing this object:

@0xhiroki
0xhiroki / simple_macd.py
Created May 29, 2018 03:32
Enigma Catalyst with simple macd histogram strategy
import os
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import talib as ta
from matplotlib.dates import date2num
from matplotlib.finance import candlestick_ohlc
from catalyst import run_algorithm
template <typename T = int> class Calc
{
  public:
    T multiply(T x, T y);
    T add(T x, T y);
};

template <typename T> T Calc<T>::multiply(T x, T y)
{

Invert a binary tree. (https://leetcode.com/problems/invert-binary-tree/)

Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a binary tree on a whiteboard so fuck off.

TreeNode* invertTree(TreeNode* root) {
    if (root == NULL) {
        return NULL;
 }
@0xhiroki
0xhiroki / binarytreelookup.markdown
Last active November 18, 2015 01:20
Binary Tree Lookup()

Given a binary search tree and a "target" value, search the tree to see if it contains the target. The basic pattern of the lookup() code occurs in many recursive tree algorithms: deal with the base case where the tree is empty, deal with the current node, and then use recursion to deal with the subtrees. If the tree is a binary search tree, there is often some sort of less-than test on the node to decide if the recursion should go left or right.

static int lookup(struct Node* node, int target) {
  if (node == NULL) {
    // 1. Base case where tree is empty.
    return false;
  } else {
    // 2. see if found here.
 if (target == node-&gt;data) {

Singly-Linked Lists:
A set of nodes each containing some data and a link to the next node. Last node points to null.

ListNode *head = nullptr
struct ListNode {
  int data;
@0xhiroki
0xhiroki / iOS Crash Log Symbolication
Last active October 20, 2015 20:20
Symbolication
Simpler one:
$ symbolicatecrash <path to your crash file> <path to your .dSYM>
Or more specifically:
$ export DEVELOPER_DIR=`xcode-select --print-path`
$ /Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash <path to your crash file> <path to your .dSYM> >> <path to your output file>
This still sometimes doesn't symbolicate some logs. (i.e. appname 0x00110093 0x101000 + 61587)
If that happens, try the following.