Skip to content

Instantly share code, notes, and snippets.

View rizen's full-sized avatar

JT Smith rizen

  • Plain Black Corporation
  • Madison, WI
View GitHub Profile
@rizen
rizen / this
Created September 27, 2018 02:45
test <|https://s3.amazonaws.com/files.component.studio/5128C484-1AA7-11E8-BA65-8E7192B40D46/Green-Shard.png|>
<|https://s3.amazonaws.com/dev.files.component.studio/79D8147C-5A2A-11E7-AFED-D5DDFFD078AF/engineering.png|> Engineering
@rizen
rizen / Event.pm
Created December 18, 2015 02:04
add_trigger from table
sub sqlt_deploy_hook {
my ($self, $sqlt_table) = @_;
$sqlt_table->schema->add_trigger(
name => 'trig_event_number',
perform_action_when => 'before',
database_events => [qw/insert/],
on_table => 'events',
action => 'SET NEW.event_number = (select max(event_number)+1 from events where convention_id=NEW.convention_id)',
scope => 'row',
);
@rizen
rizen / DB.pm
Last active December 30, 2015 00:20
add_trigger
package TTE::DB;
use Moose;
use utf8;
no warnings qw(uninitialized);
extends qw/DBIx::Class::Schema/;
sub sqlt_deploy_hook {
my ($self, $sqlt_schema) = @_;
$sqlt_schema->add_trigger(
@rizen
rizen / gist:5f76357f6758dd8f6f74
Last active May 12, 2021 15:32
A way to automatically format numbers that come back from a server as a string in AngularJS
myApp.directive('input', [function() {
return {
restrict: 'E',
require: '?ngModel',
link: function(scope, element, attrs, ngModel) {
if (
'undefined' !== typeof attrs.type
&& 'number' === attrs.type
&& ngModel
) {
@rizen
rizen / TGC PHP
Created November 27, 2014 02:54
PHP example for The Game Crafter's web services.
<?php
// reading in secret info via environment variables so I don't accidentally share it with anyone
$username = $_ENV['TGC_USER'];
$password = $_ENV['TGC_PASS'];
$apikey = $_ENV['TGC_API_KEY'];
// create a session
$session = post('session', array(
@rizen
rizen / gist:5826749
Created June 20, 2013 21:20
what happened
The contestentries table has a 1:1 relationship with games table via a foreign key called game_id in the contestentries table.
This works:
$db->resultset('ContestEntry')->search(undef,{order_by => [{ -desc => 'crafter_points'}, { -asc => 'me.date_created' }]});
This results in the "game" relationships being undef:
[2011-05-18 11:13:21,265][WARN ][cluster.service ] [Nowman, Michael] failed to reconnect to node [Nowman, Michael][KTKI7qHURzGMpUqhMkA0QA][inet[/10.0.2.102:9300]]
org.elasticsearch.transport.ConnectTransportException: [Nowman, Michael][inet[/10.0.2.102:9300]] connect_timeout[30s]
at org.elasticsearch.transport.netty.NettyTransport.connectToChannels(NettyTransport.java:512)
at org.elasticsearch.transport.netty.NettyTransport.connectToNode(NettyTransport.java:473)
at org.elasticsearch.transport.TransportService.connectToNode(TransportService.java:126)
at org.elasticsearch.cluster.service.InternalClusterService$ReconnectToNodes.run(InternalClusterService.java:301)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.net.ConnectException: connection timed out