IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » mandric's snipts The latest snipts from mandric.

showing 1-7 of 7 snipts
  • Stick this in your .vimrc if your designers leave tabs in their css.
    :autocmd FileType css set noexpandtab
    

    copy | embed

    0 comments - tagged in  posted by mandric on Jul 14, 2010 at 12:30 p.m. EDT
  • An alias in git for resetting a staged file.
    git config --global alias.unstage "reset HEAD"
    

    copy | embed

    0 comments - tagged in  posted by mandric on Jul 06, 2010 at 9:12 a.m. EDT
  • 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
    

    copy | embed

    0 comments - tagged in  posted by mandric on Apr 16, 2010 at 10:23 a.m. EDT
  • 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
    

    copy | embed

    0 comments - tagged in  posted by mandric on Apr 06, 2010 at 3:34 p.m. EDT
  • 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})')
    

    copy | embed

    0 comments - tagged in  posted by mandric on Aug 05, 2009 at 8:04 p.m. EDT
  • 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
    

    copy | embed

    0 comments - tagged in  posted by mandric on Aug 04, 2009 at 1:38 p.m. EDT
  • 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)
    

    copy | embed

    0 comments - tagged in  posted by mandric on Aug 03, 2009 at 8:13 p.m. EDT
Sign up to create your own snipts, or login.