Skip to content

Instantly share code, notes, and snippets.

View bjyoungblood's full-sized avatar

Ben Youngblood bjyoungblood

View GitHub Profile
module.exports = function(babel) {
const { types: t } = babel;
return {
visitor: {
ClassDeclaration(path, parent) {
if (path.isClassDeclaration()) {
const className = path.node.id.name;
if (!path.node.superClass || path.node.superClass.name !== 'Error') {
return;
}
@bjyoungblood
bjyoungblood / hoc-to-render-prop.tsx
Created March 29, 2018 19:50
hoc-to-render-prop-component
type HOC<InputProps, EnhancedProps> = (component: React.ComponentType<InputProps & EnhancedProps>) =>
React.ComponentType<InputProps>;
type RenderPropProps<InputProps, EnhancedProps> = {
[P in keyof InputProps]: InputProps[P];
} & {
children: (props: EnhancedProps) => React.ReactNode;
};
type RenderProp<InputProps, EnhancedProps> = React.ComponentType<RenderPropProps<InputProps, EnhancedProps>>;
import { Pipe, PipeTransform, ArgumentMetadata, BadRequestException } from '@nestjs/common';
import { validate } from 'class-validator';
import { plainToClass } from 'class-transformer';
function isNil(obj: any): boolean {
return typeof obj === 'undefined' || obj === null;
}
@Pipe()
export class ValidationPipe<T, V> implements PipeTransform<any> {
package main
import "fmt"
func checkMap(m map[interface{}]interface{}, listName, value string) bool {
_list, ok := m[listName]
if !ok {
return false
}
@bjyoungblood
bjyoungblood / nes-redis.js
Last active September 9, 2015 13:41
Example Nes Redis Adapter
// Load modules
var Util = require('util');
var EventEmitter = require('events').EventEmitter;
var Redis = require('redis');
// Declare internals
var internals = {};
exports = module.exports = internals.Adapter = function () {
render() {
let body = this.state.smarthome.when({
pending : () => { return <div>Loading...</div>; },
failed : () => { return <div>Error loading smarthome</div>; },
done : (smarthome) => { return <SmarthomeEventsView smarthome={smarthome} />; },
});
return (
<div>
<h1>Smarthome! :D</h1>
// This happens in the main application
'use strict';
var base = require('cah-base-model');
base.init(Bookshelf.PG);
var userModule = require('users-module');
userModule.initModels(base);

Create Git Mirror from SVN Repository

This guide will demonstrate how to mirror an SVN into a Git repo. You're the target audience if you're an SVN user, just getting started with Git and need to coax your project team over to Git.

The branching scenario has been simplified for clarity.

References

@bjyoungblood
bjyoungblood / build-arm.fish
Created December 14, 2014 22:06
Cross-compile Node.JS for ARM
#!/usr/bin/fish
set -x AR arm-linux-gnueabihf-ar
set -x CC arm-linux-gnueabihf-gcc
set -x CXX arm-linux-gnueabihf-g++
set -x LINK arm-linux-gnueabihf-g++
./configure --without-snapshot --dest-cpu=arm --dest-os=linux --prefix=/usr/local
make -j 2
FROM dockerfile/nodejs
RUN mkdir /node_modules
WORKDIR /node_modules
ADD package.json .
ADD .npmrc .
RUN npm install
RUN mkdir /code
WORKDIR /code