This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set TOTAL=-0 | |
for /F %%i IN ('WMIC PROCESS WHERE Description^="chrome.exe" GET workingsetsize ^| findstr "[0-9]"') DO set /a TOTAL+=%%i/1024/1024 | |
echo Chrome sucked up %TOTAL%MB of RAM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RUNAS /USER:postgres "CMD.EXE" | |
SET PATH=C:\Program Files\PostgreSQL\9.2\bin;%PATH% | |
pg_upgrade.exe --check --old-datadir "c:\ProgramData\PostgreSQL\9.1\data" --new-datadir "c:\ProgramData\PostgreSQL\9.2\data" --old-bindir "C:/Program Files/PostgreSQL/9.1/bin" --new-bindir "C:/Program Files/PostgreSQL/9.2/bin" --old-port 50431 --new-port 50432 --retain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
import sys | |
import logging | |
logging.captureWarnings(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import webbrowser | |
from threading import Timer | |
os.environ["DJANGO_SETTINGS_MODULE"] = "webapp.settings" | |
import cherrypy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pywt | |
data = [1, 3, 4, 1, 2, 5, 3, 2] | |
a2, d2, d1 = pywt.wavedec(data, 'db1', level=2) | |
a1 = pywt.upcoef('a', a2, 'db1', level=1) + \ | |
pywt.upcoef('d', d2, 'db1', level=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User.objects.filter( | |
pk__in=Follow.objects.filter( | |
user=self.user, | |
content_type=ContentType.objects.get_for_model(User) | |
).extra(select={"user_ids": "object_id::integer"}).values_list("user_ids") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_node_paths(level=1): | |
""" | |
Lists node paths on the given level. | |
Order of the paths is the same as order of nodes | |
returned by `WaveletPacket2D.get_leaf_nodes`. | |
""" | |
paths = [""] | |
for i in range(level): | |
paths = [ | |
path + name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
__author__ = 'Filip Wasilewski <[email protected]>' | |
from pywt import Wavelet, dwtn, dwt_max_level | |
from pywt.numerix import as_float_array | |
def wavedecn(data, wavelet, mode='sym', level=None): | |
data = as_float_array(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Scanner: match text to generate tokens. | |
Adam Blinkinsop <[email protected]> | |
First, construct a scanner with the tokens you'd like to match described as | |
keyword arguments, using Python-syntax regular expressions. | |
WARNING: Group syntax in these expressions has an undefined effect. | |
>>> simple = Scan(ID=r'\w+') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def queryset_to_dict(qs, key='pk'): | |
""" | |
Given a queryset will transform it into a dictionary based on ``key``. | |
""" | |
return dict((getattr(u, key), u) for u in qs) | |
def distinct(l): | |
""" | |
Given an iterable will return a list of all distinct values. | |
""" |
NewerOlder