Skip to content

Instantly share code, notes, and snippets.

@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 / _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 / bplate.cpp
Created March 18, 2020 05:10
Boilerplate for cpp problems
#include <bits/stdc++.h>
#define let const auto
#define REP(var, i) for (int var = 0; var < i; ++var)
using namespace std;
using Int = int;
//using Int = long long;
using vi = vector<Int>;
using vvi = vector< vector<Int> >;
void solve() {
@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 / dec.py
Created August 11, 2019 09:38
using pillow to encode and decode files into images
import sys
from PIL import Image
try:
ifile = sys.argv[1]
ofile = sys.argv[2]
except:
print ('usage: dec.py [input file] [out file]\n\n')
img = Image.open(ifile)
@ongspxm
ongspxm / script.js
Last active November 26, 2018 11:50
vortex space terrain rendering
const WIDTH = 128;
const COLOUR = document.getElementById("colour").getContext("2d");
const HEIGHT = document.getElementById("height").getContext("2d");
const COMBIN = document.getElementById("combin").getContext("2d");
var X=WIDTH/2, Y=WIDTH/2;
var ANGLE=0, DOP=WIDTH/2;
var img_height = "https://cdn.glitch.com/3bb25b2e-fb56-49fd-96e9-a9af83d391d2%2Fheight.jpg?1513785075480";
var img_color = "https://cdn.glitch.com/3bb25b2e-fb56-49fd-96e9-a9af83d391d2%2Fcolor.jpg?1513785075766";
@ongspxm
ongspxm / dload
Last active October 30, 2018 05:52
download videos from viu using youtube-dl
# run with the starting index like so: `dload 5`
# first url on the list will be index-ed 5
# pipe in list of urls
i=$1
if [ -d $1 ]; then i=1; fi
while read f; do
name=$(echo $f | tr "/" "\n" | tail -n 1)
@ongspxm
ongspxm / fb_auth.py
Created May 23, 2015 07:35
Facebook Authentication using web.py
import web
import requests
client_id = '<client id>'
client_secret = '<client secret>'
fb_graph = 'https://graph.facebook.com/v2.3/'
urls = [
'/', 'Index',
'/login', 'Login'
@ongspxm
ongspxm / antstack_Solution.java
Last active May 8, 2018 05:12
codejam 2018 1C
import java.util.*;
class Solution{
ArrayList<Integer> weights, minWeights;
void run(){
Scanner cin = new Scanner(System.in);
int T = cin.nextInt();
for(int t=0; t<T; t++){
@ongspxm
ongspxm / travelling.py
Last active May 8, 2018 02:45
genetic adaption for travelling salesman
import math
import random
import matplotlib.pyplot as plt
import pickle
FNAME = "data.obj"
# generate 30 towns in a 1000*1000 grid
TOWN = 30
GRID = 1000