Skip to content

Instantly share code, notes, and snippets.

View erickgnavar's full-sized avatar
🐛
Writing bugs one at time

Erick Navarro erickgnavar

🐛
Writing bugs one at time
View GitHub Profile
(let* ((status-line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(status-code (nth 1 (split-string status-line " "))))
(unless (string-equal status-code "201")
(user-error "There was a problem with GitHub API, try again later"))
(search-forward "\n\n")
(let* ((raw-response (buffer-substring-no-properties (point) (point-max)))
(data (json-parse-string raw-response))
(defun my/gist-handle-response (response)
"Process content of RESPONSE and extract link."
(interactive)
(let* ((status-line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(status-code (nth 1 (split-string status-line " "))))
(unless (string-equal status-code "201")
(user-error "There was a problem with GitHub API, try again later"))
(search-forward "\n\n")
(puthash filename file files)
(puthash "files" files payload)
(let ((url-request-method "POST")
(url-request-extra-headers `(("Content-Type" . "application/json") ("User-Agent" . "gist.el") ("Authorization" . ,(concat "Bearer " oauth-token))))
(url-request-data (json-encode payload)))
(url-retrieve "https://api.github.com/gists" 'my/gist-handle-response))))
(defun my/gist-handle-response ()
"Process content of RESPONSE and extract link."
(interactive)
(let ((url-request-method "POST")
(url-request-extra-headers `(("Content-Type" . "application/json") ("User-Agent" . "gist.el") ("Authorization" . ,(concat "Bearer " oauth-token))))
(url-request-data (json-encode payload)))
(url-retrieve "https://api.github.com/gists" 'my/gist-handle-response))))
(defun my/gist-handle-response (response)
"Process content of RESPONSE and extract link."
(let* ((status-line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(status-code (nth 1 (split-string status-line " "))))
(unless (not (string-equal status-code 201))
(user-error "There was a problem with GitHub API, try again later"))
(search-forward "\n\n")
(let* ((raw-response (buffer-substring-no-properties (point) (point-max)))
(data (json-parse-string raw-response))
(gist-link (gethash "html_url" data)))
(puthash "content" content file)
(puthash filename file files)
(puthash "files" files payload)
(message (json-encode payload))
(let ((url-request-method "POST")
(url-request-extra-headers `(("Content-Type" . "application/json") ("User-Agent" . "gist.el") ("Authorization" . ,(concat "Bearer " oauth-token))))
(url-request-data (json-encode payload)))
(url-retrieve "https://api.github.com/gists" 'my/gist-handle-response))))
(require 'tree-sitter)
(require 'seq)
(require 'cl-lib)
;;TODO: mapp grammar for other langauges and complete grammar for haskell
(setq modes-mapping '((haskell-mode . (exp_apply exp_infix exp_in exp_cond exp_literal))))
(defun expr-at-point ()
"Highlight expression at point."
(interactive)
function svg2png(svgContent, width, height, callback) {
// svgContent should be in base64
let svgData = svgContent;
let canvas = document.createElement("canvas");
let context = canvas.getContext("2d");
canvas.width = width;
canvas.height = height;
let image = new Image();
#!/bin/bash -
set -o nounset
make clean
echo "making sure all requirements are installed..."
brew install autoconf automake libxml2 jansson gnutls cmake librsvg texinfo
(defun replace-at-point ()
(delete-char 1)
(insert "🔥"))
(defun replace-line ()
(while (< (point) (line-end-position))
(sit-for 0.1)
(replace-at-point)))
(defun burn-code ()