Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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;
}
}
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 / binaryTree_pre-in-generation.c
Last active March 15, 2018 15:48
generate binary tree from pre and in order
#include "stdio.h"
void postorder(int idx, int vals[], int left[], int right[]){
if(left[idx]>-1){ postorder(left[idx], vals, left, right); }
if(right[idx]>-1){ postorder(right[idx], vals, left, right); }
printf("%d ", vals[idx]);
}
int main(void){
int n; scanf("%d", &n);
@ongspxm
ongspxm / .vimrc
Last active December 15, 2019 10:14
vimrc
" Colorscheme
colorscheme desert
syntax on
" Spaces & Tabs
set tabstop=4 shiftwidth=4 softtabstop=4 expandtab
set autoindent
retab
" Wrapping
@ongspxm
ongspxm / bathroom.java
Created April 1, 2018 05:59
2018 codejam practice
import java.util.*;
class Solution{
void run(){
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
for(int t=0; t<T; t++){
int N = cin.nextInt(),
K = cin.nextInt();
@ongspxm
ongspxm / gopher_Solution.java
Last active April 10, 2018 01:34
codejam 2018 qualifications
import java.util.*;
class Solution{
boolean allDone(boolean[][] grid, int c){
for(int i=0; i<3; i++){
for(int j=0; j<3; j++){
if(!grid[i][c+j]) return false;
}
}