Skip to content

Instantly share code, notes, and snippets.

Jared Barboza codeimpossible

Block or report user

Report or block codeimpossible

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
@codeimpossible
codeimpossible / CameraController2D.cs
Created Dec 6, 2017
Camera Controller for my 2D Game
View CameraController2D.cs
using UnityEngine;
public class CameraController2D : MonoBehaviour
{
public Transform ObjectToFollow;
public Camera CameraToMove;
public Vector2 CameraPositionOffset = Vector2.zero;
public Vector3 CameraTrackingBox = Vector3.one;
@codeimpossible
codeimpossible / PathController.cs
Created Nov 25, 2017
Really simple path follower script for unity
View PathController.cs
using UnityEngine;
public enum PathMovementStyle
{
Continuous,
Slerp,
Lerp,
}
public class PathController : MonoBehaviour
{
@codeimpossible
codeimpossible / GameManager.cs
Created Nov 22, 2017
Cross Platform GamePad Input for Unity
View GameManager.cs
using System;
using UnityEngine;
public class GameManager : MonoBehaviour {
public IInputSystem Input;
public static GameManager Instance;
void Awake() {
@codeimpossible
codeimpossible / README.md
Created Feb 2, 2017
Looping inside promises
View README.md

Promise Loops

I was building a CLI for GitHub code search which was using promises pretty heavily as the control flow of the application. It worked well enough in the beginning because the network library was promise based. However I wanted to add a feature where you could query the JSON returned by the GitHub API using json-query. This required that the user enter a REPL-type interaction, where they can enter a command and see the output, rinse and repeat until they have the data they want.

The problem is that all of the I/O in node is non-blocking. This means that all the libraries i looked at to capture user input from the command line were all either prommise based, or used node style method(data, callback) invocations. This ruled out my first option: using a while loop inside a promise to repeat the REPL until the user entered 'done'. If I did this I'd end up firing hundreds or thousands of calls to readline (the library I ended up using) to gather user i

@codeimpossible
codeimpossible / Program.cs
Last active Jan 9, 2017
Example of determining dependency injection based on interface attribute.
View Program.cs
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Collections;
using System.Reflection;
using System.Threading.Tasks;
namespace ConsoleApp1
{
View get-all-projects-with-nuget-package.ps1
# needs to be run in Package Manager Console
# i made this multiple lines for readability,
# you might need to compact it to one to run it
Get-Project -All | ForEach-Object {
Write-Host "";
Write-Host $_.ProjectName;
Write-Host "------------";
Get-Package -ProjectName $_.ProjectName -Filter <PACKAGE_NAME> | ForEach-Object {
Write-Host ($_.Id, $_.Version) -Separator " "
}
@codeimpossible
codeimpossible / 1-hoisting.js
Last active Aug 29, 2015
Variable hoisting
View 1-hoisting.js
var variable = "global";
function doSomething() {
console.log(variable);
var variable = 'local';
console.log(variable);
}
doSomething();
@codeimpossible
codeimpossible / blog-post-importer.es6
Created Jun 29, 2015
Abstract Factory, with self-registration!
View blog-post-importer.es6
let subclasses = {};
export default class BlogPostImporter {
constructor(body) {
for(var p in body) {
if(body.hasOwnProperty(p)) {
this[p] = body[p];
}
}
}
@codeimpossible
codeimpossible / pod-pub.ps1
Created Feb 7, 2015
Script to automate our podcast publishing
View pod-pub.ps1
Param (
[Parameter(Mandatory=$True)]
[string]$url
)
# this assumes you have youtube-dl installed
# choco install youtube-dl
# this also assumes you have ffmpeg installed
# choco install ffmpeg
You can’t perform that action at this time.