Skip to content

Instantly share code, notes, and snippets.

Norman Richards orb

Block or report user

Report or block orb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@orb
orb / ats-source.org
Created Apr 15, 2019
the org mode source
View ats-source.org

cisco-ats npm repositories

The @cisco-ats NPM packages are distributed in the cisco-threat-response-npm repository at engci-maven-master.cisco.com, an internal Cisco artifactory instance. The repository is mirrored to at devhub.cisco.com for authenticated use outside of the Cisco network.

using engci-maven

@orb
orb / paths.org
Created Mar 6, 2019
path finding
View paths.org

pathfinding in Clojure

Help, I’m stuck in a maze

Motivation

Many AoC problems required some sort of path finding - shortest path, cheapest path according to the rules of the world.

@orb
orb / sort_compare.clj
Created Jan 19, 2019
compare team data
View sort_compare.clj
(ns sort-compare.core)
(def team-data
[{:team-id 1
:total-pts 7
:matches [{:schedule-id 1 :opp-team-id 2 :opp-team-pts 6 :team-points 3}
{:schedule-id 2 :opp-team-id 3 :opp-team-pts 6 :team-points 4}]}
{:team-id 2
:total-pts 7
:matches [{:schedule-id 1 :opp-team-id 1 :opp-team-pts 3 :team-points 6}
@orb
orb / roll.clj
Created Sep 11, 2018
an instaparse version of the roll parser, just for fun
View roll.clj
(ns roll.core
(:require [instaparse.core :as instaparse]
[clojure.string :as str]))
(def roll-parser
(instaparse/parser "
roll = quantity? <'d'> die-type (operator operand)?
<quantity> = number
<die-type> = number
<operand> = number
View saveImage.java
boolean saveImage(String fileName, String contentType, InputStream inputStream) {
Connection connection = null;
PreparedStatement statement = null;
ResultSet keySet = null;
try {
connection = dataSource.getConnection();
statement = connection.prepareStatement("INSERT INTO images (filename, content_type, content) values (?, ?, ?)",
new String[] {"id"});
statement.setString(1, fileName);
@orb
orb / ImageServlet.java
Created Apr 20, 2018
an example setting content type on download
View ImageServlet.java
package images;
import java.io.FileInputStream;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
View gist:3ba47be961e24dd53808f71fa31ebcc7
(defun flatten (l)
(cond
((null l) nil)
((listp l) (append (flatten (car l))
(flatten (cdr l))))
(t (list l))))
(flatten '())
(flatten 1)
(flatten '(1 . 2))
@orb
orb / example.js
Last active Apr 6, 2017
bootrap modal hide event
View example.js
// capturing the hide event instead of the hidden event lets us intercept the close and update our state
//
componentDidMount = () => {
$(this.node).on("hide.bs.modal",
(e) => {
if (this.props.open) {
// if we say the modal should be open but it want's to close
e.preventDefault(); // stop it from closing
this.props.closeMe(); // update our state to request our close, if we want that behavior
}
View clojure-as-destructure
user> (defn try-it [ & [x & xs :as all-of-them]]
all-of-them)
#'user/try-it
user> (try-it 1 2 3 4 5)
(1 2 3 4 5)
user> (defn try-it [ & [x & xs :as all-of-them]]
x)
#'user/try-it
user> (try-it 1 2 3 4 5)
View project.clj
(defproject trypy "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.python/jython-standalone "2.5.2"]]
:aliases {"jython"
["trampoline" "run" "-m" "org.python.util.jython"]})
You can’t perform that action at this time.