Skip to content

Instantly share code, notes, and snippets.

View BilalQadri's full-sized avatar

Bilal BilalQadri

View GitHub Profile
@BilalQadri
BilalQadri / emacs-biwa.el
Last active June 26, 2022 12:58
Biwascheme from Emacs (with repl)
;; Initialize Biwascheme interpreter on frontend(browser) then send and receive expressions with websocket client
;; INSTALL websocket.el, LOAD this file and RUN interactive function `load-ws` from Emacs
;; ws-close to close server
;; send expression (e.g functions) to browser with `C-c C-s` ... Tip# cursor should be on function name
(defun load-ws ()
(interactive)
(load-file "~/.emacs.d/websocket.el")
(start-ws)
(start-repl))
@BilalQadri
BilalQadri / method.js
Last active January 22, 2018 16:40
Biwascheme PUT/POST/DELETE method
define_libfunc("http-post-call", 2, 2, function(ar){ // path , data and method (post/put/delete)
var path = ar[0];
assert_string(path);
var data = ar[1];
var method = ar[2];
return new BiwaScheme.Pause(function(pause){
$.ajax({
url: path,
type: method,
@BilalQadri
BilalQadri / funcs.scm
Created January 22, 2018 16:24
biwascheme utility functions and macros
(define (rassoc key alist) ;; remove alist entry with key
(define (eq- pair)
(not (string=? key (car pair))))
(filter eq- alist))
(define (capitalize str)
(let* ((f (substring str 0 1))
(s (substring str 1 (string-length str))))
(string-append (string-upcase f) s)))
@BilalQadri
BilalQadri / server.lisp
Created January 22, 2018 16:11
Hunchentoot starting point (routing)
;;; hunchentoot and split-sequence are required (hint: via quicklisp)
(defvar acceptor nil)
(setf *default-pathname-defaults* #p"~/code/lisp/attend/maker/")
(setf acceptor (hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 4242)))
;;(hunchentoot:stop acceptor)
@BilalQadri
BilalQadri / resize-image.js
Last active August 14, 2023 22:37
Resize Image (keeping aspect ratio) of HTML with Javascript
// jquery required
// maxWidth and maxHeight can be parameters for more flexibility
function (img_ref) {
var img = $(img_ref);
img.on('load', function () {
img.css("width", "auto");
img.css("height", "auto");