Skip to content

Instantly share code, notes, and snippets.

@badp
badp / better_in_every_single_way.py
Last active August 29, 2015 14:00
Calculate partial product ordering over dictionaries of tuples assuming bigger numbers are better than smaller numbers, and strings are better than others if they have more of each character ("FFF" > "FF" but "FFF" ≯ "FA")
# Name (Def Def% MDef Mdef% Slots Links, Rate, Flags)
ff7_armor = {
"Bronze Bangle": (8, 0, 0, 0, 0, 0, 0, ""),
"Iron Bangle": (10, 0, 2, 0, 1, 0, 1, ""),
"Titan Bangle": (14, 2, 4, 0, 2, 0, 1, ""),
"Mythril Armlet": (18, 3, 8, 0, 2, 1, 1, ""),
"Carbon Bangle": (27, 3, 14, 0, 3, 1, 1, ""),
"Silver Armlet": (34, 4, 22, 0, 3, 1, 1, ""),
"Gold Armlet": (46, 4, 28, 0, 4, 2, 1, ""),
"Diamond Bangle": (57, 6, 37, 0, 5, 2, 1, ""),
@badp
badp / ligaturify.py
Created June 21, 2010 07:35
Put ligatures where possible. Save characters.
#/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
if sys.version_info < (3,):
raise Exception("This requires Python 3 to run. Sorry.")
ligatures = { "db": "ȸ",
"AE": "Æ",
"ae": "æ",
@badp
badp / pastebin.py
Created June 24, 2010 09:07
Quick and dirty pastebin interface in Pyhton
import urllib
valid_expiration_values = ('N', '10M', '1H', '1D', '1M')
def postToPastebin( message,
title = "RTBot",
subdomain = "rtbot",
expire_date = "1D",
format = "text"):
@badp
badp / isgd.py
Created June 24, 2010 09:32
Quick and dirty is.gd interface in Python
import urllib
def isgd(url):
request_dict = {"longurl": url}
request = urllib.urlencode(request_dict)
result = urllib.urlopen("http://is.gd/api.php?" + request)
if result.getcode() == 500:
raise ValueError(result.read())
else:
return result.read()
@badp
badp / mockup.xml
Created September 9, 2010 08:28
SO Close dialog with additional migration step
<mockup version="1.0" skin="sketch" measuredW="568" measuredH="1453" mockupW="514" mockupH="1402">
<controls>
<control controlID="13" controlTypeID="com.balsamiq.mockups::Canvas" x="44" y="41" w="461" h="504" measuredW="100" measuredH="70" zOrder="0" locked="false" isInGroup="-1"/>
<control controlID="14" controlTypeID="com.balsamiq.mockups::Label" x="60" y="51" w="-1" h="-1" measuredW="330" measuredH="25" zOrder="1" locked="false" isInGroup="-1">
<controlProperties>
<bold>true</bold>
<size>16</size>
<text>Why%20should%20this%20question%20be%20closed%3F</text>
</controlProperties>
</control>
<mockup version="1.0" skin="sketch" measuredW="507" measuredH="529" mockupW="343" mockupH="519">
<controls>
<control controlID="298" controlTypeID="com.balsamiq.mockups::Canvas" x="165" y="35" w="322" h="63" measuredW="100" measuredH="70" zOrder="0" locked="false" isInGroup="-1">
<controlProperties>
<color>13421772</color>
</controlProperties>
</control>
<control controlID="299" controlTypeID="com.balsamiq.mockups::Label" x="306" y="51" w="-1" h="-1" measuredW="39" measuredH="29" zOrder="1" locked="false" isInGroup="-1">
<controlProperties>
<size>16</size>
/* bonus: die Tahoma die! */
a.question-hyperlink,
a.answer-hyperlink,
table.history-table a.question-hyperlink,
table.history-table a.answer-hyperlink,
#question-suggestions a.question-hyperlink,
#questions a.question-hyperlink,
table.summary-table a.question-hyperlink,
table.summary-table a.answer-hyperlink,
$.fn.each2 = function(callback)
{
for ( var i = 0; i < this.length; ++i ) {
jQueryObj = this.eq(i)
if( callback.call( jQueryObj, i, jQueryObj) === false){
break;
}
}
};
[7320] 11-17 23:49:14:123: RasGetConnectStatus: read phonenumber </endpoint-address> from port user data
[9988] 11-17 23:49:14:127: NotifyCaller done (dwNotifyResult=1)
[9988] 11-17 23:49:14:128: GetLogonUser=Santi
[9988] 11-17 23:49:14:128: GetLogonDomain=DELTA
[9988] 11-17 23:49:14:129: RASCS_ConnectDevice
[9988] 11-17 23:49:14:129: RasDeviceSetInfo done(0)
[9988] 11-17 23:49:14:129: SetDeviceParamBinary for RDT_Tunnel_Sstp
[9988] 11-17 23:49:14:130: GUID is 625d2c97-313d-48b2
[9988] 11-17 23:49:14:159: GetSstpDestinationInfo completes with 0: Proxy Query Status: 0 DestInfoSize: 120
[9988] 11-17 23:49:14:159: GetSstpDestinationInfo completes with CorrelationID length 16.GUID is 625d2c97-313d-48b2