Skip to content

Instantly share code, notes, and snippets.

export function useWhyCallback<T extends (...args: any[]) => any>(
callback: T,
deps: React.DependencyList,
name = "",
) {
useWhyDidYouUpdate(name, deps);
return useCallback(callback, deps);
}
export function useWhyEffect(
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(setq package-selected-packages (quote (web-mode f flycheck)))
;;; Flow (JS) flycheck config (http://flowtype.org)
;; from https://github.com/bodil/emacs.d/blob/master/bodil/bodil-js.el
(require 'f)
(require 'json)
"""
This is a simple Redis-based queue. Two features that I needed were
uniqueness (i.e. if an item exists in the queue already, it won't be
added again) and a delay like beanstalkd where an item must wait a
specified time before it can be popped from the queue. There are a
number of other Redis-based queues that have many more features but
I didn't see one that had these two features together. This 50-line
class works for my needs. It may or may not work for you. Feel free
to copy this and build on it.
$ ls -l /var/log/syslog*
-rw-r----- 1 syslog adm 169965 2010 01/23 00:18 /var/log/syslog
-rw-r----- 1 syslog adm 350334 2010 01/22 08:03 /var/log/syslog.1
-rw-r----- 1 syslog adm 18078 2010 01/21 07:49 /var/log/syslog.2.gz
-rw-r----- 1 syslog adm 16700 2010 01/20 07:43 /var/log/syslog.3.gz
-rw-r----- 1 syslog adm 18197 2010 01/19 07:52 /var/log/syslog.4.gz
-rw-r----- 1 syslog adm 15737 2010 01/18 07:45 /var/log/syslog.5.gz
-rw-r----- 1 syslog adm 16157 2010 01/17 07:54 /var/log/syslog.6.gz
-rw-r----- 1 syslog adm 20285 2010 01/16 07:48 /var/log/syslog.7.gz
Jan 22 23:57:01
Jan 22 14:09:01
Jan 22 03:51:01
Jan 21 17:35:01
Jan 21 14:37:33
Jan 21 08:35:01
Jan 20 22:12:01
Jan 20 11:56:01
Jan 20 01:41:01
Jan 19 15:18:01
for i, line in enumerate(get_lines('/var/log/syslog*')):
if not i % 1000:
print line[:15]
import glob
import gzip
import re
def get_lines(log_glob):
"""Return an iterator of each line in all files matching log_glob.
Lines are sorted most recent first.
Files are sorted by the integer in the suffix of the log filename.
Suffix may be one of the following:
.X (where X is an integer)