Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Piotr Godek iampeter

🏠
Working from home
  • Morialta Software
  • Adelaide, Australia
View GitHub Profile
View robot.svg
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 Dec 13, 2019
Implementing tagging in Golang with Postgres JSONB type and SQLX
View tags.md

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 Aug 29, 2015 — forked from JamesDullaghan/digitalocean.md
Deploy rails app to digitalocean with nginx, unicorn, capistrano & postgres
View digitalocean.md

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 Mar 29, 2015
Sending SMS from Cordova without any plugin on Android using Crosswalk
View gist:30957587b414403de27f

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 Apr 14, 2020
Simple proxy with hapi.js to fix your CORS problems
View gist:5af9c9e113e41c954364

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 Aug 29, 2015
Backbone Marionette - route handling inside modules
View App.coffee
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();