Skip to content

Instantly share code, notes, and snippets.

View rainiera's full-sized avatar

Rainier Ababao rainiera

View GitHub Profile
with ZipFile('files.zip') as zf:
with open('probable-v2-top12000.txt', 'r') as rhandle:
pws = rhandle.read().splitlines()
for pw in pws:
try:
zf.extractall(pwd=bytes(pw,'utf-8'))
print('SUCCESS WITH {}'.format(pw))
import sys; sys.exit(0)
except Exception as e:
print(str(e))

Setting up philkr's fork of supertuxkart on a fresh Ubuntu installation

(tested on Ubuntu 16.04 LTS running on a VirtualBox)

Update and install dependencies (many suggested by the supertuxkart GitHub readme)

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git python3-pip build-essential libssl-dev libffi-dev python-dev cmake libbluetooth-dev libcurl4-gnutls-dev libfreetype6-dev libfribidi-dev libgl1-mesa-dev libjpeg-dev libogg-dev libopenal-dev libpng-dev libvorbis-dev libxrandr-dev mesa-common-dev pkg-config zlib1g-dev python3-venv python3-tk
@rainiera
rainiera / instructions.md
Created May 3, 2017 22:46
enable user/proposal search v1

Since typeahead.js is easiest to use when the list of strings to match with has been pre-populated, and we're not going to have 1000 proposals or users at any one University's instance of Enable, we are going to pre-populate the list for typeahead.js by making a DB request upon every render_template. Once you finish this, I can implement a global in-memory cache of the Enable users and proposals list, but with little time to build and smaller traffic, this iteration of the search bar can require a DB request per call for now.

Make a function that returns a list of both user.username along with their user.profile.name AND proposal.title, for every user in User and for every proposal in Proposal. You'd have to put from app.proposal.models import Proposal and from app.profile.models import User, and make a DB call. In fact, just read enable/app/proposal/views:12 to see the function I'm talking about.

➜ python git:(master) python longest_unique_substring.py
pwwkewa
[1, 0, 0, 0, 0, 0, 0]
p
[1, 2, 0, 0, 0, 0, 0]
pw
[1, 2, 1, 0, 0, 0, 0]
w
[1, 2, 1, 2, 0, 0, 0]
@rainiera
rainiera / spiral.py
Last active December 1, 2016 17:53
spiral.py
def spiral(M, num_rows, num_cols):
new_order = []
# Corner indices of submatrices
top = left = 0
bottom, right = num_rows - 1, num_cols - 1
while top <= bottom and left <= right:
# Since you're sticking to one row/col, it's sufficient to use one iterator var
for i in range(left, right + 1):
new_order.append(M[top][i])

Stuff to install on a new dev machine

  • Google Chrome
  • iTerm2 (popular bash terminal alternative)
  • Homebrew
    • git
    • mercurial
    • most databases (Redis, RethinkDB, etc.) except MySQL
    • Python if you want to use virtualenv primarily, a Homebrew Python can conflict with an Anaconda Python installation
    • Java
var org_str = "j8ck72di";
var session_str = "4734a9fc27f7fee1aa58f66046af6c49";
var base_str = "https://ct-m-fbx.fbsbx.com/fp";
var page_id = "1";
var ip_addr_str = "820139e7306525d7";
var tarpitting_param = "";
var carrier_id_enabled = "false";
var flash_tags = "true";
# Vim
git clone https://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_awesome_vimrc.sh
# Zsh
apt-get install -y zsh git-core
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
/*
* Each process computes random number
* Root process finds and prints the maximum generated value
* Have each process print its value
*
#include "mpi.h"
#include <stdio.h>
int main(int argc, char *argv[]) {
MPI_Init(&argc, &argv);
int rank;
int size;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
int slice = 45200/32;