This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
class NoExceptionsFormatter(logging.Formatter): | |
def format(self, record): | |
record.message = record.getMessage() | |
if self.usesTime(): | |
record.asctime = self.formatTime(record, self.datefmt) | |
return self._fmt % record.__dict__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remove leading spaces | |
char *dst = (equals + 1); | |
char *src = dst; | |
while (*src++ == ' ') | |
; | |
src--; | |
while((*dst++ = *src++)) | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo fnord > fnord | |
$ (echo foo ; sleep 5 ; echo bar) > baz & (sleep 1 ; cp fnord baz) | |
$ cat baz | |
fnorbar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This is a bad idea. | |
(defun restart-process (process) | |
(let ((name (process-name process)) | |
(buffer (process-buffer process)) | |
(program-and-args (process-command process)) | |
(sentinel (process-sentinel process)) | |
(filter (process-filter process)) | |
(new-process)) | |
(with-current-buffer buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys, os, subprocess, signal | |
#usage $~/lab/erc-notifier.py title message | |
### pop up the first notify window, and kill it when pop up the second notify window | |
controler=0 | |
previous_pid=0 | |
if controler == 0: | |
p0=subprocess.Popen(['/home/jusss/lab/notifier.py', sys.argv[1], sys.argv[2]], shell=False) | |
### just replace once! sed -i '0,/a/ s//e/' example | |
os.system("sed -i -e '0,/controler=0/ s//controler=1/' ~/lab/erc-notifier.py") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = (event, context, callback) => { | |
var ec2 = new AWS.EC2({region: process.env.AWS_REGION}); | |
ec2.describeSnapshots(params).promise() | |
.then(data => { | |
return Promise.all( | |
data.Snapshots | |
.filter(snap => daysOld(snap.StartTime) > MAX_AGE) | |
.map(snap => ec2.deleteSnapshot({SnapshotId: snap.SnapshotId}).promise()) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'cl) | |
(defun test-alis-1 (i n) | |
(let* ((alis (loop for i from 0 to 10 collect (list i))) | |
(start (float-time))) | |
(dotimes (_ n) | |
(assq i alis)) | |
(- (float-time) | |
start))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'json) | |
(require 'subr-x) | |
(defun fix-string (s) | |
(string-join | |
(delq nil (mapcar (lambda (ch) | |
(encode-coding-char ch 'utf-8 'unicode)) | |
s)))) | |
(with-current-buffer (url-retrieve-synchronously |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setq-default mode-line-format | |
`("" | |
" %b" | |
(:eval | |
(if (and buffer-file-name | |
(buffer-modified-p)) | |
"*" | |
" ")) | |
" %l" | |
(column-number-mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiling no file at Fri Jan 10 17:20:03 2014 | |
Leaving directory `/home/forcer/.emacs.d/elpa/magit-1.2.0' | |
Compiling file /home/forcer/.emacs.d/elpa/magit-1.2.0/magit-bisect.el at Fri Jan 10 17:20:03 2014 | |
Entering directory `/home/forcer/.emacs.d/elpa/magit-1.2.0/' | |
magit-bisect.el:1:1:Error: Wrong type argument: listp, 769 | |
Compiling file /home/forcer/.emacs.d/elpa/magit-1.2.0/magit-blame.el at Fri Jan 10 17:20:03 2014 | |
magit-blame.el:34:1:Error: Wrong type argument: listp, 769 |
NewerOlder