Skip to content

Instantly share code, notes, and snippets.

@bootandy
bootandy / javascript_select.js
Created April 19, 2012 16:14
Javascript widgit for selecting correct value of a HTML menu dropdown
<script>
menu = document.getElementById('menu_element');
for (i = 0; i < menu.length; i++) {
if (menu.options[i].value == '{{value_to_select}}') {
menu.selectedIndex = i;
break;
}
}
</script>
@bootandy
bootandy / suggest_fb.html
Created May 2, 2012 17:08
AutoSuggest for facebook friends
<html>
<!-- Requires - jquery and jquery-ui -->
<link type="text/css" href="static/css/smoothness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="static/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="static/js/jquery-ui-1.8.20.custom.min.js"></script>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
@bootandy
bootandy / pymongo_nested_update.py
Created June 26, 2012 16:37
pymongo - showing how to update multiple nested docs
def bulk_invite(self, user_ids, group_id, invite_message):
self.db['user_details'].update( { '_id' : { '$in' : user_ids } },
{ '$set' : { 'group_invites.' + str(group_id) : invite_message} }, multi=True, safe=True)
@bootandy
bootandy / read_cookie.js
Created July 5, 2012 22:27
JS cookies without jquery
@bootandy
bootandy / strings.py
Created July 11, 2012 10:01
Python string basics
""" looks for the string: '@user ' in the string message and removes all occurrences"""
def remove_user_from_message(msg, user):
p = re.compile('@'+user+'\s+')
return p.subn('', msg)[0]
"""
indexOf and substring are done like this:
index_of = find
@bootandy
bootandy / string_split_speed.py
Created July 18, 2012 21:11
python string split speed
import time
import re
def load():
file_to_open = open('data.txt', "r")
return file_to_open.read()
def print_me(s):
print s
@bootandy
bootandy / focus.js
Created September 10, 2012 08:33
JS - Focus the field #message but DONT select all the text
$('#message').focus().val($("#message").val());
@bootandy
bootandy / divs.html
Created September 18, 2012 13:21
HTML - make div align to bottom of page / div
<!-- How 2 make a HTML div float at the bottom of the page: -->
<div id="container" style='position:relative;'>
<!-- Other elements here -->
<div id="copyright" style='position:absolute; bottom:0;'>
Copyright Foo web designs
</div>
</div>
@bootandy
bootandy / .bash_aliases
Last active May 16, 2018 13:39
My .bash_aliases file for ubuntu
# colors
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=gxgxcxdxbxegedabagacad # cyan directories
# We use UK keyboard
setxkbmap -layout gb
set completion-prefix-display-length 2
set completion-ignore-case on
@bootandy
bootandy / .bash_profile
Last active October 12, 2015 06:58
bash_profile for macbook
# colors
export CLICOLOR=1
export TERM=xterm-color
export LSCOLORS=gxgxcxdxbxegedabagacad # cyan directories
# old Prompt
#export PS1='\[\033[01;32m\]\u@:\[\033[01;36m\]\w\[\033[00m\]\$ '
#Android sdk add to PATH
#PATH=$PATH:/System/Library/android-sdk-mac_x86/tools/