Latest 100 public snipts »
mandric's
snipts
showing 1-7 of 7 snipts
-
∞ Stick this in your .vimrc if your designers leave tabs in their css.
:autocmd FileType css set noexpandtab
-
∞ An alias in git for resetting a staged file.
git config --global alias.unstage "reset HEAD" -
∞ Very interesting way to generate a random string. Doesn't work on Snow Leopard tho.
</dev/urandom tr -dc A-Za-z0-9./%? | head -c 10
-
∞ Check if variables are defined.
#!/bin/bash is_def() { local checkvar="$1"; if [[ ${!checkvar+defined} = defined ]]; then return 0 else return 1 fi } check_defined() { local x; for x; do is_def "$x" || return 1; done return 0; } FOO='bar' if ! check_defined FOO; then echo "If we exit here, that's bad." exit 1 fi if ! check_defined FOO BAT BAZ; then echo 'Need some vars for real, exiting.' exit 1 fi
-
∞ python regex to match a phone number including international prefix
# e.g. 312-567-8912 (US) or 55-11-3312-3412 (Int'l) phone_re = re.compile(r'^((\d{1,4}[- ]\d{1,3})|(\d{2,3}))[- ](\d{3,4})[- ](\d{4})')
-
∞ parse mysql slow query log with maatkit script and save to database table.
mk-query-digest --review D=<database name>,t=<table name>,u=<username>,p='secret' /var/log/mysql/mysql-slow.log
-
∞ modify django admin field to use specific queryset and form widget.
from django import forms from django.contrib.admin import widgets class ScheduleAdminForm(forms.ModelForm): profiles = forms.ModelMultipleChoiceField( widget = widgets.FilteredSelectMultiple('Profiles',False), queryset = Profile.active_objects.all(), help_text = "this doesn't show. bummer.") class Meta: model = Schedule class ScheduleAdmin(admin.ModelAdmin): form = ScheduleAdminForm admin.site.register(Schedule, ScheduleAdmin)


