Skip to content

Instantly share code, notes, and snippets.

View Compro-Prasad's full-sized avatar
🔨
Building stuff. Mostly software.

Compro Prasad Compro-Prasad

🔨
Building stuff. Mostly software.
View GitHub Profile
@Compro-Prasad
Compro-Prasad / click-text.el
Created June 22, 2019 05:15
How to make clickable text in Emacs?
(defun compro/print-message (event)
"This function runs when you click the text."
(interactive "e")
(message "Hello World"))
(let* ((str "Click Me") ;; The text that will be produced
(str-beg 0) ;; Start position of string
(str-end (string-width str)) ;; End position of string
(map (make-sparse-keymap))) ;; Click event will be registered here
(define-key map [mouse-1] 'compro/print-message) ;; Register click event
# Requirement: astyle version 3.1
# 2 space indents.
--indent=spaces=2
--indent-after-parens
--indent-col1-comments
--style=gnu

Keybase proof

I hereby claim:

  • I am compro-prasad on github.
  • I am compro (https://keybase.io/compro) on keybase.
  • I have a public key ASAbZ-8jCEIxy81B9zVVjD4UY2EbETL8yK0LA-HO6YqCFQo

To claim this, I am signing this object:

@Compro-Prasad
Compro-Prasad / ppm2png.sh
Created November 24, 2018 14:40
Convert ppm to png easily
#!/bin/sh
for i in `ls -- *.ppm`; do
echo -n Converting $i ... ' '
convert -- $i `echo $i | sed "s/.ppm/.png/"`
echo Done
done
(defun copy-current-line-position-to-clipboard (p)
"Copy current line in file to clipboard as '</path/to/file>:<line-number>'"
(interactive "sAbsolute path y/n?: ")
(let ((path-with-line-number) (file-name (buffer-file-name)))
(when (and (not (string= p "y")) (projectile-project-root))
(setq file-name (file-relative-name buffer-file-name (projectile-project-root)))
)
(setq path-with-line-number (concat file-name ":" (number-to-string (line-number-at-pos))))
(x-select-text path-with-line-number)
(message (concat path-with-line-number " copied to clipboard"))))
@Compro-Prasad
Compro-Prasad / Default (OSX).sublime-keymap
Created June 22, 2018 17:19 — forked from radum/Default (OSX).sublime-keymap
Sublime Text 3 Configuration Files
[
{ "keys": ["ctrl+pagedown"], "command": "next_view" },
{ "keys": ["ctrl+pageup"], "command": "prev_view" }
]
@Compro-Prasad
Compro-Prasad / compro-p2p.py
Last active December 10, 2018 11:21
P2P client
#!/usr/bin/python3
import socket
import threading
from time import sleep
max_peers = 4
port = 3333
thread_list = []
@Compro-Prasad
Compro-Prasad / installLAMP.sh
Last active March 7, 2018 06:11
Install php, mysql and apache and connect to an existing project
#!/bin/sh
if which apt > /dev/null; then
echo "No support for your device"
exit
fi
if which firefox > /dev/null; then
echo "Firefox found"
BROWSER=firefox
elif which chromium > /dev/null; then
/*= compile: g++ -std=c++11 -Wall $src -o $exe =*/
/*= run: $exe =*/
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cassert>
using namespace std;
@Compro-Prasad
Compro-Prasad / settings.py
Last active February 18, 2018 14:43
Django Social Auth for Mysql Innodb engines which don't allow more than 767 field length
# http://python-social-auth.readthedocs.io/en/latest/configuration/settings.html?highlight=SOCIAL_AUTH_UID_LENGTH#tweaking-some-fields-length
# Thanks to knbk on #django freenode IRC
SOCIAL_AUTH_UID_LENGTH = 190
SOCIAL_AUTH_NONCE_SERVER_URL_LENGTH = 190
SOCIAL_AUTH_ASSOCIATION_SERVER_URL_LENGTH = 190
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 190
SOCIAL_AUTH_EMAIL_LENGTH = 190 # More than 190 is very rare to be used