Skip to content

Instantly share code, notes, and snippets.

View chaitanyagupta's full-sized avatar

Chaitanya Gupta chaitanyagupta

View GitHub Profile
(defun squash-log-newlines ()
"Squash wrapped log lines back to their original single line format."
(interactive)
(end-of-line)
(let ((search-str "[2010-01")
(start-marker (make-marker))
(end-marker (make-marker)))
(set-marker start-marker (point))
(search-forward search-str)
(set-marker end-marker (- (point) (1+ (length search-str))))
var findItem = function(jid, items){
for(var i = 0; i < items.length; ++i){
var item = items[i];
if(item.jid === jid){
return item;
}
}
return null;
}
;;; Usage (percentage (analyze-systems '(a b c d))) => 42.23
(eval-when (:compile-toplevel :load-toplevel :execute)
(when (asdf:find-system :named-readtables nil)
(asdf:load-system :named-readtables)))
(defun analyze-form (form)
(typecase form
(symbol
(when (eql (symbol-package form) (find-package 'cl))
@chaitanyagupta
chaitanyagupta / AMPNavigationBar.m
Last active December 25, 2015 18:59 — forked from aprato/AMPNavigationBar.m
Use CGRectGetHeight() instead of accessing height directly.
// .h
@interface AMPNavigationBar : UINavigationBar
@property (nonatomic, assign) CGFloat extraColorLayerOpacity UI_APPEARANCE_SELECTOR;
@end
// .m
@chaitanyagupta
chaitanyagupta / pj_str.c
Created February 13, 2014 05:01
Some memory tests around pj_str_t
// pj_str.c
// Some memory tests around pj_str_t
//
// To compile,
//
// $ gcc -g -I$PJSIP/pjlib/include -L$PJSIP/pjlib/lib -lpj-i386-apple-darwin12.5.0 -o pj_str pj_str.c
//
// And then run ./pj_str
//
// Check memory leaks using valgrind:
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active March 29, 2024 19:56
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@chaitanyagupta
chaitanyagupta / re-sign-ios-app.md
Last active October 20, 2023 08:28
How to re-sign an iOS app with another developer account

WARNING These steps are probably out dated and will not work.

To re-sign an iOS app with another developer account, ensure that the following are in place first.

  1. Distribution certificate of the other developer account
  2. A provisioning profile from the other developer account

Note that the Apple requires bundle IDs to be globally unique, even across accounts. So a bundle ID i.e. CFBundleIdentifier from one account can't be used in a different account, even though the team id/prefix would be different.

Ensure that the new distribution certificate is in your keychain and the new provisioning profile on your disk.

<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-17906056-1', { 'userId': '<snipped>','clientId': '<snipped>' });
ga('set', 'dimension1', '<snipped>');
ga('send', 'pageview', '/VPV/LI/Overview/MyView/Dashboard');</script>

Keybase proof

I hereby claim:

  • I am chaitanyagupta on github.
  • I am chaitanyagupta (https://keybase.io/chaitanyagupta) on keybase.
  • I have a public key ASC2IGaOUZI3T5g9aPkl0_8azN9kb0BGarsb8iQbll54gAo

To claim this, I am signing this object:

@chaitanyagupta
chaitanyagupta / mbox-parser.lisp
Last active December 8, 2016 10:39
mbox-parser
;;; mbox parser in Common Lisp
;; needs cl-mime and cl-base64
;; (ql:quickload :cl-mime)
;; (ql:quickload :cl-base64)
;;
;; Example: returns all emails in an mbox (as CL-MIME:MIME objects)
;;
;; (with-open-file (in #p"/path/to/mbox")
;; (let ((p (make-parser :stream in)))
;; (loop for mime = (next-mime p)