Skip to content

Instantly share code, notes, and snippets.

@gisborne
gisborne / failed-webrtc.dart
Created June 28, 2024 22:37
Failed webrtc connection
import 'package:flutter/material.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@gisborne
gisborne / terminal
Created January 24, 2020 03:01
Output of flutter run --verbose Shows failure to connect to browser
$ flutter run --verbose -d chrome
[ +48 ms] executing: [/Users/gisborne/dev/bin/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +84 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[ +2 ms] e2aa9e13cef8f3dc17c2de55dc9639d4c3968d21
[ +2 ms] executing: [/Users/gisborne/dev/bin/flutter/] git describe --match v*.*.* --first-parent --long --tags
[ +73 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[ +11 ms] v1.14.3-39-ge2aa9e13c
[ +41 ms] executing: [/Users/gisborne/dev/bin/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[ +22 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[ +1 ms] origin/master
@gisborne
gisborne / dice_row.dart
Created April 8, 2019 02:35
Why can't I access the rebuild() method from the state object?
import 'package:flutter/material.dart';
import 'dice_button.dart';
import 'dice_rack.dart';
import 'dart:developer';
class DiceRow extends StatefulWidget {
final _RowState content = _RowState();
final RackState rack;
DiceRow(this.rack);
@gisborne
gisborne / gist:3315906
Created August 10, 2012 17:24
pg_dump fails could not access file "$libdir/hstore": No such file or directory
$ pg_dump -h localhost -U webserver -p 5433 production -f backup/12-08-10.dump
pg_dump: SQL command failed
pg_dump: Error message from server: ERROR:  could not access file "$libdir/hstore": No such file or directory
pg_dump: The command was: COPY public.event_logs (id, auth_token, text, created_at, updated_at, user_id, data, remote_creation_date) TO stdout;
/home/www/.rvm/gems/ruby-1.9.2-p180/gems/authlogic-3.0.3/lib/authlogic/controller_adapters/rails_adapter.rb:48:in `<top (required)>': uninitialized constant ActionController (NameError)
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/authlogic-3.0.3/lib/authlogic.rb:62:in `<top (required)>'
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /home/www/.rvm/gems/ruby-1.9.2-p180/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /hom
$ bundle exec gem list --local
*** LOCAL GEMS ***
actionmailer (3.1.3)
actionpack (3.1.3)
activemerchant (1.7.0)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
$ gem list --local
*** LOCAL GEMS ***
abstract (1.0.0)
actionmailer (3.1.3, 3.1.0, 3.0.7, 3.0.6)
actionpack (3.1.3, 3.1.0, 3.0.7, 3.0.6)
activeadmin (0.3.2, 0.2.2)
activemodel (3.1.3, 3.1.0, 3.0.9, 3.0.7, 3.0.6)
activerecord (3.1.3, 3.1.0, 3.0.9, 3.0.7, 3.0.6)
@gisborne
gisborne / gist:1501333
Created December 20, 2011 11:55
Gemfile. pg_ext loading error
#bundle install to set this stuff up
source :rubyforge
gem 'rack'
gem 'rails', '>= 3.0.4'
#gem 'rack-ssl'
#gem 'thin'
gem 'unicorn'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
def self.create_from_array(attrs)

keys = attrs.first.keys

 d = ActiveRecord::Base.connection

d.execute <<SQL

INSERT INTO #{table_name} (#{keys * ', '}, created_at, updated_at)

 VALUES #{attrs.map do |a|
      "(#{keys.map{|k| d.quote(a[k].to_s)} * ','},

    NOW(),

          NOW())"}

ON DUPLICATE KEY UPDATE #{keys.map{|k| "#{k} = VALUES(#{k})"} * ', '}

SQL
(Thanks to Adam Grant)
Used with Autowatchr helper gem, Watchr adds testing functionality to your project
ala Zentest/autotest without the cruft and (sometimes) confusing callback hooks
that can lead someone to stop testing and turn to drinking massive amounts of Tab Cola.
The script contains a set of simple rules that map observed files to an action.
Its DSL is a single method:
watch(pattern, &action)