Skip to content

Instantly share code, notes, and snippets.

Question to pythonistas out there: Is it acceptable to reduce indentation by doing:

if blah:
	# do stuff
	return
# do lots of other stuff

instead of:

@mcpower
mcpower / horrible_hacky_code.py
Created March 7, 2015 08:47
Grim Patron + Bouncing Blade
from __future__ import division, print_function # Python 3 backwards compatible (and I'm lazy/hacky)
outcomes = 0
# zip mult sum
# returns [a[0] * amult + b[0] * bmult, a[1] * amult + b[1] * bmult, ...]
def zms(a, b, amult=1, bmult=1):
return list(map(lambda x, y: x * amult + y * bmult, a, b))
# cache decorator
def cache(f):
@mcpower
mcpower / grim_patron.md
Last active August 29, 2015 14:16
Grim Patron + Bouncing Blade outcomes

Stats overview:

Attack Health Chance
9 8 16.6667%
6 6 16.6667%
12 10 15.8333%
15 12 13.0556%
18 14 10.2976%
18 13 8.9116%
@mcpower
mcpower / userscript.js
Last active August 29, 2015 14:24
osu! HTML5 audio playback
// ==UserScript==
// @name osu! HTML5 audio playback
// @namespace http://your.homepage/
// @version 0.1
// @description Replaces the osu! Flash audio preview with an HTML5 one.
// @author mcpower
// @match https://osu.ppy.sh/p/beatmaplist*
// @match https://osu.ppy.sh/s/*
// @match https://osu.ppy.sh/b/*
// @grant none
L = [int(x) for x in "1307 2716 3449 2758 4597 5191 1465 2259 2829 3004".split()]
N = 20000
array = [[]] + [None for i in range(N-1)]
minimum, route = float("inf"), None
for num in L:
todo = []
for index in range(N):
#Hotstring EndChars :
#Hotstring O ?
:::+1::👍
:::-1::👎
:::100::💯
:::1234::🔢
:::8ball::🎱
:::a::🅰️
:::ab::🆎
:::abc::🔤
@mcpower
mcpower / osugame_func+.user.js
Created March 15, 2016 00:12
Userscript for /r/osugame
// ==UserScript==
// @name osugame_func+
// @namespace /r/osugame
// @author /u/N3G4
// @description Adds osu! related functionality to /r/osugame
// @include *reddit.com/r/osugame*
// @version 1.2.2
// @run-at document-end
// @grant GM_xmlhttpRequest
// ==/UserScript==
@mcpower
mcpower / fix.ps1
Created October 2, 2016 09:42
Fixing broken Windows 10 apps
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\ContactSupport_cw5n1h2txyewy\appxmanifest.xml" -Register
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy\appxmanifest.xml" -Register
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\Microsoft.AccountsControl_cw5n1h2txyewy\appxmanifest.xml" -Register
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\Microsoft.BioEnrollment_cw5n1h2txyewy\appxmanifest.xml" -Register
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\Microsoft.LockApp_cw5n1h2txyewy\appxmanifest.xml" -Register
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\appxmanifest.xml" -Register
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\Microsoft.PPIProjection_cw5n1h2txyewy\appxmanifest.xml" -Register
Add-AppxPackage -DisableDevelopmentMode "$env:windir\systemapps\Microsoft.Windows.AppRep.ChxApp_cw5n1h2txyewy\appxmanifest.x
diff -ur old/extractwifi.c new/extractwifi.c
--- old/extractwifi.c 2016-12-29 23:04:40.000000000 +1100
+++ new/extractwifi.c 2016-12-30 16:00:29.106186400 +1100
@@ -51,7 +51,7 @@
int main(int argc, char** argv) {
if(argc<2) {
printf("Usage:\n");
- printf("./extractwifi filename\n");
+ printf("./extractwifi filename [offset=b730]\n");
return -1;
@mcpower
mcpower / dynasty_preloader.user.js
Last active January 9, 2017 12:05
Dynasty Preloader
// ==UserScript==
// @name Dynasty Preloader
// @namespace http://tampermonkey.net/
// @version 0.3.5.1
// @description Preloads Dynasty Reader pages.
// @author mcpower
// @match http://dynasty-scans.com/chapters/*
// @grant none
// @license GPLv3
// ==/UserScript==