Skip to content

Instantly share code, notes, and snippets.

@crisward
crisward / gulp watchify
Last active August 29, 2015 13:56
Gulp Stylus Browserify - added error handling for production. Need to work out errors for watchify task.
var source = require('vinyl-source-stream'),
watchify = require('watchify'),
gulp = require('gulp'),
fs = require('fs'),
gulp = require('gulp'),
browserify = require('gulp-browserify'),
uglify = require('gulp-uglify'),
ngmin = require('gulp-ngmin'),
stylus = require('gulp-stylus'),
livereload = require('gulp-livereload'),
+ case "$(lsb_release -si)" in
++ lsb_release -si
+ export DOKKU_DISTRO=ubuntu
+ DOKKU_DISTRO=ubuntu
+ export DOKKU_IMAGE=gliderlabs/herokuish
+ DOKKU_IMAGE=gliderlabs/herokuish
+ export DOKKU_LIB_ROOT=/var/lib/dokku
+ DOKKU_LIB_ROOT=/var/lib/dokku
+ export PLUGIN_PATH=/var/lib/dokku/plugins
+ PLUGIN_PATH=/var/lib/dokku/plugins
@crisward
crisward / crystal-exception.log
Created August 27, 2016 17:27
crystal db exception
Exception: end of file reached (IO::EOFError)
[4340973938] *CallStack::unwind:Array(Pointer(Void)) +82
[4340973841] *CallStack#initialize:Array(Pointer(Void)) +17
[4340973800] *CallStack::new:CallStack +40
[4340944489] *raise<Exception+>:NoReturn +25
[4341592831] *DB::Database@DB::QueryMethods#query<String, String>:MySql::ResultSet +143
[4341685147] *Pages#from_path<String>:(Page | Nil) +43
[4341636559] *Pages#render_path<HTTP::Server::Context>:(Int32 | String | Nil) +287
[4340948641] ~procProc(HTTP::Server::Context, (Int32 | String | Nil))@./src/crystal2.cr:26 +33
[4340947973] ~proc3Proc(HTTP::Server::Context, String)@./libs/kemal/kemal/route.cr:11 +101
@crisward
crisward / db-result.cr
Last active September 25, 2016 20:16
Select fields
struct Org
DB.mapping({
id: Int32,
name: {type: String, nilable: true},
address: {type: String, nilable: true},
postcode: {type: String, nilable: true},
created_at: {type: Time, nilable: true},
updated_at: {type: Time, nilable: true},
deleted_at: {type: Time, nilable: true},
@crisward
crisward / mess.cr
Last active October 21, 2016 13:54
kemal mysql
require "./mess/*"
require "kemal"
require "json"
require "mysql"
require "pool/connection"
db = ConnectionPool.new(capacity: 25, timeout: 0.01) do
DB.open(ENV["DATABASE_URL"])
end
@crisward
crisward / test.cr
Created November 24, 2016 09:33
testing crystal
Module App
Class UserService
initialize(@orgService : OrgService)
end
def get(id)
db.sql("select * from users where id = ?")
#....
user.org = @orgService.get(user.org_id)

The line of code causing this looks like this. Publish and button are int8

      res = @db.exec("
        Update pages set
        title = ?, parent_id = ?, template = ?, publish = ?, button = ?,`order` = ?,
        meta = ?, created_at = ?, updated_at = ?
        where id = ?
      ", title, parent_id, template, publish, button, order, meta, created_at, updated_at, id)
@crisward
crisward / mess.cr
Created December 10, 2016 21:47
crystal passing class method as a callback
class Do
def that
x = 10
while x > 0
yield x
x-=1
end
end
end
@crisward
crisward / crystaldb-0.21.0-dump
Created February 22, 2017 11:12
crystaldb-0.21.0-dump
Error in src/app/database/database.cr:11: instantiating 'DB:Module#open(String)'
@@db : DB::Database = DB.open(DBURL + "?max_pool_size=10&initial_pool_size=2&max_idle_pool_size=2")
^~~~
in lib/db/src/db.cr:103: instantiating 'build_database(String)'
build_database(uri)
^~~~~~~~~~~~~~
2017-06-27T08:17:13.468857074Z app[web.1]: Invalid memory access (signal 11) at address 0x0
2017-06-27T08:17:13.470053308Z app[web.1]: [0x6363d5] *CallStack::print_backtrace:Int32 +117
2017-06-27T08:17:13.470384157Z app[web.1]: [0x5f2ecd] __crystal_sigfault_handler +61
2017-06-27T08:17:13.471176757Z app[web.1]: [0xd2d9b4] sigfault_handler +40
2017-06-27T08:17:13.471234670Z app[web.1]: [0x7f44602c3340] ???
2017-06-27T08:17:13.471644884Z app[web.1]: [0x7f4460bd5dd9] ???
2017-06-27T08:17:13.471718207Z app[web.1]: [0x7f4460bd6a63] ???
2017-06-27T08:17:13.472143543Z app[web.1]: [0x7f4460bd6bc9] ???
2017-06-27T08:17:13.472553163Z app[web.1]: [0x7f4460bd8931] ???
2017-06-27T08:17:13.472859127Z app[web.1]: [0xa98316] *OpenSSL::SSL::Socket::Client#initialize<TCPSocket, OpenSSL::SSL::Context::Client, Bool, String>:Nil +182