Skip to content

Instantly share code, notes, and snippets.

View ioncodes's full-sized avatar
😴
Playing with memory regions...

Layle ioncodes

😴
Playing with memory regions...
View GitHub Profile
@ioncodes
ioncodes / Qt 5 Dark Fusion Palette
Last active October 16, 2017 19:17 — forked from QuantumCD/Qt 5 Dark Fusion Palette
Qt 5 Fusion Theme
qApp->setStyle(QStyleFactory::create("Fusion"));
QPalette darkPalette;
darkPalette.setColor(QPalette::Window, QColor(53,53,53));
darkPalette.setColor(QPalette::WindowText, Qt::white);
darkPalette.setColor(QPalette::Base, QColor(25,25,25));
darkPalette.setColor(QPalette::AlternateBase, QColor(53,53,53));
darkPalette.setColor(QPalette::ToolTipBase, Qt::white);
darkPalette.setColor(QPalette::ToolTipText, Qt::white);
darkPalette.setColor(QPalette::Text, Qt::white);
@ioncodes
ioncodes / xor.c
Last active September 2, 2018 20:01
xor two strings in c
#include <stdio.h>
#include <memory.h>
#include <stdlib.h>
#define LENGTH 5
void xor(char const value1[LENGTH], char const value2[LENGTH], char *xored[LENGTH]) {
for(int i=0; i<LENGTH; ++i) {
xored[i] = (char)(value1[i] ^ value2[i]);
}
@ioncodes
ioncodes / factorio_headless_guide.md
Created May 19, 2017 13:07 — forked from othyn/factorio_headless_guide.md
How to setup a Factorio Headless Server

[LINUX] Factorio Headless Server Guide

So, with credit to the Factorio wiki and cbednarski's helpful gist, I managed to eventually setup a Factorio headless server. Although, I thought the process could be nailed down/simplified to be a bit more 'tutorialised' and also to document how I got it all working for my future records.

The specific distro/version I'm using for this guide being Ubuntu Server 16.04.1 LTS. Although, that shouldn't matter, as long as your distro supports systemd (just for this guide, not a Factorio headless requirement, although most distros use it as standard now). The version of Factorio I shall be using is 0.14.20, although should work for any version of Factorio 0.14.12 and higher.

Alternate

If you prefer a simple, automated setup, [Bisa has a really handy init script that will do most of the work for

@ioncodes
ioncodes / u8tohex.rs
Created March 1, 2017 17:59
convert u8 to hex
use std::fmt;
struct ByteBuf<'a>(&'a [u8]);
impl<'a> fmt::LowerHex for ByteBuf<'a> {
fn fmt(&self, fmtr: &mut fmt::Formatter) -> Result<(), fmt::Error> {
for byte in self.0 {
try!(fmtr.write_fmt(format_args!("{:02x}", byte)));
}
Ok(())
}
}
var svgs = document.getElementsByClassName('icon');
var icons = [];
for(var i = 0; i < svgs.length; i++) {
var child = svgs[i].childNodes[0].getAttribute('xlink:href');
icons.push(child);
}
var ficons = document.getElementsByTagName('I');
var icons = [];
for(var i = 0; i < ficons.length; i++) {
if(ficons[i].className.indexOf(' ') === -1) {
icons.push(ficons[i].className);
}
}
var ionicons = document.getElementsByClassName('icon');
var icons = [];
for(var i = 0; i < ionicons.length; i++) {
if(i%10 === 0) {
icons.push(ionicons[i].className.split(' ').pop());
}
}
var devIcons = document.getElementsByClassName('devicons');
var icons = [];
for(var i = 0; i < devIcons.length; i++) {
if(i%5 === 0) {
icons.push(devIcons[i].className.split(' ').pop());
}
}
var svg = document.getElementsByTagName('LI');
var names = [];
for(var i = 0; i < svg.length; i++) {
names.push(svg[i].getAttribute('data-name'));
}
@ioncodes
ioncodes / glyphicon-scraper.js
Last active February 15, 2017 18:06
Scrapes all the glyphicons classnames from http://glyphicons.bootstrapcheatsheets.com/
var spans = document.getElementsByTagName('SPAN');
var names = [];
for(var i = 0; i < spans.length; i++) {
if(spans[i].className.indexOf('glyphicon') !== -1) {
names.push(spans[i].className.split(' ').pop());
}
}