Skip to content

Instantly share code, notes, and snippets.

View bjyoungblood's full-sized avatar

Ben Youngblood bjyoungblood

View GitHub Profile
@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
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 / gist:5e092d256327d3c4fee2
Last active January 21, 2020 18:34
Bamboo bulk delete disabled plan branches
jQuery('.branches > .disabled a').map(function(i, node) {
return node.href.replace('http://ci.cahtech.com/browse/', '').replace('/editConfig', '');
}).each(function(i, planKey) {
jQuery.ajax({
url : 'http://ci.cahtech.com/chain/admin/deleteChain!doDelete.action',
method : 'POST',
data : {
buildKey : planKey,
save : 'Confirm'
},
@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 / config.fish
Created December 16, 2013 15:31
~/.config/fish/config.fish
# Fish git prompt
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_showdirtystate 'yes'
set -g __fish_git_prompt_showstashstate 'yes'
set -g __fish_git_prompt_showupstream 'yes'
set -g __fish_git_prompt_color_branch magenta bold
@bjyoungblood
bjyoungblood / JsonRpcClient.php
Created August 29, 2013 15:47
simple jsonrpc 2.0 client
<?php
class JsonRpcClient {
protected $_url;
public function __construct($url)
{
$this->_url = $url;
}
@bjyoungblood
bjyoungblood / gist:6178555
Created August 7, 2013 20:55
kohana cache using apc if available
public static function cache($name, $data = NULL, $lifetime = NULL)
{
if (function_exists('apc_store'))
return self::_apc_cache($name, $data, $lifetime);
return parent::cache($name, $data, $lifetime);
}
protected static function _apc_cache($name, $data = NULL, $lifetime = NULL)
{
public function execute()
{
$this->before();
$method = $this->get_http_method();
$this->_data = $this->{$method}();
$this->after();