Skip to content

Instantly share code, notes, and snippets.

View LeviSchuck's full-sized avatar

Levi LeviSchuck

View GitHub Profile
@LeviSchuck
LeviSchuck / main.php
Created March 14, 2011 02:06
main.php of PHP OOP Tutorial 2
<?php
//Object Oriented Programming in PHP Intro #2
class bank {
private $name = '';
public function __construct($name) {
echo "Starting the bank: $name.";
$this->name=$name;
}
public function iHaveThisMuchMoney(){
$sum = 0;
@LeviSchuck
LeviSchuck / OOP3.php
Created March 20, 2011 18:35
PHP OOP Tutorial 3: Implementing interfaces, utilizing structure
<?php
//PHP Object Oriented Programming Tutorial 3
interface person {
function myName();
function myPosition();
}
class employee implements person {
public function myName(){
return "Happy ". ucfirst(__CLASS__);
}
@LeviSchuck
LeviSchuck / superminimalogre.cpp
Created November 28, 2011 19:45
Super Minimal Ogre conceptual application
#include <iostream>
#include <OGRE/OgreRoot.h>
#include <OGRE/OgreRenderSystem.h>
#include <OGRE/OgreRenderWindow.h>
#include <OGRE/OgreSceneManager.h>
#include <OGRE/OgreColourValue.h>
#include <OGRE/OgreCamera.h>
#include <OGRE/OgreViewport.h>
#include <OGRE/OgreEntity.h>
#include <OGRE/OgreWindowEventUtilities.h>
@LeviSchuck
LeviSchuck / gist:3474185
Created August 26, 2012 04:46
Clean database not iterating
function cleanDatabase() {
Log.warning("db_cleanup", "Attempting to clean Database")
_ = Iter.map(function(plant){
//Db.remove(@/cactusdb/Plants[{id: plant.id}])
Log.warning("db_cleanup", "Deleting Plant {plant.id}")
void
},Model.get_plants())
_ = Iter.map(function(display){
Log.warning("db_cleanup", "Deleting Plant Display {display.id}")
@LeviSchuck
LeviSchuck / cyclicStrToLong.cpp
Created October 20, 2012 19:24
Takes a string, be it statically const or not, and makes an 8-byte long
#include <iostream>
using namespace std;
unsigned long attrID2(const char * ls){
const unsigned long golden = 0x9E3779B97f4A7C15;
unsigned long result = 0;
int offset = 0;
for(int i=0; ls[i] != 0; i++,offset = (offset + 1) % sizeof(long)){
const unsigned long p = ((long)ls[i] << (offset*8));
const unsigned long p2 = ((long)1 << (i%(sizeof(long)*8))) & golden;
0x7fff721a6180: START LEAK DETECTED!
0x7fff721a6180: Meatless has 1 entries!
0x7fff721a6180: Meatless 0xbeef
0x7fff721a6180: BANANAS has 1 entries!
0x7fff721a6180: BANANAS 0xdead
0x7fff721a6180: Apples has 2 entries!
0x7fff721a6180: Apples 0xdeadbeef
0x7fff721a6180: Apples 0xdeadeeeeee
-- No hiding Route
import Yesod as Import
-- ...
--Assumes that "App" is your context
type RouteRenderer = (Route App -> Text)
@LeviSchuck
LeviSchuck / KV.hs
Created July 27, 2013 21:44
I'm having trouble with having subparts be of the same typeclass but not necessarily the same kind of data.
class KVEntity a where
kvIdentity :: a -> KVIdentifier
kvProperties :: a -> Value
kvLastModified :: a -> UTCTime
kvClass :: a -> KVClass
kvRelations :: a -> [KVLink]
kvCachedRels :: a -> [a]
kvProperties _ = emptyObject
kvCachedRels _ = []
-- Suppose I have this type class
externalFunction :: SomeData -> Blah -> a -> SomethingElse
class Something a where
someConstant :: a -> SomeData
another :: Blah -> a -> SomethingElse
another b a = externalFunction (someConstant (undefined :: "This Type class instance")) b a
{-# LANGUAGE DeriveDataTypeable #-}
module KV2 where
import qualified Solar.Data.KV as K
import System.IO.Unsafe(unsafePerformIO)
import Data.Time.Clock
import Data.Text(pack)
import Data.Typeable
import GHC.Generics as G