This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
(circe-set-display-handler "irc.message" 'my/display-PRIVMSG) | |
(defun my/display-PRIVMSG (nick userhost command target text) | |
(if (not (equal nick "slack-irc-bot")) | |
(circe-display-PRIVMSG nick userhost command target text) | |
(let ((circe-format-say "[{nick}] {body}")) | |
(when (string-match "^<\\([^>]*\\)> \\(.*\\)" text) | |
(setq nick (match-string 1 text) | |
text (match-string 2 text))) | |
(circe-display-PRIVMSG nick userhost command target text)))) |
This file contains hidden or 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
(defun ref-define (type-symbol getter setter) | |
(put type-symbol 'ref-getter getter) | |
(put type-symbol 'ref-setter setter)) | |
(defun ref (obj &rest args) | |
(apply (get (type-of obj) 'ref-getter) | |
obj | |
args)) | |
(gv-define-simple-setter |
This file contains hidden or 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
(add-to-list 'load-path "~/Projects/circe") | |
(load "circe") | |
(load "profiler") | |
(setf (caar profiler-report-cpu-line-format) | |
500) | |
(setq circe-default-nick "forcer-" | |
irc-debug-log t |
NewerOlder