Skip to content

Instantly share code, notes, and snippets.

View nastajus's full-sized avatar

Ian Nastajus nastajus

View GitHub Profile
const express = require('express');
const multer = require('multer');
const ejs = require('ejs');
const path = require('path');
//const bodyParser = require('body-parser');
const port = process.env.PORT || 3004;
const app = express();
const storage = multer.diskStorage({
@nastajus
nastajus / Vehicle.cs
Created August 21, 2016 21:27
Visitor Pattern for Damage key methods excerpt
protected override void OnCollisionEnter2D(Collision2D col)
{
DamageVisitor damager = col.gameObject.GetComponent<DamageVisitor>();
DamageVisitable damagable = gameObject.GetComponent<DamageVisitable>();
damagable.AcceptDamageFrom(damager);
}
public override void AcceptDamageFrom(DamageVisitor damager)
{
int damageAmount = damager.CauseDamageTo(this);
select
cco.option_code, substr(cco.option_code, 18) pt_code, pt.payment_type_id, pt.PAYMENT_TYPE_CODE, pt.PAYMENT_TYPE_DESCRIPTION
from psec_client_config_option cco, paycfg_payment_type pt
where substr(cco.option_code, 18) = pt.payment_type_id
and cco.option_code like 'ACCOUNT_PATTERN%'
and cco.client_code = ( select client_code from psec_client where short_name = upper('cott'))
order by pt_code;
select
cco.option_code, substr(cco.option_code, 18) pt_code, pt.payment_type_id
from psec_client_config_option cco, paycfg_payment_type pt
where substr(cco.option_code, 18) = pt.payment_type_id
--where cco.client_code = pt.client_code
and cco.option_code like 'ACCOUNT_PATTERN%'
and cco.client_code = ( select client_code from psec_client where short_name = upper('cott'))
order by pt_code;
@nastajus
nastajus / ShowHitsComps.cs
Created April 26, 2015 22:47
Casts (and shows) a ray detecting all objects and their multiple components from the mouse cursor position outward from the camera position in the camera's direction. Always works in only Scene pane, but Gizmos needs to be on and the direction away from camera changed to see in Game pane.
// Update is called once per frame
private void Update()
{
ShowHitsComps();
}
/**
Casts (and shows) a ray detecting all objects and their multiple components from the mouse cursor
position outward from the camera position in the camera's direction. Always works in only Scene
pane, but Gizmos needs to be on and the direction away from camera changed to see in Game pane.
@nastajus
nastajus / SetPointIan_BAD.cs
Created April 19, 2015 00:32
nested ifs are the devil. NO! Do flat non-nested ifs instead, by reversing the if-statement negation and exiting instead.
//is called recursively to draw the beam of light
public void SetPoint(Vector3 origin, Vector3 direction)
{
RaycastHit2D hit = Physics2D.Raycast(origin, direction);
//hit something!
if (hit.collider != null)
{
if (hit.collider.GetComponent<Switch>().passable == true )
@nastajus
nastajus / ha.cs
Last active August 29, 2015 14:14
i just wrote this!
using UnityEngine;
public class _Ha : MonoBehaviour {
float red = 0x00;
float green = 0x00;
float blue = 0x00;
const int step = 1;
const int min = 0x08;
const int max = 0xFF;
@nastajus
nastajus / deckcard.cs
Created November 28, 2014 03:54
interview question from IBM staff: create the signatures, access specifiers, for general card game. It needs to have a deck, be shuffleable, and track the deck separately from cards on table. There are no players in this version of this simple API.
C#
class Card {
public static enum CardType { “HEART”, “SPADE”, “DIAMOND”, “CLUB” }
public CardType type;
public int num;
//said I wanted to use properties with backing fields to limit access to sets,
//only provide public gets, but that I wasn’t exactly sure how to do it
public Card( int type, int num ){
this.type = (CardType)type;
@nastajus
nastajus / Problem.java
Last active August 29, 2015 14:05
SPOJ _4138_DOUGHNUT wrong answer for problem here: http://www.spoj.com/problems/DOUGHNUT/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
* Created by IAN on 30/08/14.
*/
class Problem {
@nastajus
nastajus / control_move.cs
Created July 29, 2014 22:51
probably lame lane movement.
[RequireComponent(typeof(CharacterController))]
public class MyController : MonoBehaviour
{
enum Lane { left, middle, right };
Lane curLane = Lane.middle;
CharacterController cc;
void Start () {