Skip to content

Instantly share code, notes, and snippets.

@purpleP
purpleP / designer.html
Last active August 29, 2015 14:07
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../chart-js/chart-js.html">
<polymer-element name="my-element">
@purpleP
purpleP / designer.html
Created December 20, 2014 10:21
designer
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@purpleP
purpleP / designer.html
Last active August 29, 2015 14:12
designer
<link rel="import" href="../polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
from pytest import fixture, mark
from sqlalchemy import (
create_engine,
Column,
String,
Integer,
ForeignKey
)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship
@purpleP
purpleP / snippets
Created May 24, 2016 21:03
some python snippets for ultisnip
snippet fixture "pytest fixture" b
@pytest.fixture(${1})
def ${2}(${3}):
${4}
endsnippet
snippet parametrize "pytest parametrize test" b
@pytest.mark.parametrize(${1:''}, ${2:()})
def ${3}(${4}):
${5}
@purpleP
purpleP / lessparens.py
Last active December 21, 2016 20:30
What if python have parens in function calls optional where possible?
def some(a, b, c):
print a, b, c
def foo(a, b):
return a, b
def bar():
print 'bar'
@purpleP
purpleP / results.txt
Created January 5, 2017 14:04
comparing different string search methods
----------------------------------------------------------------------------------- benchmark: 3 tests -----------------------------------------------------------------------------------
Name (time in us) Min Max Mean StdDev Median IQR Outliers(*) Rounds Iterations
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_search[re_compile] 452.1870 (1.0) 1,199.2530 (1.13) 471.1449 (1.0) 56.5338 (1.0) 455.0175 (1.0) 3.9840 (1.0) 120;321 1844 1
test_search[no_compile] 521.2920 (1.15) 1,059.7880 (1.0) 554.4658 (1.18) 92.9603 (1.64) 526.5430 (1.16) 5.2185 (1.31) 28;75 388 1
test_search[endswith] 1,601.1760 (3.54) 3,252.0090 (3.07) 1,691.4124 (3.59) 246.1582
from strategies import store
@store
def name0():
pass
@store
def name1():
@purpleP
purpleP / changes.hs
Created March 9, 2017 22:33
attempt at json serialization in haskell
{-# LANGUAGE DeriveGeneric, DeriveAnyClass, StandaloneDeriving #-}
import Data.Map (empty, fromList, insert, delete, Map)
import GHC.Generics
import Data.Aeson
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Encoding as T
data Task = Task
{ id :: String

If constructing an object is entagled with different cases and conditions it's better to use factory. That's not the case here.

Instead of this.

def make_board(mines, size):
    '''function that uses my created Board methods to create the playing board'''
    board = Board(tuple([tuple([Cell(True,True,True) for i in range(size+1)]) for j in range(size+1)]))
    open_pos = list(range(size-1)*(size-1))
    for i in range(mines):