Skip to content

Instantly share code, notes, and snippets.

@joequery
joequery / gist:3425222
Created August 22, 2012 12:42
Ghetto Autotest
#!/bin/bash
# Our ghetto auto-testish thing. User presses any key to test,
# Ctrl-C to get out. Make this file executable, place in your path, and run in
# your Ruby project's directory. Assumes your tests are located in spec/
# Technically 100% more convenient than up+enter! ;)
function hold(){
read -n 1 -s
}
@joequery
joequery / gist:3421153
Created August 22, 2012 01:20
Postfix Calculator
// Implement a post-fix calculator using a stack.
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
#define MAX_ELEMENTS 100
#define ROGUE_VALUE -99999
typedef int stackdata_t;
typedef struct{
@joequery
joequery / gist:3418841
Created August 21, 2012 19:54
Vim Toggle Relative Line Numbers
" use Ctrl+L to toggle the line number counting method
function! g:ToggleNuMode()
if &nu == 1
set rnu
else
set nu
endif
endfunction
nnoremap <silent><C-L> :call g:ToggleNuMode()<cr>
@joequery
joequery / gist:3418565
Created August 21, 2012 19:31
Tab or complete
"Use TAB to complete when typing words, else inserts TABs as usual.
function! Tab_Or_Complete()
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
return "\<C-N>"
else
return "\<Tab>"
endif
endfunction
inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>
@joequery
joequery / gist:3398622
Created August 19, 2012 23:40
New Ubuntu Machine
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install chromium-browser
sudo apt-get install git
sudo apt-get install vim
sudo apt-get install screen
ssh-keygen -t rsa
mkdir ~/web
mkdir ~/web/github
mkdir ~/web/lab
/Downloads$ sudo apt-get update; lsb_release -a
Ign http://mirror.lstn.net precise InRelease
Ign http://mirror.lstn.net precise-security InRelease
Ign http://mirror.lstn.net precise-updates InRelease
Ign http://mirror.lstn.net precise-proposed InRelease
Ign http://mirror.lstn.net precise-backports InRelease
Hit http://mirror.lstn.net precise Release.gpg
Hit http://mirror.lstn.net precise-security Release.gpg
Hit http:
@joequery
joequery / gist:3390776
Created August 19, 2012 01:23
Upgrade fail part 2
E: Unmet dependencies. Try using -f.
~/Downloads$ sudo apt-get upgrade -f
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages have been kept back:
hplip hplip-data libhpmud0 libsane-hpaio linux-generic linux-headers-generic linux-image-generic printer-driver-hpcups printer-driver-hpijs vlc vlc-nox vlc-plugin-notify vlc-plugin-pulse
The following packages will be upgraded:
accountsservice akregator apport apport-kde aptdaemon aptdaemon-data ark banshee banshee-extension-soundmenu base-files bind9-host cron cups cups-bsd cups-client cups-common cups-driver-gutenprint cups-ppdc dconf-gsettings-backend
@joequery
joequery / gist:3365121
Created August 16, 2012 00:48
Upgrade fail
/etc/apt$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
libqt4-declarative : Depends: libqt4-sql (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
Depends: libqt4-xmlpatterns (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
libqt4-declarative:i386 : Depends: libqt4-sql:i386 (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
Depends: libqt4-xmlpatterns:i386 (= 4:4.8.1-0ubuntu4.2) but 4:4.8.1-0ubuntu4.1 is installed
@joequery
joequery / gist:3229108
Created August 1, 2012 17:36
Toggl relative line numbers
" use Ctrl+L to toggle the line number counting method
function! g:ToggleNuMode()
if &nu == 1
set rnu
else
set nu
endif
endfunction
nnoremap <C-L> :call g:ToggleNuMode()<cr>
@joequery
joequery / gist:3103138
Created July 13, 2012 06:32
How to Read a Programming Tutorial (gist backup)

Many of us seek to improve ourselves beyond what's required. Many CS students are not content to just make good grades in class; they want to get their hands dirty with real-world projects. Many employees read up on the latest languages and frameworks well beyond office hours, simply because they want to play with technology while learning to build a better product. It's important, however, to ensure our time spent studying new programming techniques does not go to waste.

!(confused) != knowledgeable