Skip to content

Instantly share code, notes, and snippets.

@Bouke
Bouke / gist:10454272
Last active September 22, 2023 17:23
Install FreeTDS, unixODBC and pyodbc on OS X

First, install the following libraries:

$ brew install unixodbc
$ brew install freetds --with-unixodbc

FreeTDS should already work now, without configuration:

$ tsql -S [IP or hostname] -U [username] -P [password]
locale is "en_US.UTF-8"

locale charset is "UTF-8"

@Bouke
Bouke / gist:11261620
Last active August 3, 2023 01:46
Multiple Python installations on OS X

Previous versions used homebrew to install the various versions. As suggested in the comments, it's better to use pyenv instead. If you are looking for the previous version of this document, see the revision history.

$ brew update
$ brew install pyenv
$ pyenv install 3.5.0
$ pyenv install 3.4.3
$ pyenv install 3.3.6
$ pyenv install 3.2.6
$ pyenv install 2.7.10

$ pyenv install 2.6.9

@Bouke
Bouke / StringDecimalConverter.cs
Last active August 27, 2020 10:15
Serialize decimal to string in Newtonsoft.Json
public class StringDecimalConverter : JsonConverter
{
public override bool CanRead
{
get
{
return false;
}
}
@Bouke
Bouke / settings.py
Created September 2, 2012 13:22
Django simple sqlite config
import os
# Define PROJECT_PATH as the project's root directory, according to new 1.4 layout:
#
# root
# |-- manage.py
# |-- project
# |-- settings.py
PROJECT_PATH = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@Bouke
Bouke / ajax-request.d.ts
Created June 19, 2018 04:16
TypeScript typings for ember-ajax
declare module 'ember-ajax/ajax-request' {
import Ember from 'ember';
import AjaxRequestMixin from 'ember-ajax/mixins/ajax-request';
export default class AjaxRequest extends Ember.Object.extend(AjaxRequestMixin) { }
}
@Bouke
Bouke / copy-last-commit-id-to-clipboard.sh
Created August 27, 2010 12:23
Copy commit-id to clipboard in post-commit hook
#!/bin/sh
# Use this per example as a post-commit hook
git log -n 1 --pretty=%H | tr -d '\n' | xclip -sel clip
echo "\033[32mCopied commit-id to clipboard\033[0m"
@Bouke
Bouke / ember-select.js
Created April 11, 2013 14:31
Ember.Select allowing options to be disabled. Usage `{{view Ember.Select ... optionDisabledPath="content.disabled"}}`
var get = Ember.get, getPath = Ember.getPath, set = Ember.set, fmt = Ember.String.fmt;
Ember.Select.reopen({
optionDisabledPath: null
});
Ember.SelectOption.reopen({
attributeBindings: ['disabled'],
init: function() {
@Bouke
Bouke / aws_usage.py
Last active April 19, 2017 18:01 — forked from rcoup/aws_usage.py
Catch login failures / captcha input
#!/usr/bin/env python
"""
A script to query the Amazon Web Services usage reports programmatically.
Ideally this wouldn't exist, and Amazon would provide an API we can use
instead, but hey - that's life.
Basically takes your AWS account username and password, logs into the
website as you, and grabs the data out. Always gets the 'All Usage Types'
@Bouke
Bouke / postactivate
Created January 8, 2014 18:37
Python virtualenvwrapper
#!/bin/bash
# This hook is run after every virtualenv is activated.
#create project directory and cd into it
env_name="`basename \"$VIRTUAL_ENV\"`"
env_name="${env_name/-py3/}"
pwd_root="$HOME/Sites/$env_name"
if [ ! -d "$pwd_root" ] ; then
echo "Creating directory $pwd_root"
mkdir "$pwd_root"
@Bouke
Bouke / gist:7579228
Last active December 28, 2015 23:29
Fetch a pull request without adding the requester's repo as a remote
git fetch origin pull/[id]/head:pull/[id]