Skip to content

Instantly share code, notes, and snippets.

" <F2> Run 'perl -cw' over the code currently being edited
" <F3> Close current window
" <F4> Run code currently being edited as a perl script
" <F5> Load these keybinds even if vim doesn't think it is a perl script
" perl -cw buffer, open output in a new window
function! PerlCWBuffer()
let l:tmpfile1 = tempname()
let l:tmpfile2 = tempname()
#!/bin/sh
function charsort
{
# accept a string and return the string sorted by character
sorted=$(for i in $(jot $(echo $1 | wc -c) 1); do
echo $1 | cut -c $i
done | sort | tr -d '\n')
echo $sorted
}
#include <stdio.h>
#include <time.h>
#ifndef isleap
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
#endif
int
main(int argc, char **argv)
{
bundle agent init
{
vars:
any::
"sl[a]" string => "aa";
"sl[b]" string => "bb";
"sl[c]" string => "cc";
# Cache images for one month
<FilesMatch ".(gif|jpg|jpeg|png|ico)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# Cache text, CSS, and javascript files for one week
<FilesMatch ".(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
set -o noclobber
set -o vi
stty erase '^?'
PATH=$PATH:~/bin
CVS_RSH=ssh
if [ -d ~/.history ]; then
HISTFILE=~/.history/hist.$(tty | sed 's;.*/;;')
@skreuzer
skreuzer / tempconvert.c
Created February 19, 2014 15:38
Temperature Conversion
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#define C2F(c) c * 9 / 5 + 32
#define F2C(f) (f - 32) * 5 / 9
int
main(int argc, char **argv)
@skreuzer
skreuzer / problem_1.pl
Created January 14, 2014 19:14
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.
#!/usr/local/bin/perl
use strict;
my $z = 0;
for my $i (0..999) {
$z += $i if(($i % 3 == 0) || ($i % 5 == 0));
}
printf("%d\n", $z);
@skreuzer
skreuzer / gist:8230481
Last active January 2, 2016 01:29
Mavericks System Preference Pane Not Working
defaults write NSGlobalDomain NSUseLeopardWindowValues YES
defaults write com.apple.Safari NSUseLeopardWindowValues NO
killall SystemUIServer
#!/bin/sh
CLUSTER=$(hostname | cut -d- -f 1)
GRAPHITE_PORT=2003
REFRESH=5
function _usage
{
echo "$0 -g graphite-server [-p graphite-port] [-c cluster-name] [-r polling-interval]"
}