Skip to content

Instantly share code, notes, and snippets.

View nickretallack's full-sized avatar

Nick Retallack nickretallack

View GitHub Profile
$ gulp watch
module.js:338
throw err;
^
Error: Cannot find module 'orchestrator'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/nick/aurelia/navigation-app/node_modules/gulp/index.js:4:20)
---- Primary Entities
-- You search by these
create table tag (
id serial primary key,
name varchar not null,
unique (name)
);
-- The primary post type
@nickretallack
nickretallack / to_buffer.js
Created March 3, 2015 03:49
Converting the WordArray into 8-bit character values.
function to_char(number){
return [
(number & 0xff000000) >>> 24,
(number & 0x00ff0000) >>> 16,
(number & 0x0000ff00) >>> 8,
(number & 0x000000ff) >>> 0
];
}
function to_char_array(wordarray){
@nickretallack
nickretallack / backtrace
Created March 3, 2015 02:31
This happens sometimes in swagger-editor
builder.js:43 Uncaught TypeError: Cannot read property 'title' of null
builder.js:43 buildDocspreview.js:30 update
local-storage.js:17 (anonymous function)
local-storage.js:16 LocalStorage.save
editor.js:24 onAceChange
lodash.js:6879 delayed
@nickretallack
nickretallack / swagger.yaml
Created March 3, 2015 00:31
Why is this not valid?
swagger: '2.0'
info:
version: "0.0.0"
title: Example
paths:
/test:
get:
responses:
200:
description: OK
@nickretallack
nickretallack / gist:e7288159f115f4c386be
Created January 24, 2015 02:08
Unfortunately, value1 gets clobbered by value2 because they both bind to value. Is there a general purpose solution to this? My real query is much more complex and dynamically constructed than this and can't be simplified by any tricks. What I want is unique parameter names that never clobber each other.
db.session.query(MyTable).filter(
db.or_(
db.text("(my_table.json_field ->> key)::text = :value").bindparams(value=value1),
db.text("(my_table.json_field ->> key)::text = :value").bindparams(value=value2),
)
)
@nickretallack
nickretallack / testhex.go
Created December 12, 2014 01:55
Can't bind hex values in go sql?
package main
import (
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
)
type Result struct {
Testhex string
}
@nickretallack
nickretallack / test_spkac.sh
Last active January 23, 2018 05:28
This should work, right?
openssl genrsa -out private.pem 4096
openssl spkac -key private.pem > public.spkac
echo "CN=test" >> public.spkac
openssl ca -config openssl.conf -extensions client -spkac public.spkac -out signed.pem -batch
openssl pkcs12 -nodes -export -inkey private.pem -in signed.pem -out cert.p12
# No certificate matches private key
package main
import (
"net/http"
"code.google.com/p/gogoprotobuf/proto"
"path/to/protobufs"
"io/ioutil"
)
func read_protobuf(request *http.Request) *protobufs.MyMessage {
body, err := ioutil.ReadAll(request.Body)
@nickretallack
nickretallack / joins.py
Last active May 21, 2023 22:18
How do I do a join without a real foreign key constraint?
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, ForeignKey, Integer, String, ForeignKeyConstraint
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, relationship
Model = declarative_base()
class Parent(Model):
__tablename__ = 'parent'
id = Column(Integer, primary_key=True)