Skip to content

Instantly share code, notes, and snippets.

View iampeter's full-sized avatar
🏠
Working from home

Piotr Godek iampeter

🏠
Working from home
  • Morialta Software
  • Adelaide, Australia
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iampeter
iampeter / tags.md
Last active December 13, 2019 07:37
Implementing tagging in Golang with Postgres JSONB type and SQLX

When you need to handle text tags in Golang, eg. a Document can be tagged with software engineering, important and golang, you could do it with the Postgres text[] array type.

But with the jsonb type, you have all the marshalling and unmarshalling already there, so all you need to do is have a []string type, like below:

type JSONTags []string

func (tags *JSONTags) Scan(src interface{}) error {
@iampeter
iampeter / digitalocean.md
Last active August 29, 2015 14:27 — forked from JamesDullaghan/digitalocean.md
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

@iampeter
iampeter / gist:30957587b414403de27f
Created March 29, 2015 10:47
Sending SMS from Cordova without any plugin on Android using Crosswalk

Did you know that using Crosswalk you can send an SMS without any plugin in Cordova for Android?


xwalk.experimental.messaging.sms.send(number, text).then(function (message) {
  console.log("Message sent");

}), function (error) {
  console.log("Error!, Error!");
})
@iampeter
iampeter / gist:5af9c9e113e41c954364
Last active April 14, 2020 13:00
Simple proxy with hapi.js to fix your CORS problems

Problem

While building a JavaScript single page app that acts as a front-end to multiple backend servers, even if they are on the same host as the web app - but on different ports, you come across CORS issues.

Solution

Use a simple node.js + hapi.js server to:

  1. Serve your static single page app
  2. Act as proxy to the backend servers
@iampeter
iampeter / App.coffee
Last active August 29, 2015 13:59
Backbone Marionette - route handling inside modules
TodoModule = require './modules/todo/TodoModule'
class App extends Backbone.Marionette.Application
initialize: =>
@router = new Backbone.Marionette.AppRouter
@module('Todo', TodoModule)
@addInitializer( (options) =>
Backbone.history.start();