Showing posts with label make. Show all posts
Showing posts with label make. Show all posts

Wednesday, October 31, 2012

Zotero => bibtex with md5 identifiers

I was just hesitated to see annoying useful BibTeX ids like: "???_tonejito_???" so I found this page [1] that shows how to mess with the Zotero Firefox plugin, and I came out with the idea of using the md5 of the title as identifier (for me that is better than the other id).

The file in question was <FirefoxProfile>/zotero/translators/BibTeX.js the whole code is javascript so it's easy to modify and play with.

Looking around the web I also found this github:gist [2] to calculate an md5 sum from a given string, I pasted all the code at the end of the file and used the md5_hex function as follows to replace the element key.


$ diff -u /tmp/BibTeX.js BibTeX.js 
--- /tmp/BibTeX.js 2012-10-31 02:51:49.000000000 -0600
+++ BibTeX.js 2012-10-31 02:51:43.000000000 -0600
@@ -2083,7 +2083,8 @@
  if(!type) type = "misc";
 
  // create a unique citation key
- var citekey = buildCiteKey(item, citekeys);
+ //var citekey = buildCiteKey(item, citekeys);
+ var citekey = hex_md5(buildCiteKey(item, citekeys));
 
 
  // write citation key


I'm currently using the Zotero plugin [3] and the zotero bibtex auto-exporter plugin [4], I tested this using the preferences pane for the autoexporter and run a manual test. After a couple of tries the results were like this:



@misc{20c7358045528f33804340fb6510b8b9,
title = {tonejito {(Andres} Hernandez) · {GitHub}},
url = {https://github.com/tonejito/},
urldate = {2012-10-31},
howpublished = {https://github.com/tonejito/},
file = {tonejito (Andres Hernandez) · GitHub:/Users/tonejito/Library/Application Support/Firefox/Profiles/profile.default/zotero/storage/AAAAAAAA/tonejito.html:text/html}
},

@misc{823e4a8551f18d37794d3115226700ba,
title = {Tonejito},
url = {http://tonejito.blogspot.com/},
urldate = {2012-10-31},
howpublished = {http://tonejito.blogspot.com/},
file = {Tonejito:/Users/tonejito/Library/Application Support/Firefox/Profiles/profile.default/zotero/storage/BBBBBBBB/tonejito.blogspot.com.html:text/html}
},

@misc{d83e6f346506b44510957a2fa00fff13,
title = {Andres Hernandez {(Tonejito)} on Twitter},
url = {https://twitter.com/tonejito},
urldate = {2012-10-31},
howpublished = {https://twitter.com/tonejito},
file = {Andres Hernandez (Tonejito) on Twitter:/Users/tonejito/Library/Application Support/Firefox/Profiles/profile.default/zotero/storage/CCCCCCCC/tonejito.html:text/html}
}



So I can use any of this hashes in a LaTeX document like this and the bibliography entries will be sorted and referenced correctly.

\textbf{Twitter}
\cite{d83e6f346506b44510957a2fa00fff13}


\textbf{Blog}
\cite{823e4a8551f18d37794d3115226700ba}


\textbf{Github}
\cite{20c7358045528f33804340fb6510b8b9}



Thanks LaTeX and BibTeX

[1] http://www.curiousjason.com/zoterotobibtex.html
[2] https://gist.github.com/951664
[3] https://addons.mozilla.org/en-US/firefox/addon/zotero/
[4] https://addons.mozilla.org/en-US/firefox/addon/zotero-bib-autoexport/
--
  = ^ . ^ =

Friday, June 29, 2012

% make FF



% cat Makefile


FOLLOWERS?=
ME?=Tonejito
SIGNATURE?="= ^ . ^ ="


FF:
if [ "${FOLLOWERS}" ] ; \
then  \
 for FOLLOWER in ${FOLLOWERS} ;  \
 do  \
   echo "FF @$$FOLLOWER" ;  \
 done ;  \
else  \
 echo "FF @${ME}" ;  \
fi ;
echo ${SIGNATURE} ;
--


% make -s
FF @Tonejito
= ^ . ^ =


% make -s FF FOLLOWERS="alpha beta gamma"
FF @alpha
FF @beta
FF @gamma
= ^ . ^ =


--


crontab -e



# m h  dom mon dow   command
  0 12  *   *   5    make FF


--
= ^ . ^ =

Monday, March 5, 2012

IPv4 and IPv6 SOCKS proxy

$ cat Makefile
XTERM=/usr/bin/xterm
SSH=/usr/bin/ssh
GEOMETRY=169x39-0-0
IPv6_LOCALHOST=::1
PROXY_PORT=1080
SSH_PORT?=22
IPv4_PROXY=127.128.129.130
IPv6_PROXY=${IPv6_LOCALHOST}
IPv4_REMOTE?=127.126.125.124
IPv6_REMOTE=${IPv6_LOCALHOST}
IPv4_BIND=127.127.127.127
IPv6_BIND=${IPv6_LOCALHOST}

proxy:
        ${XTERM} -geometry ${GEOMETRY} -iconic -T "IPv4 proxy" \
          -e ${SSH} -v -x -n -N -b $(IPv4_BIND) -p ${SSH_PORT} \
          -D ${IPv4_PROXY}:${PROXY_PORT} ${IPv4_REMOTE} &
        ${XTERM} -geometry ${GEOMETRY} -iconic -T "IPv6 proxy" \
         -e ${SSH} -v -x -n -N -b $(IPv6_BIND) -p ${SSH_PORT} \
         -D [${IPv6_PROXY}]:${PROXY_PORT} ${IPv6_REMOTE} &

$ make proxy

--
  = ^ . ^ =

Wednesday, February 1, 2012

make my life hard

% cat Makefile
# = ^ . ^ =
_:
        make -f $(PWD)/Makefile &


% make


--
  = ^ . ^ =

Thursday, August 11, 2011

make me a sandwich

% cat Makefile
me: a

a: sandwich

sandwich:
% make me a sandwich
make: `me' is up to date.
make: `a' is up to date.
make: Nothing to be done for `sandwich'.

--
  = ^ . ^ =