Skip to content

Instantly share code, notes, and snippets.

@avk
avk / autorow_controller.js
Created July 22, 2021 13:30
auto-resizing textareas in Stimulus 1.2
/* example use
<%= form.text_area :notes,
cols: "auto",
rows: "1",
placeholder: "+ thoughts",
data: {
controller: "autorow",
action: "input->autorow#handleInput",
target: "autorow.textarea",
}
// from react-dnd
// module.exports = DragLayer(collect)(ItemPreview);
let function1 = DragLayer(collect);
let function2 = function1(ItemPreview);
module.exports = function2;
function partial_sum(a) {
return function (b) {
return a+b;
};
@avk
avk / search_git_log.sh
Created November 30, 2015 16:40
two bash helper functions for searching git commit messages and commit history
function commit_messages {
if [ -z "$1" ]
then
echo "Please pass in a string to search for in all of this repository's log messages."
else
echo "Searching commit messages for \"$1\""
git log --grep "$1" --all
fi
}
@avk
avk / gem_repo.sh
Created August 28, 2015 21:42
opens the home page of the given (installed) gem
function gem_repo {
gem list -d $1 | grep "Homepage: " | sed s/Homepage:\ // | xargs open
}
@avk
avk / gitat.sh
Created May 31, 2013 19:55
View the past and present state of deployed files in a git repo.
# gitat
# View the past and present state of deployed files in a git repo.
#
# Usage:
# 1. prints file in currently deployed state
# $ gitat path/to/file
# 2. prints version of file deployed on May 20
# $ gitat path/to/file 2013-05-20
# 3. prints context around line 123 in version of file deployed on May 20
# $ gitat path/to/file 2013-05-20 123
@avk
avk / new_footer_contents_link.html
Created December 12, 2011 00:52
SaaS book #39 revised for one HTML file per jQuery Mobile page
@avk
avk / xhr_json_post.js
Created December 9, 2011 00:48
Titanium Mobile properly serializing JSON into a query string
var url = "http://localhost:3000";
var params = {
foo: 'bar',
stuff: [1,2,3]
};
var xhr = Ti.Network.createHTTPClient({
onload: function() {
alert("load!");
},
onerror: function() {
@avk
avk / toc.html
Created December 8, 2011 02:45
SaaS book revised TOC
<div data-role="page" id="toc">
<div data-role="content">
<h2 class="likechapterhead">Contents</h2>
<!-- FOREWORD CHAPTER (i.e. everything between #toc and #chapter_1) -->
<div class="chapter_contents">
<h2>
<a class="chapter_title" href="#chapter_0">
Foreword
</a>
@avk
avk / cover_and_title_page.html
Created December 7, 2011 09:15
SaaS book image cover and title page
<body>
<!-- START cover image page -->
<div data-role="page" id="cover">
<div data-role="content">
<img id="cover-landscape" src="cover/cover-landscape.jpg" width="1024">
<img id="cover-portrait" src="cover/cover-portrait.jpg" width="768">
</div>
<div data-role="footer" data-id="global-nav" data-position="fixed" class="ui-bar">
<!-- footer content -->
@avk
avk / pastebin_links.html
Created November 28, 2011 21:49
SaaS book Pastebin links