Skip to content

Instantly share code, notes, and snippets.

Bradley M. Froehle bfroehle

Block or report user

Report or block bfroehle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bfroehle
bfroehle / prime.cpp
Last active Dec 22, 2015
Emulate Python's for-else construct in C++.
View prime.cpp
#include <iostream>
// Emulate the for-else Python construct in C++.
// http://docs.python.org/2/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops
int main() {
for (int n = 2; n < 10; n++) {
bool success = true;
for (int x = 2; x < n || (success = false); x++) {
if (n % x == 0) {
@bfroehle
bfroehle / xstartup.custom
Created Jul 16, 2013
RealVNC xstartup script for Ubuntu 13.04. To use, save this file to `/etc/vnc/xstartup.custom` and make it executable. Then ensure that you have installed the `gnome-session-fallback` package.
View xstartup.custom
#!/bin/sh
# VNC Server (Virtual-Mode) start-up script.
unset XDG_RUNTIME_DIR
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
if [ -f /usr/bin/gnome-session ]; then
@bfroehle
bfroehle / find_bounding_box.py
Created Jun 14, 2013
Calculate the minimal bounding box of a series of images.
View find_bounding_box.py
#!/usr/bin/env python
"""Calculate the minimal bounding box of a series of images.
Example usage::
$ find_bounding_box.py *.jpg
836x680+64+0
$ mogrify -crop 836x680+64+0 *.jpg
Requires the `identify` command which is part of ImageMagick.
@bfroehle
bfroehle / kenken.py
Created May 28, 2013
SAT-based KenKen solver.
View kenken.py
"""
A SAT-based KenKen (http://www.kenken.com/) solver.
The implementation of this solver is based on the ideas contained in
the paper:
"A SAT-based Sudoku solver" by Tjark Weber
https://www.lri.fr/~conchon/mpri/weber.pdf
@bfroehle
bfroehle / xres.py
Last active Dec 16, 2015
A script to change the screen resolution and restart Nautilus.
View xres.py
#!/usr/bin/env python
"""
Change the screen resolution and restart Nautilus.
You may need to provide your VNC server with a list of available
resolutions. See:
http://stackoverflow.com/questions/15816/changing-the-resolution-of-a-vnc-session-in-linux
"""
#-----------------------------------------------------------------------------
@bfroehle
bfroehle / With Magic Demo.ipynb
Last active Dec 16, 2015
%with / %endwith IPython extension
View With Magic Demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bfroehle
bfroehle / scalapack.rb
Created Mar 3, 2013
ScaLAPACK Homebrew Formula
View scalapack.rb
require 'formula'
class Scalapack < Formula
homepage 'http://www.netlib.org/scalapack/'
url 'http://www.netlib.org/scalapack/scalapack-2.0.2.tgz'
sha1 'ff9532120c2cffa79aef5e4c2f38777c6a1f3e6a'
option 'test', 'Verify the build with make test'
option 'with-openblas', "Use openblas instead of Apple's Accelerate.framework"
@bfroehle
bfroehle / README.md
Last active Jan 22, 2018
Proof of concept of using the LLVM JIT compiler to load Python extension modules.
View README.md

Python & LLVM Extension Modules

This is a quick proof of concept of using the LLVM JIT compiler as Python's extension module loader. This implelentation completely replaces the standard extension module framework, so regular extension modules cannot be loaded. It would not be too difficult to extend the patch to allow loading both LLVM bitcode (.bc) and regular extension (.so) modules.

View ipython_all_pages.py
#!/usr/bin/env python
import re
import requests
html = requests.get('http://wiki.ipython.org/Special:AllPages')
all_pages_table = re.search('<table class="mw-allpages-table-chunk">(.*)</table>',
html.content, re.DOTALL).group()
titles = re.findall(r'title="([^"]*?)"', all_pages_table)
@bfroehle
bfroehle / umfpack.cpp
Created Dec 6, 2012
UMFPACK Numeric/Symbolic Smart Pointer in C++
View umfpack.cpp
#include "umfpack.h"
/**
* Smart pointer versions of the typical "void *Numeric" and
* "void *Symbolic" defintions.
*
* For example:
* umfpack_dl_numeric_ptr Numeric;
* umfpack_dl_numeric(..., &Numeric, ...);
* // No call to umfpack_dl_free_numeric required, as it is
You can’t perform that action at this time.