Skip to content

Instantly share code, notes, and snippets.

View theoperatore's full-sized avatar

Alex Petersen theoperatore

View GitHub Profile
@theoperatore
theoperatore / gist:4439693
Created January 3, 2013 00:26
Homebrew Warnings
Gargantua-1:~ alex$ brew doctor
Warning: Experimental support for using Xcode without the "Command Line Tools".
You have only installed Xcode. If stuff is not building, try installing the
"Command Line Tools for Xcode" package provided by Apple.
Warning: gettext files detected at a system prefix
These files can cause compilation and link failures, especially if they
are compiled with improper architectures. Consider removing these files:
/usr/local/lib/libintl.dylib
Warning: You have leftover files from an older version of Xcode.
You should delete them using:
@theoperatore
theoperatore / iterations_even_odd
Created January 30, 2013 23:24
iterations for even/odd selection
i=0; FILES=$(ls -tr ./); for FILE in $FILES; do i=$(($i + 1)); if [$(($i % 2)) = 0]; then echo"$i$FILE"; fi; done;
outputs:
==>
-bash: [0: command not found
-bash: [1: command not found
-bash: [0: command not found
...
...
...
@theoperatore
theoperatore / ShadowArray.java
Last active February 28, 2016 20:51
An array that uses a shadow array method to expand the underlying array data structure Should be Constant Time, independent of the size of the arrays
public class ShadowArray<E> implements ShadowArrayInterface<E>{
private E[] k;
private E[] s;
private int numItems;
private int carryIndex;
static final int INIT_SIZE = 5;
@SuppressWarnings("unchecked")
@theoperatore
theoperatore / BruteArray.java
Last active December 14, 2015 10:39
Brute force method -- Should be Linear Time, dependent on the size of the array
public class BruteArray<E> implements BruteArrayInterface<E>{
private E[] items;
private int numItems;
private static final int INIT_SIZE = 5;
@SuppressWarnings("unchecked")
public BruteArray() {
@theoperatore
theoperatore / BruteArrayAdd.java
Last active December 14, 2015 14:38
Add methods from a ShadowArray ADT and a BruteArrayADT
//int numItems ==> int to hold the number of Items in each underlying array
//E[] items ==> the data structure used in the BruteArray ADT
public void add(E item) {
//if the array needs to be expanded
if (numItems >= items.length) {
//create a new array that is twice as long
E[] brute = (E[])(new Object[items.length * 2]);
@theoperatore
theoperatore / query.php
Created June 5, 2013 21:08
simple php to query a connected database using AJAX. Important: USE OF DO WHILE LOOP!
<?php
require_once('db_connect.php');
if ($con) {
$select = $_POST['select'];
$from = $_POST['from'];
$where = $_POST['where'];
$where_param = $_POST['where_param'];
@theoperatore
theoperatore / character_not_proto.js
Created June 21, 2013 17:15
Best Practice? Later on, I'll need to do a check on 'features' to see if a member exists: var alex = new Character(); if (alex.features['awesome']) { //do something } else if (alex.features['job']) { //not a member }
var Character = function() {
this.char_name = 'Alex';
this.char_level = 1;
this.char_race = 'Human';
this.features = {
'field of study' : 'Computer Science',
'awesome' : true;
};
this.health = new HpSpace();
@theoperatore
theoperatore / demo.html
Created January 18, 2014 20:15
A starting point for an HTML canvas demo.
<! DOCTYPE HTML >
<html>
<head>
<meta charset='utf-8'/>
<style type="text/css">
#playground { border: 1px solid #333333; background-color: #EBEBEB; }
</style>
@theoperatore
theoperatore / pixelSwap.js
Last active November 14, 2016 01:10
pixel swapping via RGB distance checking
var canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d');
document.body.appendChild(canvas);
var dest_src = "./images/american-gothic.png",
palette_src = "./images/starry-night.png",
anim, palette, dest,
ITERATIONS = 8000;
(function init() {
@theoperatore
theoperatore / keybase.md
Created October 26, 2014 05:50
Keybase.io public verification

Keybase proof

I hereby claim:

  • I am theoperatore on github.
  • I am theoperatore (https://keybase.io/theoperatore) on keybase.
  • I have a public key whose fingerprint is DFF1 D15A 7DFE E471 E0DA 5D34 A681 841E 8617 64C8

To claim this, I am signing this object: