Skip to content

Instantly share code, notes, and snippets.

@scturtle
scturtle / ttt.py
Last active December 17, 2015 06:08
tic tac toe AI
import random
opmv = {'O': 'X', 'X': 'O'}
def print_grid(grid):
print '\n' + '\n'.join(' '.join(line) for line in zip(*[iter(grid)]*3))
def possible(grid):
return [i for i in xrange(9) if grid[i] == '_']
@scturtle
scturtle / snake.py
Last active April 29, 2018 02:27
snake AI demo with pygame
import pygame
import random
from Queue import Queue, deque
from pygame.color import Color
d = 20
WIDTH = 15
HEIGHT = 10
LEFT, RIGHT, UP, DOWN = -1, 1, -WIDTH, WIDTH
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active May 5, 2025 13:05
A badass list of frontend development resources I collected over time.
@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active March 21, 2025 15:01
Backend Architectures Keywords and References
@nodesocket
nodesocket / bootstrap.flatten.css
Last active April 1, 2021 23:37
Below are simple styles to "flatten" bootstrap. I didn't go through every control and widget that bootstrap offers, only what was required for https://commando.io, so your milage may vary.
/* Flatten das boostrap */
.well, .navbar-inner, .popover, .btn, .tooltip, input, select, textarea, pre, .progress, .modal, .add-on, .alert, .table-bordered, .nav>.active>a, .dropdown-menu, .tooltip-inner, .badge, .label, .img-polaroid {
-moz-box-shadow: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
-webkit-border-radius: 0px !important;
-moz-border-radius: 0px !important;
border-radius: 0px !important;
border-collapse: collapse !important;
background-image: none !important;
@scturtle
scturtle / simplex.py
Created July 6, 2013 12:01
simplex algorithm
from __future__ import division
try:
from numpypy import *
except ImportError:
from numpy import *
class Tableau:
def __init__(self, obj):
self.obj, self.rows, self.cons = obj, [], []
@scturtle
scturtle / addlrc.py
Last active March 4, 2023 10:10
download from music.163.com
import eyed3
import re
import glob
def get_lyric(lrc):
text = open(lrc).read()
text = re.sub(r'(?:\[.*\])+', '', text).strip()
text = map(lambda l: l.strip(), text.split('\n'))
ans = []
for l in text:
@scturtle
scturtle / rg.py
Last active May 2, 2020 04:33
Answer to regex golf http://regex.alf.nu/
plain = r'foo'
anchor = r'k$'
ranges = r'^[a-f]*$'
backrefs = r'(...).*\1'
abba = (r'^(?!' # don't (
r'.*(.)(.)\2\1.*' # parttern like abba
r'$)') # ) select
plan = r'^(.)(.).*\2\1$'
import cv2
import numpy as np
canny = rho = threshold = minLen = maxGap = None
def draw():
lines = cv2.HoughLinesP(canny, rho, np.pi / 180,
threshold, None, minLen, maxGap)
dst = cv2.cvtColor(canny, cv2.COLOR_GRAY2BGR)