Skip to content

Instantly share code, notes, and snippets.

View offby1's full-sized avatar

Eric Hanchrow offby1

View GitHub Profile
@offby1
offby1 / wat.py
Last active September 11, 2016 04:09
from bs4 import BeautifulSoup
import requests
import re
import urlparse
html = requests.get("http://mandalorianmercs.org/forum/index.php?board=86.0")
html.encoding = 'ISO-8859-1'
soup = BeautifulSoup(html.text, 'html.parser')
@offby1
offby1 / wat.py
Created September 11, 2016 03:45
import urllib.parse
for link in soup.find_all('a', href=re.compile('.*index.php\\?topic=')):
parsed = urllib.parse(link)
if not parsed.fragment:
print(link.get('href'), link.text)
@offby1
offby1 / wat.el
Last active September 10, 2016 20:14
(defun is-enabled-minor-mode (symbol)
(and (string-match (rx "-mode" eos) (symbol-name symbol))
(symbol-function symbol)
(condition-case nil
(symbol-value symbol)
(error nil))
))
(let ((minor-modes '()))
(mapatoms #'(lambda (sym)
(when (is-enabled-minor-mode sym)
void main(void) {
#define foo(a, b) \
(foo * bar)
}
wat () {
this;
}
(progn
(require 'org)
(defun timestamp ()
"Convenience wrapper around \\[org-time-stamp]"
(interactive)
(let ((org-time-stamp-formats (cons "%FT%T%z" "%FT%T%z")))
(org-time-stamp '(16))
(insert " ")))
(local-set-key (kbd "C-c C-c") 'timestamp))
@offby1
offby1 / gist:15e4f9b9736ea402b06bf7db6c4aca7e
Created July 25, 2016 19:39
Use magit? Have a lotta buffers? This is handy.
;; Unrelated to the above, but handy anyway
(defun ibuffer-mark-most-readonly-buffers ()
(interactive)
(ibuffer-mark-on-buffer
#'(lambda (buf)
(and
;; Yeah, yeah, I could (defvar
;; ibuffer-precious-read-only-yadda-yadda) but screw that.
(not (string-match (rx bos "*magit: ") (buffer-name buf)))
(buffer-local-value 'buffer-read-only buf)))))
Character code properties: customize what to show
name: ASTERISK
general-category: Po (Punctuation, Other)
There are text properties here:
fontified t
front-sticky t
lui-format circe-format-self-say
lui-format-argument body
lui-keywords [Show]
>>> [m.groups() for m in [re.match(r'abc(\d+)def', x) for x in ['abc14def', 'xyz38def', 'asdf', 'abc3def']] if m]
[('14',), ('3',)]
>>>
git ? rebase -i --autosquash --autostash 58ededc^
fatal: Needed a single revision
[detached HEAD 8a4481b] blah blah blah
Date: Wed Feb 10 23:13:09 2016 +0000
Successfully rebased and updated refs/heads/consolidate-regions.
No stash found.
"git stash store" requires one <commit> argument
Cannot store
>>> import requests
>>> url = 'http://www.weatheraction.com/pages/pv.asp?p=wact46'
>>> url += "'"
>>> requests.get (url)
<Response [500]>
>>> response = requests.get (url)
>>> response.body
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Response' object has no attribute 'body'