Sign up to create your own snipts, or login.

Public snipts » spider's snipts The latest snipts from spider.

showing 1-15 of 15 snipts
  • researchr
    a, a:visited, a:active { 
      color : #009; 
    }
    
    h2 { 
      font-size : 120%; 
      line-height: 1.4em; 
      margin-bottom : 1em; 
      margin-top : 1em; 
      font-weight : bold; 
      text-transform: uppercase;
      color: #900;
    }
    

    copy | embed

    0 comments - tagged in  posted by spider on Dec 24, 2009 at 7:06 a.m. EST
  • mi3ch
    Problem:    _ _
            _ _|_|_|
           |_|_|_|
    
    Solutions:
         _ _         _ _
     _ _|  _|    _ _|_| |
    |_|_|_|_|   |_|_|_ _|
    
       _ _ _       _ _ _
     _|  _|_|    _|_| |_|
    |_|_|_|     |_|_ _|
    

    copy | embed

    1 comment - tagged in  posted by spider on Jun 17, 2009 at 5:32 p.m. EDT
  • listings
    \usepackage{float}
    \usepackage{tocloft}
    \newcommand{\listofsnippetname}{List of Listings}
    \newlistof{snippet}{lol}{\listofsnippetname}
    \floatstyle{boxed}
    \newfloat{snippet}{thp}{lol}[chapter]
    \floatname{snippet}{Listing}
    \newcommand{\snippetautorefname}{Listing}
    \renewcommand{\thesnippet}{\thechapter.\arabic{snippet}}
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 10, 2009 at 8:35 a.m. EDT
  • dreampy6
    DSL.Wrapper(bgffile).open('r').readlines().join('').strip()(lambda x:'<list>'+x+'</list>')(lambda x:ET.XML(x)).findall('*')
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 05, 2009 at 4:13 a.m. EDT
  • dreampy5
    bgffile.open('r').readlines().join('').strip().complete().parseXML().findall('*').copySubElement(rr)
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 05, 2009 at 4:06 a.m. EDT
  • realpy3
     for r in ET.XML('<list>'+''.join(open(bgffile,'r').readlines()).strip()+'</list>').findall('*'):
      x = ET.SubElement(rr,'root')
      x.text = r.text
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 05, 2009 at 3:58 a.m. EDT
  • dreampy4
    a = [(True,'x',20),(False,'y',3),(False,'z',-1)]
    if (_,n,_) in a:
     print 'Match!'
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 04, 2009 at 6:42 p.m. EDT
  • dreampy3
    a = [('x',20),('y',3),('z',-1)]
    if (n,_) in a:
     print 'Match!'
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 04, 2009 at 6:39 p.m. EDT
  • dreampy2
    a = ['x','y','z']
    if n in a:
     print 'Match!'
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 04, 2009 at 6:35 p.m. EDT
  • realpy2
    def append_(x,y):
     z = x[:]
     z.append(y)
     return z
    
    def sort_(x):
     z = x[:]
     z.sort()
     return z
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 04, 2009 at 6:07 p.m. EDT
  • realpy1
    a.extend(b)
    a.sort()
    a.reverse()
    for i in a:
     doStuff(i)
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 04, 2009 at 5:58 p.m. EDT
  • dreampy1
    for i in a.extend(b).sort().reverse():
     doStuff(i)
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 04, 2009 at 5:47 p.m. EDT
  • beating @twitbrain on Twitter, guaranteed
    #!/usr/bin/python
    import os, sys, urllib
    from elementtree import ElementTree as et
    whom   = 'http://twitter.com/twitbrain'    # whom are we beating
    email  = 'spider.vz@gmail.com'             # your email goes here
    passwd = 'obfuscated'                      # your password goes here
    # API recipe taken from http://twitter.com/radkat/status/1783742923 (@radkat via @shellfu)
    template = 'wget --keep-session-cookies --http-user='+email+' --http-password='+passwd+\
               ' --post-data="status=@twitbrain NNN" http://twitter.com:80/statuses/update.xml'
    # twitbrain rules should've been more intricate
    replacepairs = ('+',''),('-',''),('*',''),('/',''),(' ',''),\
                   ('plus','+'),('minus','-'),('times','*')
    # some twitter html magic (last one is 0 for working mode, 1 for debugging)
    splitrules = ('<ol class="statuses" id="timeline">',1),('</ol>',0),('</li>',0)
    # damn you, python, for not being pure FP!
    def concat(car,cdr): lst = [car]; lst.extend(cdr); return lst 
    
    if __name__ == "__main__":
     print 'Beat Twit Brain v 1.00'
     # started 29 May, 15:21
     # finished 29 May, 16:04
     # best time to beat @twitbrain: 4 seconds
     # prooflinks: http://twitter.com/twitbrain/status/1969162641
     #             http://twitter.com/twitbrain/status/1970038221
     #             http://twitter.com/twitbrain/status/1973465293
     #             http://twitter.com/twitbrain/status/1975133562
     txt = ''
     while not txt:
      print 'Stalking...'
      txt = et.XML('<ol>'+\
            reduce(lambda x,y:x.split(y[0])[y[1]],concat(urllib.urlopen(whom).read(),splitrules))+\
            '</li></ol>').findtext('li/span/span')
      if not txt[0].isdigit():
       txt = ''
     print 'Evaluating...'
     s = reduce(lambda x,y:apply(x.replace,y),concat(txt,replacepairs))
     print s,'=',eval(s)
     # Stop here if you don't want anything posted!!!
     #sys.exit(1)
     print 'Posting...'
     os.system(template.replace('NNN',str(eval(s))))
     print 'Done.'
     # clean up the update.xml created by wget
    

    copy | embed

    0 comments - tagged in  posted by spider on Jun 04, 2009 at 3:56 a.m. EDT
  • pp_pp
    #!/usr/bin/python
    import sys
    
    # post-processor for pretty-printer
    
    if len(sys.argv) > 1:
     maxLen = int(sys.argv[1])
    else:
     maxLen = 70
    mode = 0
    for line in sys.stdin:
     if mode == 1:
      if line.find('\\end{lstlisting}\\end{graybox}')>-1:
       mode = 0
       lline = line
      else:
       tokens = line.split(' ')
       lline = tokens[0]
       for token in tokens[1:]:
        if len(lline + ' ' + token)>maxLen:
         print lline
         lline = ' '*16 + token
        else:
         lline = lline + ' ' + token
      print lline,
     elif mode == 0:
      if line.find('\\begin{lstlisting}[language=pp]')>-1:
       mode = 1
      print line,
    

    copy | embed

    1 comment - tagged in  posted by spider on May 19, 2009 at 5:48 p.m. EDT
  • xbgfSlice
    def main(xbgfFile):
     xbgfDir = '/'.join(xbgfFile.split('/')[:-1])
     if xbgfDir == '':
      xbgfDir = './'
     elif xbgfDir[-1]!='/':
      xbgfDir += '/'
     print 'Slicing...'
     sliced = slicing.sliceFile(xbgfDir,xbgfDir,xbgfFile.split('/')[-1].replace('.xbgf',''))
     return
    

    copy | embed

    0 comments - tagged in  posted by spider on May 19, 2009 at 9:36 a.m. EDT
Sign up to create your own snipts, or login.