Skip to content

Instantly share code, notes, and snippets.

Avatar

Ken Manheimer kenmanheimer

View GitHub Profile
@kenmanheimer
kenmanheimer / sample
Created Jan 4, 2020
Scratch pyyaml for custom object export/import
View sample
def minimal_representer(dumper, item):
# type: (yaml.representer.Representer, spherical.item.Item) -> str
"""Minimal example of a representer that has features items will need."""
tag = "!spherical.example"
for i in spherical.utils.partially_sorted_partition(item):
fields = [['id', str(item._id)],
['title', item._title]]
return dumper.represent_sequence(tag, fields) # type: str
View gist:cdeb6c97c18adbd1fceb
def g(n):
if n == 1:
return 4
elif n < 1:
raise ArithmeticError, "g can't do negative numbers"
else:
return g(n-1) * -3
View gist:72c08453b12c0d0a813f
;; From https://gist.github.com/offby1/1240799
;; There's something similar (but fancier) in vc-git.el: vc-git-grep
;; -I means don't search through binary files
;; --no-color, oddly enough, is required to allow emacs to colorize the output
(defcustom git-grep-switches
"git --no-pager grep --extended-regexp -I -n --ignore-case --no-color"
View gist:bc03f06dbe06a4c9fd28
(defun my-get-agent ()
"Establish my registered ssh agent in this emacs shell *and* emacs session."
(interactive)
(let ((process (get-buffer-process (current-buffer)))
beg end start-point)
(if (not process)
(error "Non-shell buffer")
(goto-char (process-mark process))
(insert "eval $(ga); echo SSH_AUTH_SOCK::$SSH_AUTH_SOCK::")
(comint-send-input)
View gist:840834cfce780517d8d8
# Adapted from a friend's alternative solution to the Madhava implementation problem
# from question 16 in the Interactive Python Textbook problem set:
# http://interactivepython.org/runestone/static/thinkcspy/Functions/thinkcspyExercises.html
# Original gist: https://gist.github.com/anonymous/2f78d796e965d6abcaec/321252a19d85aebca2359188d9991f7472e9f786
def myPi(tolerance=0.01):
"""Compute Pi by Madhava's technique, to specified tolerance, default .01."""
accumulator = 0
n = 0
newvalue = abs(tolerance) + 1
View gist:3f667c00f9dff9020b55
function dembase() {
var resolvefunc,
p1 = new Promise(
function (resolve) {resolvefunc = resolve})
.done(function() {console.log("p1 resolve")}),
r1 = resolvefunc,
p2 = new Promise(
function (resolve) {resolvefunc = resolve})
.done(function() {console.log("p2 resolve")}),
r2 = resolvefunc,
View gist:72510607541f34792046
/** Show cordova .getFile() problem with some filenames containing "%" char.
*
* We create a file with the specified name in the Download dir,
* indicating whether or not the name of the created file is the same as
* that specified. On Android, the name is different if the specified
* one contains a sequence of chars starting with a "%" and not
* qualifying as a proper character entity - because of
* https://github.com/apache/cordova-plugin-file/blob/master/www/android/FileSystem.js#L29
*
* @param(string) filename - defaults to "x%y", which shows the problem.
View gist:32bba3506eb88b173de3
diff --git a/src/views/FilesView.js b/src/views/FilesView.js
index 28cfcd7..04eaa8c 100644
--- a/src/views/FilesView.js
+++ b/src/views/FilesView.js
@@ -192,11 +192,11 @@
}
var model = this.model;
// Start by getting the folder path
- var path = "Download/" + s("SpiderOak") + "/.favorites/" +
- (spiderOakApp.accountModel.get("b32username") || "anonymous") +
@kenmanheimer
kenmanheimer / gist:6717382
Created Sep 26, 2013
much further - now consistently failing in transaction functionality integration tests
View gist:6717382
...
◦ should refuse invalid usernames:
 2) should refuse invalid usernames
◦ should refuse incorrect passphrases:
 3) should refuse incorrect passphrases
Transaction functionality
4) "before all" hook
✖ 4 of 24 tests failed:
@kenmanheimer
kenmanheimer / gist:6717139
Created Sep 26, 2013
problem bootstrapping crypton, on 'sharing' branch
View gist:6717139
crisp.crypton 2: git branch
master
* sharing
crisp.crypton 3: ls
.git/ Makefile integration_tests/
.gitignore README.md otis.config.js
.travis.yml client/ server/
LICENSE doc/
crisp.crypton 4: make
make -C server test