Skip to content

Instantly share code, notes, and snippets.

View xstherrera1987's full-sized avatar

Jose Herrera xstherrera1987

  • CCC Information Services
  • Southern California
View GitHub Profile
import sublime, sublime_plugin
class ConsoleLog(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
for sel in view.sel():
selection = cursor = sel
line_region = view.line(cursor)
line_text = view.substr(line_region)
ident = line_text.replace(line_text.lstrip(), "")
if cursor.empty():
@xstherrera1987
xstherrera1987 / main()
Created August 7, 2012 06:30
what function is this?
unsigned long int powsoftwo = 1;
do {
cout << " x=" << (int) log10(powsoftwo) << " y=" << powsoftwo << endl;
powsoftwo = powsoftwo << 1;
} while (powsoftwo != 0);
@xstherrera1987
xstherrera1987 / CircBuf.h
Created July 29, 2012 07:09
Generic Circular Buffer and tests, C++
#include <stdexcept>
/*
T must implement operator=, copy ctor
*/
template<typename T> class CircBuf {
// don't use default ctor
CircBuf();
@xstherrera1987
xstherrera1987 / Main.java
Created July 28, 2012 05:39
computing prime numbers in parallel
import java.util.ArrayList;
public class Main {
static final int MAX = 100000;
static final int THREADS = Runtime.getRuntime().availableProcessors();
static final int ARRINITSIZE = 100000;
static ArrayList<Integer> primes = new ArrayList<Integer>(ARRINITSIZE);
public static void main(String[] args) throws Exception {
Thread[] t = new Thread[THREADS];
PrimeRun.m = new Monitor();