Skip to content

Instantly share code, notes, and snippets.

View bramses's full-sized avatar
🤨

Bram Adams bramses

🤨
View GitHub Profile
@bramses
bramses / indexOf.java
Created July 6, 2018 12:52
Java Implementation of indexOf()
public int indexOf(int ch, int fromIndex) {
if (fromIndex < 0) {
fromIndex = 0;
} else if (fromIndex >= count) {
// Note: fromIndex might be near -1>>>1.
return -1;
}
if (ch < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
// handle most cases here (ch is a BMP code point or a
@bramses
bramses / two_functions.py
Created July 6, 2018 21:25
How To test Without Really Trying
def hard_state_add_5(whole_obj):
if "a" in whole_obj:
return whole_obj["a"] + 5
def easy_state_add_5(input_num):
return input_num + 5
def main():
whole_obj = {}
whole_obj["a"] = 10
@bramses
bramses / Menu.js
Created May 30, 2019 17:12
Algolia Custom Component
import React from "react"
const Menu = ({ items, refine, title }) => (
<div>
<p className="star-wars-facet">{title}</p>
<hr className="star-wars-hr"/>
<ul>
{items.map(item => (
<li style={{ listStyle: 'none' }} key={item.value}>
<a href="#" style={{ fontWeight: item.isRefined ? 'bold' : '', textDecoration: 'none' }} className="star-wars-facet" onClick={event => {
@bramses
bramses / algolia-plugin.js
Created May 31, 2019 17:05
Algolia Plugin -- Gatsby
{
resolve: `gatsby-plugin-algolia`,
options: {
appId: process.env.APP_ID,
apiKey: process.env.API_KEY,
indexName: 'star-wars-characters', // for all queries
queries,
chunkSize: 10000, // default: 1000
}
}
@bramses
bramses / galakrond_priest.pde
Created December 15, 2019 06:42
Galakrond Priest Eye 👁
float p1x;
float p1y;
float p2x;
float p2y;
float p3x;
float p3y;
float p4y;
@bramses
bramses / script.pde
Created January 18, 2020 07:42
Disentegrating Mountain [Processing]
/*
fork of P_2_1_2_04
*/
PImage img;
int tileCount = 50;
float tileWidth;
float tileHeight;
int actRandomSeed = 0;
@bramses
bramses / api.py
Last active September 8, 2021 11:05
Run OpenAI API in NodeJS Express Server
import openai
import os
from dotenv import load_dotenv
import sys
load_dotenv()
TOKEN_RESPONSE_LENGTH = 20
TEMPERATURE = 0.75
STOP = "\n"
@bramses
bramses / COMDE.md
Created April 17, 2021 19:03
Recursion

index.ts -- low temperature: Typescript

This code is importing the VSCode library and the dotenv library. It also imports OpenAI, which is a library for AI.

import * as vscode from 'vscode'
import * as dotenv from 'dotenv'
// @ts-ignore
import * as OpenAI from '../openai/index.js'
import fetch from 'node-fetch'
@bramses
bramses / add.js
Created August 3, 2021 03:01
the cli test
/* make a function that does basic addition */
function add(a, b) {
return a + b;
}
@bramses
bramses / BinTree.java
Created August 5, 2021 21:00
Silicon Valley Season 1, Episode 6 (15:07)
def _remove_from_parent(self,tr,path):
parent = self._find(tr, path[:-1]
del tr[parent[self.SUBDIRS][path[-1][.key0]