Skip to content

Instantly share code, notes, and snippets.

View timsgardner's full-sized avatar

Tims Gardner timsgardner

  • Arcadia Technologies
  • Brooklyn, NY
View GitHub Profile
@timsgardner
timsgardner / python_operator_precedence.md
Created September 26, 2023 23:16
Python Operator Precedence Cheat Sheet

Python Operator Precedence Cheat Sheet

What is Operator Precedence?

Operator precedence defines the order in which operations are performed when evaluating an expression. In Python, certain operators are evaluated before others. For example, in the expression 1 + 2 * 3, multiplication (*) has higher precedence than addition (+), so 2 * 3 is evaluated first, followed by 1 + 6, resulting in 7.

Understanding operator precedence is essential for accurately interpreting and writing Python code. It dictates how complex expressions are evaluated and helps prevent logical errors.

Precedence Order (Highest to Lowest)

(require 'inf-clojure)
;; need to trim whitespace; see https://www.emacswiki.org/emacs/ElispCookbook#toc6
(require 'subr-x)
;; this was making inf-clojure-set-ns act badly.
;; (with-eval-after-load 'inf-clojure
;; (defun inf-clojure-set-ns (ns)
;; "Set the ns of the inferior Clojure process to NS.
;; Defaults to the ns of the current buffer."
;; (interactive (inf-clojure-symprompt "Set ns to" (clojure-find-ns)))
| :calls | :max-time | :top-calls | :top-time-total | :name |
|--------+-----------+------------+-----------------+----------------------------------------------|
| 48 | 0.5917 | 48 | 1 | magic.analyzer/ensure-class |
| 6 | 0.922 | 6 | 1 | clojure.tools.analyzer/analyze-set |
| 1 | 2.4616 | 1 | 2 | clojure.tools.analyzer/parse-catch |
| 138 | 2.0322 | 138 | 2 | magic.analyzer/empty-env |
| 76 | 1.3766 | 76 | 2 | clojure.tools.analyzer/parse-var |
| 397 | 1.4513 | 397 | 3 | clojure.tools.analyzer/validate-bindings |
| 9 | 2.3541 | 9 | 3 | clojure.tools.analyzer/parse-set! |
| 1623 | 1.1749 | 1039 | 4 | clojure.walk/prewalk |
(setq clojure-mode-hook '(clojure-enable-miracle))
@timsgardner
timsgardner / cider-breakpoint-problem.clj
Created July 31, 2019 21:22
problem with multithreaded breakpoints in cider
(ns cider-experiment.core)
(def thread-log (atom []))
(defn log-thread [msg]
(swap! thread-log conj {:thread (Thread/currentThread)
:msg msg}))
;; instrument this function:
(defn f1 [x]
nothing at all
@timsgardner
timsgardner / InterestingClass.cs
Created November 27, 2018 06:27
an interesting class
using arcadia.@internal.test;
using clojure.lang;
using DeftypeBase.arcadia.@internal;
using System;
using System.Runtime.CompilerServices;
namespace arcadia.@internal
{
[Serializable]
public class test$make_tester$reify__15793__15819 : test$make_tester$reify__1579315795, IFn, ITester, IObj
class Note {
constructor(noteValue, pitch){
this.pitch = pitch;
this.noteValue = noteValue;
}
}
class Bar {
constructor(...notes) {
this.notes = notes;
{;; This specifies a form that the repl will evaluate before
;; evaluating every input:
;; :repl/injections (use 'clojure.repl)
;; set :reactive to false in user configuration file to disable file
;; watching, and everything that depends on it, such as automaic file
;; loading on change (see :reload-on-change below) and responding to
;; changes in configuration.edn without a restart
:reactive true