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 » gin's snipts The latest snipts from gin.

showing 1-8 of 8 snipts
  • Get PYTHONPATH content, from bash shell
    # Get PYTHONPATH content, from bash shell
    printf "import sys\nprint sys.path\nquit()\n" | python
    

    copy | embed

    0 comments - tagged in  posted by gin on Jan 21, 2010 at 2:31 p.m. EST
  • search & apply new perm for files in pattern
    #!/bin/bash
    
    # Search for files with pattern name defined on name var, then
    # apply new user, group and other perms. located in path
    
    old_user='gin';
    new_user='shakka';
    
    old_group='guest';
    new_group='geek';
    
    name='*.ogg'
    path='/home/gin/video/';
    perm='700';
    
    	chmod ${perm} `find ${path} -name ${name} -user ${old_user} -group ${old_group}`;
    	chown ${new_user}:${new_group} `find ${path} -name ${name} -user ${old_user} -group ${old_group}`;
    
    exit 0;
    

    copy | embed

    0 comments - tagged in  posted by gin on Jan 05, 2010 at 6:19 p.m. EST
  • set database charset with zend
    <?
    /* Index.php bootstrap application*/
    
    /* Load config data */
    $config = new Zend_Config_Xml('./app/config.xml', 'general');
    $registry = Zend_Registry::getInstance();
    $registry->set('config', $config);
    
    /* Set database */
    $db = Zend_Db::Factory($config->db->def->adapter, $config->db->def->params->toArray());
    Zend_Db_Table::setDefaultAdapter($db);
    
    /* Specify database charset */
    $db->query("SET NAMES 'utf8'");
    $db->query("SET CHARACTER SET 'utf8'");
    

    copy | embed

    0 comments - tagged in  posted by gin on Dec 30, 2009 at 11:29 a.m. EST
  • remove spaces
    #!/bin/bash
    
    # original value
    my_var="Fuck World!";
    
    # trim function
    function trim()
    {
    local _tmp=$@;
    
        _tmp=${_tmp/ /};
        echo $_tmp;
    }
    
        # passing one argument
        new_var=$(trim $my_var);
    
        # modified value, without spaces
        echo $new_var;
    

    copy | embed

    0 comments - tagged in  posted by gin on Dec 11, 2009 at 10:43 a.m. EST
  • clean samba recycle directory every 'x' time
    #!/bin/bash
    
    # clean samba recycle directory every 'x' time
    #
    # cronjob:
    # 0 5 * * * root /usr/local/bin/recyclean.sh
    
    path="/home/samba/.recycle/"
    days="20"
    
    rm -rf `find ${path} -mtime +${days} -print`;
    

    copy | embed

    0 comments - tagged in  posted by gin on Oct 26, 2009 at 3:31 p.m. EDT
  • run banshee from ssh session
    #!/bin/sh
    # run banshee from ssh session & auto play queque
    
    export DISPLAY=:0
    dbus-launch /usr/bin/banshee --play
    

    copy | embed

    0 comments - tagged in  posted by gin on Oct 26, 2009 at 3:21 p.m. EDT
  • get info from selected drop box
    /* Get info from selected drop box
     * Javascript Common tools
     * Moises Brenes moises.brenes@gmail.com
     */
    function get_selected(id)
    {
    var selected, value, text;
    	
    	value = null;
    	text = null;
    	
    	/* id item selected */
    	selected = document.getElementById(id).selectedIndex;
    	
    	if (selected >= 0)
    	{
    		value = document.getElementById(id).options[selected].value;
    		text = document.getElementById(id).options[selected].text;
    	}
    
    	if (selected < 0)
    		selected = null;
    
    return [selected, value, text];
    }
    

    copy | embed

    0 comments - tagged in  posted by gin on Aug 24, 2009 at 7:09 p.m. EDT
  • alien number generator
    /* Alien Numbers
     * Google Code Jam, Practice 2009
     * Moises Brenes moises.brenes@gmail.com
     */
    #include <cstdlib>
    #include <string>
    #include <cmath>
    #include <vector>
    #include <iostream>
    #include <fstream>
    
    using namespace std;
    
    /* explode a string */
    void split(string src, string del, vector<string> *dst)
    {
    int found;
    
    	found = src.find_first_of(del);
    	while (found != string::npos)
    	{
    		if (found > 0)
    			dst->push_back(src.substr(0, found));
    		
    		src = src.substr(found + 1);
    		found = src.find_first_of(del);
    	}
    	
    	if (src.length() > 0)
    		dst->push_back(src);
    }
    
    /* convert a string from any base to any base  */
    string convert(string alien, string source, string target)
    {
    string str;
    int a_size;
    int s_size;
    int t_size;
    int dec;
    int i;
    
    	/* alien number size */
    	a_size = alien.size();
    	/* source language base */
    	s_size = source.size();
    	/* target language base */
    	t_size = target.size();
    	
    	str = "";
    	dec = 0;
    	
    	/* convert x base to decimal */
    	for (i = 0; i < a_size; i++)
    		dec = dec + (source.find_first_of(alien[i]) * pow(s_size, a_size - 1 - i));
    	
    	/* convert decimal to y base */
    	while (dec != 0)
    	{
    		str = (target[dec % t_size] + str);
    		dec = (int) (dec / t_size);
    	}
    	
    return str;
    }
    
    int main(int argc, char **argv)
    {
    char buffer[256];
    int i;
    int top;
    ifstream input;
    string str;
    vector<string> field;
    
    	if (argc == 2)
    	{
    		input.open(argv[1]); 
    
    		input.getline(buffer, 256);
    		str = (string) buffer;
    		
    		i = 1;
    		top = atoi(str.c_str());
    		do
    		{
    			input.getline(buffer, 256);
    			str = (string) buffer;
    			
    			if (i <= top)
    			{
    				split(str, " ", &field);
    				
    				cout << "Case #" << i << ": " << convert(field[0], field[1], field[2]) << endl;
    				
    				field.erase(field.begin(),field.end());
    			}
    			
    			i++;
    		}
    		while (!input.eof());
    		
    		input.close();
    	}
    
    return 0;
    }
    

    copy | embed

    0 comments - tagged in  posted by gin on Aug 24, 2009 at 2:38 p.m. EDT
Sign up to create your own snipts, or login.