Skip to content

Instantly share code, notes, and snippets.

@camillol
camillol / spaceutil.c
Created August 6, 2011 14:54
Two ways of messing with spaces
#include <unistd.h>
#include <CoreServices/CoreServices.h>
#include <ApplicationServices/ApplicationServices.h>
typedef int CGSConnection;
extern OSStatus CGSGetWorkspace(const CGSConnection cid, int *workspace);
extern OSStatus CGSSetWorkspace(const CGSConnection cid, int workspace);
extern CGSConnection _CGSDefaultConnection(void);
int get_space_id(void);
@rwilcox
rwilcox / open_here.applescript
Created March 9, 2012 14:26
Open Here in Current iTerm Tab
tell application "BBEdit" to set theFile to file of document 1
tell application "Finder" to set theFolder to (container of file theFile) as alias
set theUnixPath to POSIX path of theFolder
tell application "iTerm"
tell current session of current terminal
write text "pushd \"" & theUnixPath & "\""
end tell
activate
end tell
@netaustin
netaustin / fabric.py
Created May 21, 2012 03:47
Fabric SSH Tunnel
from fabric.api import *
from fabric.contrib.console import confirm
from local_settings import remote_user
from time import time
import subprocess, shlex, atexit, time
from settings import DATABASES
from os import remove
env.use_ssh_config = True
env.context = 'local'
#!/bin/bash
# Set credentials for BigML and for the US Census
BIGML_USERNAME=bigml
BIGML_API_KEY=****
CENSUS_API_KEY=****
BIGML_AUTH="username=$BIGML_USERNAME;api_key=$BIGML_API_KEY"
# Download demographic data into files. Have to do it this way
# because the census API doesn't seem to allow returns of more
@wutali
wutali / fabric.rb
Created July 10, 2012 12:30
Vagrant provisioner of Fabric.
module Vagrant
module Provisioners
class Fabric < Base
class Config < Vagrant::Config::Base
attr_accessor :fabfile_path
attr_accessor :fabric_path
attr_accessor :python_path
attr_writer :tasks
def _default_fabfile_path
-- Find the note in omnifocus for the current project / folder
-- (or create a new one) and display it.
-- Created by Mark Fowler (mark@twoshortplanks.com)
-- Help from http://veritrope.com/code/search-evernote-for-notes-containing-link-to-selected-omnifocus-item/
-- on getting the name / url for the current omnifocus item
tell front window of application "OmniFocus"
try
@larsmans
larsmans / gist:3745866
Created September 18, 2012 21:00
Inspecting scikit-learn CountVectorizer output with a Pandas DataFrame
>>> from pandas import DataFrame
>>> from sklearn.feature_extraction.text import CountVectorizer
>>> docs = ["You can catch more flies with honey than you can with vinegar.",
... "You can lead a horse to water, but you can't make him drink."]
>>> vect = CountVectorizer(min_df=0., max_df=1.0)
>>> X = vect.fit_transform(docs)
>>> print(DataFrame(X.A, columns=vect.get_feature_names()).to_string())
but can catch drink flies him honey horse lead make more than to vinegar water with you
0 0 2 1 0 1 0 1 0 0 0 1 1 0 1 0 2 2
1 1 2 0 1 0 1 0 1 1 1 0 0 1 0 1 0 2
@yoavram
yoavram / ipynb-reveal-convert-and-run.sh
Last active December 11, 2015 21:28
A recipe for setting up IPython notebook nbconvert with reveal.js slideshows. .shfiles can also be used as .bat files, as long as you fix the \ / folder separator issue. The working directory will get a new nbconvert project. the ipython-notebooks is where you keep your notebooks. You will need git (I use version 1.8.0), python (I use 2.7.3), IP…
python ../nbconvert/nbconvert.py -f reveal reveal-test.ipynb
reveal-test_slides.html
@kellrott
kellrott / synapse_galaxy_sync.py
Last active August 29, 2015 14:00
Synapse to Galaxy Sync
#!/usr/bin/env python
"""
Sample call:
python synapse_galaxy_sync.py <api_key> <api_url> syn12345
NOTE: The upload method used requires the data library filesystem upload allow_library_path_paste
"""
import os
import shutil
@dgraham
dgraham / osx-setup.sh
Last active April 6, 2024 17:18
A setup script for macOS development.
xcode-select --install
if [ ! -x /opt/homebrew/bin/brew ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew tap 'homebrew/bundle'
brew tap 'homebrew/services'
brew install automake clang-format cmake icu4c libressl libxml2 openssl pkg-config readline sqlite yajl