Skip to content

Instantly share code, notes, and snippets.

@benjamin-wss
benjamin-wss / configureStore.js
Created September 16, 2020 10:45
Redux Persist Config
/**
* Create the store with dynamic reducers
*/
import { createStore, applyMiddleware, compose } from 'redux';
import { routerMiddleware } from 'connected-react-router';
import createSagaMiddleware from 'redux-saga';
import { persistStore } from 'redux-persist';
import createReducer from './reducers';
@benjamin-wss
benjamin-wss / object.utilities.js
Created September 5, 2019 18:21
A series of utilities I wrote to simply my work. The one here shows how I convert snake cased (snake_case) to camel case (camelCase).
'use strict';
/**
* This util class converts snake cased fields/columns into camel case from snake canse.
* @param {Object} row Object to have their fields converted to camel case from the DB native snake case.
*/
const ConvertSnakeCaseToCamelCaseFields = row => {
const keys = Object.keys(row);
const updatedRow = {};
@benjamin-wss
benjamin-wss / StringExtensionsStaticLibrary.h
Last active August 29, 2015 14:11
Replace all occurances of a string within a string with a new string (phew, quite a mouthful, no?)
#include "Object.h"
#include <string>
#include "UStringExtensionsStaticLibrary.generated.h"
UCLASS()
class MYGAME_API UStringExtensionsStaticLibrary : public UObject
{
GENERATED_BODY()
/*
@benjamin-wss
benjamin-wss / AChap.cpp
Last active August 29, 2015 14:11
How to use the migrate to the GENERATED_BODY macro in Unreal Engine 4.7
#include "GameForGentlemen.h"
#include "Chap.h"
AChap::AChap(const class FObjectInitializer& PCIP)
{
this->_IsInvalid = false;
}
AChap:PublicMethodGuv()
{
@benjamin-wss
benjamin-wss / StringBuilder.js
Last active August 28, 2019 16:44
String builder for JavaScript
function StringBuilder(value) {
this.strings = new Array();
this.append(value);
}
StringBuilder.prototype.append = function (value) {
if (value) {
this.strings.push(value);
}
}
@benjamin-wss
benjamin-wss / ActorCompass.cpp
Created October 27, 2014 07:02
Unreal Engine C++ Compass Code
const FRotator Rotation = this->Controller->GetControlRotation();
// following section will get the characters rotation for direction
float directionTheCharacterIsFacing = Rotation.Yaw + 22.5f; //Offset rotation to account for your 359.999 to 0 crossover
// if yaw is less than 0, add 360 so we can get a positive value.
if (directionTheCharacterIsFacing < 0)
{
directionTheCharacterIsFacing = directionTheCharacterIsFacing + 360.f;
}
@benjamin-wss
benjamin-wss / MyCharacter.cpp
Created October 14, 2014 13:42
Getting your Unreal Character to point towards your mouse cursor.
#include "MyGame.h"
#include "MyBaseCharacterBase.h"
#include "MyBaseCharacterBaseController.h"
AMyBaseCharacterBase::AMyBaseCharacterBase(const class FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
// Set size for collision capsule
CapsuleComponent->InitCapsuleSize(42.f, 96.0f);
@benjamin-wss
benjamin-wss / EnumeratingXmlNamespaceManager
Created September 3, 2014 13:49
A way to enumerate the stored namespaces within the XmlNamespaceManager
var doc = XDocument.Parse(myXmlString);
var xmlNamespaceManager = new XmlNamespaceManager(new NameTable());
xmlNamespaceManager.AddNamespace("x", "http://myAwesomeXmlNamespace/");
xmlNamespaceManager.AddNamespace("y", "http://yetAnotherAwesomeXmlNamespace/");
//gets all registered namespaces as a IDictionary/Hash Table
IDictionary<string, string> myNamespaces = xmlNamespaceManager.GetNamespacesInScope(XmlNamespaceScope.All);
foreach(var myNamespace in myNamespaces)
@benjamin-wss
benjamin-wss / InstallMicrosoft.Web.InfrastructureViaNuget.ps1
Last active August 29, 2015 14:03
Package Manager command to install Microsoft.Web.Infrastructure dlls into project
PM > Install-Package Microsoft.Web.Infrastructure
Installing 'Microsoft.SharePoint.Client 14.0.4762.1000'.
Successfully installed 'Microsoft.SharePoint.Client 14.0.4762.1000'.
Adding 'Microsoft.SharePoint.Client 14.0.4762.1000' to FluxCapacitorWebApp.
Successfully added 'Microsoft.SharePoint.Client 14.0.4762.1000' to FluxCapacitorWebApp.
@benjamin-wss
benjamin-wss / JsonExtensions
Created July 4, 2014 17:26
Encapsulated JSON.net Code
using Newtonsoft.Json;
namespace ExtensionMethodEncapsulation
{
public static class JsonExtensions
{
/// <summary>
/// Method to encapsulate how you serialize your JSON object.
/// </summary>
/// <typeparam name="T">The type of the object/POCO you wish to convert to JSON.</typeparam>