Skip to content

Instantly share code, notes, and snippets.

@dbridges
dbridges / 3d_cellular_automata.nb
Created May 18, 2021 21:22
Three Dimensional Self Reproducing Cellular Automata
Evolve2D[m_] :=
ArrayPad[BlockMap[
Mod[#[[2, 1]] + #[[2, 3]] + #[[1, 2]] + #[[3, 2]], 2] &, m, {3, 3},
1], 1]
Evolve3D[m_] := ArrayPad[
BlockMap[
Mod[#[[1, 2, 2]] + #[[3, 2, 2]] + #[[2, 1, 2]] + #[[2, 3, 2]] + #[[
2, 2, 1]] + #[[2, 2, 3]], 2] &, m, {3, 3, 3}, 1
],
import React from "react";
import ReactDOM from "react-dom";
import Select from "react-select";
import { Controller } from "stimulus";
export default class extends Controller {
initialize() {
// We need this check because Turbolinks renders a preview when navigating
// back and Stimulus will re-initilaze the controllers.
if (!this.data.get("initialized")) {
<ul class="food">
<% items.each do |item| %>
<li>
<span><%= item.name %></span>
<span class="kind"><%= item.kind %></span>
</li>
<% end %>
</ul>

Playground

fmt.Println(os.Getwd())
import pandas as pd
print(pd.read_csv('data.csv'))
let g:notefile_base_path="~/Dropbox/notes"
function! CurrentNoteDir()
return fnamemodify(CurrentNotePath(), ":p:h")
endfunction
function! CurrentNotePath()
return substitute(getcwd(), $HOME, expand(g:notefile_base_path), "") . ".md"
endfunction
@dbridges
dbridges / CaliforniaEarthquakes.nb
Created September 9, 2019 21:07
California Earthquake's
This file has been truncated, but you can view the full file.
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 12.0' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
func main() {
// Fetch and filter the feeds
feeds := fetchFeeds(feedURLs)
feeds = filterFeeds(feeds)
if len(feeds) == 0 {
return
}
// Render the feeds to an HTML string
t := loadTemplate()
writer := &strings.Builder{}
func mail(content string) error {
host := os.Getenv("MAIL_HOST")
port := os.Getenv("MAIL_PORT")
addr := host + ":" + port
to := os.Getenv("MAIL_TO")
from := os.Getenv("MAIL_FROM")
pw := os.Getenv("MAIL_PASSWORD")
auth := smtp.PlainAuth("", from, pw, host)
subject := "RSS Feeds for " + time.Now().Format("Jan 02, 2006")
func loadTemplate() *template.Template {
templates, err := filepath.Glob("templates/*")
if err != nil {
log.Println(err)
}
t := template.Must(template.New("layout.go.html").ParseFiles(templates...))
return t
}
func main() {