Skip to content

Instantly share code, notes, and snippets.

View aaronang's full-sized avatar

Aaron Ang aaronang

View GitHub Profile
@aaronang
aaronang / .bashrc
Created July 16, 2018 22:51
Bash prompt for servers
#
# Clean and minimalistic Bash prompt
# Author: Artem Sapegin, sapegin.me
#
# Inspired by: https://github.com/sindresorhus/pure & https://github.com/dreadatour/dotfiles/blob/master/.bash_profile
#
# Notes:
# - $local_username - username you don’t want to see in the prompt - can be defined in ~/.bashlocal : `local_username="admin"`
# - Colors ($RED, $GREEN) - defined in ../tilde/bash_profile.bash
#
@aaronang
aaronang / main.cpp
Last active February 21, 2019 18:36
Interview Question: Review the handwritten sorting library in C++.
#include <cstdlib>
#include <iostream>
#include <sorter.hpp>
int main (int argc, char *argv[]) {
int* a = new int[10];
for (int i = 0; i < 10; i++) {
a[i] = rand();
}
bool double_eq(const double a, const double b) {
return std::fabs(a - b) < std::numeric_limits<double>::epsilon();
}
double average(const vector<int> &numbers) {
int sum = std::accumulate(numbers.begin(), numbers.end(), 0);
return sum / numbers.size();
}
int main() {
@aaronang
aaronang / quadtree.jl
Created October 19, 2018 17:11
Just experimenting with RegionTrees
module Playground
using RegionTrees
import StaticArrays: SVector
const Point = SVector{2, Float32}
root = Cell(SVector(0., 0), SVector(1., 1), [
Point(0, 0),
Point(.5, .5),
@aaronang
aaronang / CMakeLists.txt
Last active August 24, 2018 21:58
Calling a Python script from C++ 🐍
cmake_minimum_required(VERSION 3.12)
project(popen)
set(CMAKE_CXX_STANDARD 11)
add_executable(popen main.cpp)
install(FILES hello.py
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
lerna(verbose) GitUtilities.isInitialized ()
lerna(verbose) GitUtilities.isInitialized () => true
lerna(verbose) GitUtilities.getTopLevelDirectory()
lerna(verbose) GitUtilities.getTopLevelDirectory() => "."
lerna(verbose) FileSystemUtilities.existsSync("./lerna.json")
lerna(verbose) FileSystemUtilities.existsSync("./lerna.json") => true
lerna(verbose) FileSystemUtilities.readFileSync("./lerna.json")
lerna(verbose) FileSystemUtilities.readFileSync("./lerna.json") => "{\n \"lerna\": \"2.0.0-beta.38\",\n \"version\": \"6.23.1\",\n \"changelog\": {\n \"repo\": \"babel/babel\",\n \"labels\": {\n \"tag: spec compliancy\": \":eyeglasses: Spec Compliancy\",\n \"tag: breaking change\": \":boom: Breaking Change\",\n \"tag: new feature\": \":rocket: New Feature\",\n \"tag: bug fix\": \":bug: Bug Fix\",\n \"tag: polish\": \":nail_care: Polish\",\n \"tag: documentation\": \":memo: Documentation\",\n \"tag: internal\": \":house: Internal\"\n }\n },\n \"cacheDir\": \".c
#!/usr/bin/env node
require("../lib/babel");
export function transform(filename, code, opts) {
opts = defaults(opts || {}, index.opts);
opts.filename = filename;
const result = babel.transform(code, opts);
result.filename = filename;
result.actual = code;
return result;
}
const fn = commander.outDir ? dirCommand : fileCommand;
fn(commander, filenames, opts);
const square = n => n * n