Skip to content

Instantly share code, notes, and snippets.

n, m = map(int, raw_input().split())
grid = []
for i in range(n):
grid.append(map(int, raw_input().split()))
dp = []
for i in range(n):
dp.append([0]*m)
for i in range(n):
@ongspxm
ongspxm / gmail-scheduler.gs
Last active August 3, 2017 09:28
gmail scheduler
var label = 'schedule';
function dpad(num){
if(num<10){
return "0"+num;
}else{
return num;
}
}
@ongspxm
ongspxm / keepvid.py
Last active April 22, 2024 17:32
download video using keepvid service
'''
Keepvid video downloader by ongspxm
This script uses keepvid to download videos from streaming sites (youtube, etc). Currently, it is set to download 480p quality videos. Edit to fit your needs.
The links are to be entered in this format:
[name of file w/o extension] [link to video]
To automate the process, you can combine all of the links into a list. Then you can run the script in the following manner:
@ongspxm
ongspxm / extract_posts.py
Created August 30, 2016 04:05
Extract posts from WordPress to Jekyll posts
import xml.etree.ElementTree as etree
ns = {'wp': 'http://wordpress.org/export/1.2/', 'content': 'http://purl.org/rss/1.0/modules/content/'}
blog = etree.parse('data.xml').getroot().find('channel')
for item in blog.findall('item'):
header = []
title = item.find('title').text
slug = item.find('wp:post_name', ns).text
content = item.find('content:encoded', ns).text
@ongspxm
ongspxm / rdark.scss
Created August 19, 2016 15:02
dark theme for pygment code highlighter
.highlight { background: #1e2426; color: #babdb6}
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #656763} /* Comment */
.highlight .err { color: #babdb6} /* Error */
.highlight .g { color: #babdb6} /* Generic */
.highlight .k { color: #729fcf} /* Keyword */
.highlight .l { color: #babdb6} /* Literal */
.highlight .n { color: #babdb6} /* Name */
.highlight .o { color: #babdb6} /* Operator */
.highlight .x { color: #babdb6} /* Other */
@ongspxm
ongspxm / _cat_gen.rb
Last active October 5, 2020 11:40
Tag and Category plugin for Jekyll
module Jekyll
class CatIndex < Page
def initialize(site, base, dir, cat)
@site = site
@base = base
@dir = dir
@name = 'index.html'
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'cat_index.html')
self.data['cat'] = cat
@ongspxm
ongspxm / c.py
Created May 22, 2016 02:20
2016 codejam 1C
T = input()
for t in range(T):
J, P, S, K = map(int, raw_input().split())
poss = []
for j in range(1, J+1):
for p in range(1, P+1):
if K>=S:
for s in range(1, S+1): poss.append('%d %d %d'%(j, p, s))
else:
@ongspxm
ongspxm / b.py
Created May 22, 2016 02:18
2016 codejam 1C
T = input()
for t in range(T):
B, M = map(int, raw_input().split())
fixed = []
if M>2**(B-2):
print 'Case #%d: IMPOSSIBLE'%(t+1)
else:
config = bin(M-1)[2:]
if B==2: config=''
@ongspxm
ongspxm / a.py
Created May 22, 2016 02:17
2016 codejam 1C
T = input()
grps = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
for t in range(T):
N = input()
P = map(int, raw_input().split())
plans = []
while sum(P)>0:
idx = P.index(max(P))
P[idx] -= 1
@ongspxm
ongspxm / mangareaderDownload.py
Last active October 18, 2015 05:22
Manga reader downloader
"""MangaReader downloader.
Usage:
dw.py <manga> [<chapter>] [<page>]
Options:
-h --help Show this screen
--version Show version
"""