Skip to content

Instantly share code, notes, and snippets.

@MatthaeusHarris
MatthaeusHarris / interfaces
Created July 30, 2018 17:25
OpenVSwitch Proxmox VLAN configuration
auto lo
iface lo inet loopback
allow-vmbr0 vlan4
iface vlan4 inet static
address 172.16.4.38
netmask 255.255.254.0
gateway 172.16.4.1
ovs_type OVSIntPort
ovs_bridge vmbr0
@MatthaeusHarris
MatthaeusHarris / str_to_int.c
Created September 19, 2017 21:11
str_to_int function, with no bounds error checking
#include <stdio.h>
int char_is_int(char c) {
return c >= '0' && c <= '9';
}
int char_to_int(char c) {
return c - '0';
}
@MatthaeusHarris
MatthaeusHarris / fizzbuzz_no_conditional.c
Created September 1, 2017 22:39
Fizzbuzz no conditionals
#include <stdio.h>
char *fizz[3] = {"Fizz", "", ""};
char *buzz[5] = {"Buzz", "", "", "", ""};
void main(void) {
for (int i = 1; i <= 100; i++)
printf("%d\r%s%s\n", i, fizz[i%3], buzz[i%5]);
}
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include "lcd.h"
// Shift register pin info
#define SRCLK_PIN 2
#define DATA_PIN 1
#define RCLK_PIN 0
!Current Configuration:
!
!System Description "EdgeSwitch 24-Port Lite, 1.3.0.4831995, Linux 3.6.5-f4a26ed5"
!System Software Version "1.3.0.4831995"
!System Up Time "0 days 9 hrs 54 mins 37 secs"
!Additional Packages QOS,IPv6 Management,Routing
!Current SNTP Synchronized Time: SNTP Last Attempt Status Is Not Successful
!
network protocol none
network parms 172.16.4.25 255.255.254.0 172.16.4.1
@MatthaeusHarris
MatthaeusHarris / gist:128e53aacd74d83c6d3a
Created February 9, 2016 09:54
Proxmox LXC hang on backup
root@tiamat:~# ps faxo f,uid,pid,ppid,pri,ni,vsz,rss,wchan:20,stat,tty,time,comm | tee ps.log
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND
1 0 2 0 19 0 0 0 kthreadd S ? 00:00:00 kthreadd
1 0 3 2 19 0 0 0 smpboot_thread_fn S ? 00:00:02 \_ ksoftirqd/0
1 0 5 2 39 -20 0 0 worker_thread S< ? 00:00:00 \_ kworker/0:0H
1 0 7 2 19 0 0 0 rcu_gp_kthread S ? 00:03:19 \_ rcu_sched
1 0 8 2 19 0 0 0 rcu_gp_kthread S ? 00:00:00 \_ rcu_bh
1 0 9 2 19 0 0 0 rcu_nocb_kthread S ? 00:02:00 \_ rcuos/0
1 0 10 2 19 0 0 0 rcu_nocb_kthread S ? 00:00:00 \_ rcuob/0
1 0 11 2 139 - 0 0 smpboot_thread_fn S ? 00:00:04 \_ migration/0
var feed_url = "http://dragonfinsoup.com/wp/wordpress/?json_route=/posts";
var data;
var masterTemplate;
var fetchPosts = function(num, offset) {
if (!masterTemplate) {
masterTemplate = $('.blogEntry').first().clone();
}
if (!data) {
@MatthaeusHarris
MatthaeusHarris / preload.js
Last active October 21, 2015 21:27
Javascript Preloader
function preload(urls, callback) {
console.log("Setting up preload");
// Container for the actual images
var images = [];
// List of images already loaded
var loaded = {};
// Initialize loaded array to all false
var makeLogger = function(level) {
return function(message) {
console.log(level + ": " + message);
}
}
var warn = makeLogger('warn');
var err = makeLogger('err');
var info = makeLogger('info');
var a = function(b) {
return function(c) {
return b*c;
}
}