n3paste.de

::

a haskell happstack pastebin

  • New paste
  • View pastes

  • Login

  • About
  • Most recent pastes (filtered)

    Filter pastes (help):

    15:39 - Sat 2017.02.11

    Python

    Paste: /XNp/Show related

    Reply to /pz8/

    test0 = {
        'input': {},
        'expected': [ ]
        }
    
    test00 = {
            'input': { 'a': 1 },
        'expected': [ ['a'] ]
        }
    
    test1 = {
        'input': { 'a': { 'b': 'stop here' } },
        'expected': [ ['a', 'b' ] ],
        }
    
    test2 = {
        'input': { 'a': { 'b': { 'c': {} } } },
        'expected': [ ['a', 'b', 'c' ] ],
        }
    
    

    14:48 - Tue 2016.04.05

    Python

    Paste: /FAw/Show related

    No description.

    #!/usr/bin/python
    import os
    import sys
    import shutil
    
    # Find Basepath of Latex-Files
    basepath = os.path.dirname(os.path.realpath(__file__))
    if len(sys.argv)>1:
    	if os.path.isdir(sys.argv[1]):
    		basepath = sys.argv[1];
    if basepath[-1]!=os.sep:
    	basepath+= os.sep
    
    # Folder for tex-Files
    texfolder = basepath+"texte"
    
    # Function to extract Text from Folder-Names
    def folder2title(foldername):
    	if(os.path.isfile(foldername+os.sep+"title")):
    		return open(foldername+os.sep+"title").readline().rstrip().replace('_',' ')
    

    21:29 - Mon 2016.04.04

    Python

    Paste: /rJX/Show related

    randompw

    import random
    from string import digits, letters
    
    def randompw(length=8):
        return ''.join((random.choice(digits + letters) for i in range(length)))
    

    17:13 - Sun 2016.01.24

    Python

    Paste: /Ma/Show related

    kleines script

    import numpy as np
    from PIL import Image
    import os
    import sys
    from glob import glob
    from tqdm import tqdm
    
    
    def trim_picture(location):
        org = Image.open(location)
        w, h = org.size
        arr = np.array(org)
        # find first nontransparent pixel in every direction
        nz = arr.nonzero()
        # vertical minimal distance
        vdist = min(min(nz[0]), h - 1 - max(nz[0]))
        # horizontal minimal distance
        hdist = min(min(nz[1]), w - 1 - max(nz[1]))
        # get box for cropping picture
        box = hdist, vdist, w - hdist, h - vdist
    

    19:25 - Thu 2016.01.21

    Python

    Paste: /tT/Show related

    No description.

    # -*- coding: utf-8 -*-
    
    import colorsys
    import numpy
    
    class Color(object):
    
        red = None
        green = None
        blue = None
    
        hue = None
        saturation = None
        value = None
    
        alpha = None
    
        def __init__(self, red=None, green=None, blue=None, hue=None, saturation=None, value=None, alpha=None):
    
            rgb_passed = bool(red)|bool(green)|bool(blue)
    

    19:24 - Thu 2016.01.21

    Python

    Paste: /BSP/Show related

    No description.

    #!env python
    # -*- coding:utf-8 -*-
    
    #import numba # MORE MAGIC.
    
    import multiprocessing
    import time
    
    from serial import Serial
    from sys import exit
    
    import util
    import audio
    
    
    class Layer(list):
    
    
        def __init__(self, *args, **kw):
    
    

    13:56 - Thu 2015.12.10

    Python

    Paste: /1QK/Show related

    No description.

    #!/usr/bin/env python
    
    from datetime import datetime
    from time import time
    
    print(datetime.now().timestamp())
    print(time())
    

    10:41 - Thu 2015.12.10

    Python

    Paste: /xi/Show related

    No description.

    import sys
    import math
    
    # Auto-generated code below aims at helping you parse
    # the standard input according to the problem statement.
    
    
    # game loop
    while 1:
        space_x, space_y = [int(i) for i in input().split()]
        for i in range(8):
            mountain_h = int(input())
            hight = mountain_h  # represents the height of one mountain, from 9 to 0. Mountain heights are provided from left to right.
        # Write an action using print
        # To debug: print("Debug messages...", file=sys.stderr)
        print(hight,file=sys.stderr )
        # either:  FIRE (ship is firing its phase cannons) or HOLD (ship is not firing).
        if space_x == 7:
            print("FIRE")
        else:
    

    18:31 - Mon 2015.02.09

    Python

    Paste: /Ex/Show related

    ehehehe

    def problem_17(num):
        ones = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six',
                7: 'seven', 8: 'eight', 9: 'nine'}
        tens = {1: 'ten', 2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty',
                6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety'}
        teens = {1: 'eleven', 2: 'twelve', 3: 'thirteen', 4: 'fourteen',
                 5: 'fifteen', 6: 'sixteen', 7: 'seventeen', 8: 'eighteen',
                 9: 'nineteen'}
        hundreds = 'hundred'
    
        def return_string(num):
            ns = str(num)
            if len(ns) == 1:
                return ones[num]
            elif len(ns) == 2:
                if ns[1] == '0':
                    return tens[int(ns[0])]
                elif ns[0] == '1':
                    return teens[int(ns[1])]
                else:
    

    16:15 - Thu 2015.02.05

    Python

    Paste: /3OI/Show related

    progessbar

    def print_progress(frac):
        length = 30
        block = int(round(length*frac))
        text = '\r[{}] {:.3g}%'.format('#'*block + '-'*(length - block), frac*100)
        stdout.write(text)
        stdout.flush()
    

    09:17 - Wed 2014.12.24

    Python

    Paste: /jFzP/Show related

    No description.

    self._viewport = glCurrentViewport()
            glPushMatrix()
            glLoadIdentity()
            glCurrentViewport(0, 0, self.texture.width, self.texture.height)
    

    08:59 - Wed 2014.12.24

    Python

    Paste: /N9X/Show related

    No description.

    class OffscreenBuffer(object):
    
        def __init__(self, width, height):
            """ "FBO" is an OpenGL extension to do "Render to Texture", drawing in an offscreen buffer.
                It is useful as a place to chain multiple shaders,
                since each shader has its own program and we can only install one program at a time.
            """
            self.id = c_uint(_uid())
            try:
                glGenFramebuffersEXT(1, byref(self.id))
            except:
                raise (OffscreenBufferError, "offscreen buffer not supported.")
            self.texture = None
            self._viewport = (None, None, None, None) # The canvas bounds, set in OffscreenBuffer.push().
            self._active = False
            self._init(width, height)
            self._init_depthbuffer(width, height)
    
        def __enter__(self):
            self.clear()
    

    18:57 - Fri 2014.12.19

    Python

    Paste: /GY/Show related

    No description.

    
            self.vertex_list = batch.add_indexed(
                length, self.mode, group,
                indices, *[('v3f/dynamic', self.verts),
                           ('n3f/dynamic', self.norms),
                           ('c4f/static', self.color * length),
                           ('0g4f/static', weights), ('1g1i/static', w_lens),
                           ('2g4i/static', w_bone_ids)])
    

    07:31 - Wed 2014.12.17

    Python

    Paste: /4F5/Show related

    No description.

    
    old:
            glMatrixMode(GL_MODELVIEW)
            glLoadIdentity()
            glMatrixMode(GL_PROJECTION)
            glLoadIdentity()
            gluPerspective(10, 16./9, 0.1, 10000)
            gluLookAt(0, 0, 3300 * self.scale.x, x, y, 0, 0, 1, 0)
    
    
    new:
    
            mvp = Matrix.perspective(16, 9, 10,  0.1, 10000)
            mvp = mvp.look_at(0, 0, 3300 * self.scale.x, x, y, 0, 0, 1, 0)
            self.shader.set('mvp', mvp)
            self.shader.push()
    

    18:01 - Tue 2014.09.23

    Python

    Paste: /HQl/Show related

    script fuer 9ls

    def nils_diploma_thesis(stringlist):
        for st in stringlist:
            print 'bam_' + st
    

    19:49 - Fri 2014.09.05

    Python

    Paste: /Mv/Show related

    campino.py

    def process_order(order):
        if order.preferences == no_onions or order.preferences == pineapple:
            order.discard_preferences()
        return pizza
    

    17:52 - Sun 2014.06.29

    Python

    Paste: /kVJ/Show related

    No description.

    from struct import unpack
    import numpy as np
    import matplotlib.pyplot as plt
    
    from numpy.fft import *
    
    FIFO_FILE = "sine.raw"
    BIT_RESOLUTION = 16
    CHUNK_SIZE = BIT_RESOLUTION / 8 # divided by 8 to get byte count
    FREQUENCY = 44100 # Hz
    SAMPLES = 2048
    FRAME_SIZE = SAMPLES * CHUNK_SIZE
    
    T_FRAME = SAMPLES / np.float(FREQUENCY)
    
    def music_samples():
    
        with open(FIFO_FILE) as fifo:
    
            frame = fifo.read(FRAME_SIZE)
    

    14:18 - Sun 2014.06.29

    Python

    Paste: /RPq2/Show related

    No description.

    from struct import unpack
    import numpy as np
    import matplotlib.pyplot as plt
    
    from numpy.fft import hfft, fftfreq
    
    
    FIFO_FILE = "sine.raw"
    SAMPLES = 2048
    BIT_RESOLUTION = 16
    CHUNK_SIZE = BIT_RESOLUTION / 8 # divided by 8 to get byte count
    FRAME_SIZE = SAMPLES * CHUNK_SIZE
    
    def music_samples():
    
        with open(FIFO_FILE) as fifo:
    
            frame = fifo.read(FRAME_SIZE)
            raw_samples = [frame[i:i+CHUNK_SIZE] for i in range(0, SAMPLES)]
            unpacked_samples = []
    

    19:56 - Fri 2014.06.20

    Python

    Paste: /E3/Show related

    No description.

    from glob import glob
    from crosstalk import get_spectra, xtalksspec_err
    
    filelist = [f for f in glob('*_*/*') if not '.' in f]
    subgen = (get_spectra(f, (380, 560)) for f in filelist)
    xtalks = [xtalksspec_err(sub[0]) for sub in subgen]
    

    12:39 - Mon 2014.04.07

    Python

    Paste: /Zc/Show related

    pde_int

    from glob import glob
    from read_drs import event_generator, return_dtype
    from numpy import histogram, sum, log, unique, argmin, mean, inf, std
    from numpy import loadtxt, where, sqrt, arctan, sin, fromstring, r_
    from smooth import smooth
    
    
    def extract_pde(dark_counts=False, cutoff=32675, w_start=340,
                    w_len=180, small_pmt_win=False, print_pe=False):
    
        filelist = [fname for fname in glob('*_*') if not '.' in fname]
        wavelengths = unique(i[:-2] for i in filelist)
        QE_file = '/home/jammer/diplom/calib/pmt2c.dat'
        f = loadtxt(QE_file, unpack=True)
    
        pde_array = []
        wavelength_array = []
        sterr_array = []
        syserr_array = []