Skip to content

Instantly share code, notes, and snippets.

View mgutz's full-sized avatar

Mario Gutierrez mgutz

View GitHub Profile
@mgutz
mgutz / gist:3148405
Created July 20, 2012 03:02
go + postgres + pq library
package mine
import (
"fmt"
_ "github.com/bmizerany/pq"
"database/sql"
"testing"
)
@mgutz
mgutz / pgadmin3_log_debug.md
Created December 21, 2013 16:51
DEBUG messages not logged in pgAdmin3 logs

Problem

There's a bug in pgAdmin3 query editor which sets client_min_messages to NOTICE regardless of the setting in the options dialog.

Workaround

Run this statement once in each query editor window using DEBUG logging

SET client_min_messages to 'DEBUG1';

@mgutz
mgutz / gist:8343496
Last active January 2, 2016 18:29
The beauty of promises is they are values. Async and sync calls are handles the same within a `then` statement. In this example, async, sync and error handling are handled gracefully.
Promise = require('bluebird')
i = 0
printAsync = (cb) ->
setTimeout ->
console.log i++
cb()
, Math.floor((Math.random()*10)+1) # random 1..10
print = (action) ->
@mgutz
mgutz / Projfile.coffee
Last active January 3, 2016 00:08
Projmate built on gulp filters syntax. Projmate can be run in imperative mode meaning it will run JavaScript or CoffeeScript files with the usual require and function goodness. It also runs project files in JSON in JSON, CSON or YAML format. The JSON mode is for the Projmate GUI. The JSON file can be edited by hand or the GUI and it is round-tri…
Promise = require("bluebird")
coffee = require("gulp-coffee")
dest = require("gulp").dest
less = require("gulp-less")
uglify = require("gulp-uglify")
exports.imports =
S: "./simple.coffee"
exports.project = (pm) ->
module.exports = function(gee) {
return {
scripts: {
src: "src/**/*.js",
pipe: function() { return [jshint(), concat(), uglify(), dest('dist/all.js')] }
}
};
};
// to watch? simple, add -w flag

How to setup your VMWare Fusion 6 images to use static IP addresses on Mac OS X

At Crush + Lovely, we use Railsmachine's Moonshine to automate the configuration of our servers. When writing our deployment recipes, VMWare Fusion's ability to take snapshots and rollback to these snapshots is a huge timesaver because it takes just seconds to roll a server image to it's original state.

When you're just configuring a single server, having a static IP address for your server image isn't too important, but when you're configuring multi-server setups, it can be useful to duplicate a number of server images and give each a static IP address so you can consistently deploy to them. While not documented well at all, it turns out that this is relatively easy to accomplish in four simple steps.

1. Determine the MAC address of your guest machine

Let's say you have a guest machine with the name ubuntu-lucid-lynx-base

Get scope of current file
```
atom.workspace.getActiveEditor().getGrammar().scopeName
```
@mgutz
mgutz / main.yaml
Created December 21, 2017 12:14
ansible script for i3
- name: install i3 and custom utils
become: yes
apt: pkg={{item}}
with_items:
- hsetroot
- i3
- rofi
- xsel
- rxvt-unicode-256color
@mgutz
mgutz / colors.js
Last active May 30, 2019 09:05
svelte3 actions and getters using nested object store
import {readable, writable} from 'svelte/store';
// could be its own module
const util = {
_root: null,
// similar to createSelector but instead returns a reactive variable
createGetter(store, fn, initialData) {
return readable(initialData, set => {
store.subscribe(state => set(fn(state, this._root)));
@mgutz
mgutz / Antonyms.md
Created January 26, 2020 10:45 — forked from maxtruxa/Antonyms.md
A list of common terms used in programming and their respective antonyms.

Antonym List

Note: The table headings (positive/negative) are not necessarily meaningful.

Positive Negative
acquire release
add remove (e.g. an item), subtract (arithmetic)
advance retreat
allocate deallocate (correct), free (common)
allow deny