Posts

ELLE Looks Like Emacs

Image
  If you like revisiting history, here's how you can run Elle on Minix. Download the minix image from https://github.com/davidgiven/minix2 . You can run the image in KVM. Login as root and run " elle file.txt ". # Install KVM and download image   sudo apt install qemu-kvm curl https://github.com/davidgiven/minix2/files/917987/minix-2.0-hd-64MB.img.gz -o minix-2.0-hd-64MB.img.gz gzip -d minix-2.0-hd-64MB.img.gz # Run the image in KVM kvm -hda minix-2.0-hd-64MB.img     Update software Compile the libraries, commands and kernel         a. # cd /usr/src         b. # make world   We need to update the bootloader as well.         a. # cd /         b. # mv boot boot.old         c. # cp /usr/mdec/boot .         d. # installboot -d /dev/c0d0p0s0 /usr/mdec/bootblock boot Now reboot.         a. # shutdown     References ELLE command reference Minix upgrade instructions    

Take Charge of PDF in GNU Emacs

Image
Display popup annotation in docview   All or None Docview is the default major-mode for displaying PDF in Emacs. It converts each page into an image using ghostscript into a temporary folder (/tmp/docview<nnnn>) and displays the same. For large PDF document, this conversion is unnecessary in most cases - especially when one is looking at the document for quick reference.   An ideal solution would be to convert pages on demand. However, for this, one would need to know the number of pages in the document. This can be done either by some external tools like pdfinfo or one would need to parse the metadata in the document. So here's some elisp code for the same.   (require 'pdf) (pdf-get "Root.Pages.Count")   or   M-x pdf-total-pages   ;; Metadata about the document (pdf-get "Root.Metadata")     So here we are - now that one can parse the metadata, what else can we do? Form fields and Embedded scripts M-x pdf-form PDF supports embedded Javascript for add

AWS API Usage in Elisp

Image
Here's some sample elisp code for signing Amazon Web Services (AWS) API requests . The value (first element) returned by (aws-sign4) is used in Authorization header while making a request. When the function is called with an expires value, it returns a URL which can be directly used in a browser. (require 'aws-sign4)   (let ((*aws-credentials*        (lambda ()          (values "AKIAIOSFODNN7EXAMPLE" "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"))))   (aws-sign4 :region "eu-west-1"              :service "s3"              :host "s3-eu-west-1.amazonaws.com"              :path "/some-bucket/some-file"              ))   (let ((*aws-credentials*        (lambda ()          (values "AKIAIOSFODNN7EXAMPLE" "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"))))   (aws-sign4 :region "us-east-1"              :service "iam"              :host "iam.amazonaws.com"              :params '((&qu

One-click Social Media Client

Image
Reddit: Dashboard and details view Twitter: Dashboard and details view Tumblr: Dashboard and details view GNU Emacs as a Social Media Client Consumption of social media typically necessitates few repeated actions - like, share, comment and follow. If these actions are assigned to convenient keyboard keys, the consumption becomes easier - no more pointing and clicking tiny icons. Here's an attempt to unify this experience using GNU Emacs, tumblesocks and oauth2.   (require 'tumblesocks) (require 'oauth2)   ;; service below is one of twitter, reddit or tumblr (setq tumblesocks-service-conf    (service . ( client-id secret-key redirect-url ))     Use M-x sm-twitter , M-x sm-reddit or M-x sm-tumblr . First time, it will open a browser window. You'll need to login to the service and allow the permissions in following window. Then you'll be redirected to a URL. You'll need to copy the code (code= value#_ ) in the URL without the # and _ . Then you can use l for like

Oauth2 sample flow in Elisp

Image
Here's a modified version of oauth2.el . This Elisp code works for oauth2 flow using Twitter, Gmail, Reddit and Tumblr. To add more services, add the provider URLs to the variable oauth2-service-conf. To make API calls, set the service configuration values (client-id, secret-key and  redirect-url) in the variable t-service-conf. Then use the examples in the usage section. (require 'oauth2)  (setq t-token nil) (setq t-service-conf   '((service . ( client-id secret-key redirect-url ))))   (defun t-api-oauth2-request (url params method service auth-scope                        &optional headers)   (let* ((oauth2-conf (assoc service oauth2-service-conf))      (conf (assoc service t-service-conf))      (t-consumer-key (nth 1 conf))      (t-secret-key (nth 2 conf))      (t-callback-url (nth 3 conf))      (data nil))     (unless (assoc service t-token)       (push (cons service           ( oauth2-auth (nth 1 oauth2-conf)                    (nth 2 oauth2-conf)               

Tumblr access from GNU Emacs

Image
Dashboard view (left) and detail view (right) tumblesocks-mode allows you to access Tumblr from GNU Emacs. Best part is - it has pagewise navigation by default instead of endless scroll. Use c for new post, f for follow, l for like and r for reblog. Since the repository is dormant and I needed some customization, I created a fork . It includes some UI changes, fix for emoji display, shorter tumblesocks alias and fix for displaying post at point, like post, reblog post, goto page etc.  

Compose Emoji in GNU Emacs

Image
  Modern emojis are composable - you can compose multiple emojis into a new one. Most commonly, this is done using Zero-Width Joiner or ZWJ character (#200D). Though not all combinations are valid. The valid combinations are defined by the font. e.g. you can combine as follows: Person + rocket = Astronaut Person + manual wheelchair = Person on wheelchair Following function will help you insert ZWJ in between selected text. (defun emoji-compose ()   "Compose emoji from components."   (interactive)   (unless (region-active-p)     (error "Select a sequence of emoji components"))   (let* ((start (1+ (region-beginning)))      (len (- (region-end) start)))     (goto-char start)     (dotimes (i len)       (insert #x200D)       (forward-char)))) For auto-completion, you can use company-emoji . References Unicode defined ZWJ sequences Unicode ZWJ specification