Skip to content

Instantly share code, notes, and snippets.

@brthornbury
brthornbury / reactsjs-scroll-in-nav.md
Created February 3, 2017 05:49
Simple ReactJS component to support a navbar becoming visible after the user scrolls down the page.

Ensure you have raf installed: npm install --save raf

This is the code for the component.

import raf from 'raf';

export default class ScrollInNav extends Component {
  static propTypes = {
    scrollInHeight: React.PropTypes.number
@brthornbury
brthornbury / PythonBetterLambda.md
Created September 10, 2016 05:05
Lambdas that Rock, Rewriting Python on the Fly

For a long time, I've had a distaste for the syntax of lambda expressions in python.

add1 = lambda value: value + 1
print add1(1)
>>> 2

Compared to syntaxes for the same effect in other languages (like c#), it seems clunky.

------ Build started: Project: CosmosOs, Configuration: Debug Any CPU ------
CosmosOs -> C:\Users\who\Code_Work\CosmosOS\CosmosOs\bin\Debug\CosmosOs.dll
------ Build started: Project: CosmosOsBoot, Configuration: Debug x86 ------
C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets(31,5): error : Error occurred while invoking IL2CPU.
C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets(31,5): error : Exception: System.Exception: OpCode IL_0020: Initobj tries to pop item at stack position 0 with type System.Void*, but actual type is System.IntPtr
C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets(31,5): error : at Cosmos.IL2CPU.ILOpCode.InterpretStackTypes(IDictionary`2 aOpCodes, Stack`1 aStack, Boolean& aSituationChanged, Int32 aMaxRecursionDepth) in c:\Data\Sources\OpenSource\Cosmos\source\Cosmos.IL2CPU\ILOpCode.cs:line 375
C:\Program Files (x86)\MSBuild\Cosmos\Cosmos.targets(31,5): error : at Cosmos.IL2CPU.ILOpCode.InterpretInstruction(ILOpCode xNextOpCode, IDictionary`2 aOpCodes, Stack`1 aStack,
@brthornbury
brthornbury / libgdxmopubbanner
Created February 26, 2014 20:21
Stick this in the RobovmLauncher class created by the libgdx project ui for mopub ads. This is interacting with blueriver's robovm mopub bindings. You can use this to set up admob with libgdx on iOS.
@Override
public boolean didFinishLaunching (UIApplication application, NSDictionary options) {
super.didFinishLaunching(application,options);
// We need a view controller to see ads.
//rootViewController = ((IOSApplication) Gdx.app).getUIViewController();
// If you are already using a UIWindow with a root view controller, get the root view controller (f.e. LibGDX):
rootViewController = ((IOSApplication)Gdx.app).getUIViewController();
// Create a MoPub ad. In this case a banner, but you can make it any size you want.
final MPAdView banner = new MPAdView(BANNER_AD_UNIT_ID, MPConstants.MOPUB_BANNER_SIZE);
npm install -g express
express express_app
cd express_app
npm install
npm install passport passport-http-bearer