Skip to content

Instantly share code, notes, and snippets.

View agrippa1994's full-sized avatar

Manuel Leitold agrippa1994

  • DCCS GmbH
  • Styria, Austria
View GitHub Profile
@agrippa1994
agrippa1994 / js_spirit2.cpp
Created January 28, 2016 12:22 — forked from jefftrull/js_spirit2.cpp
Attempted solution to "Boost Spirit vs. Flex/Bison" comparison
// Attempt at making a Boost grammar that successfully parses Jason Shankel's predicate logic language
// #define BOOST_SPIRIT_DEBUG
#include <boost/spirit/include/qi.hpp>
#include <boost/variant/recursive_variant.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/optional.hpp>
// start with the AST
@agrippa1994
agrippa1994 / playground.swift
Created January 4, 2016 22:05
Bonjour Discovery OS X iOS
import Foundation
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
extension NSData {
func castToCPointer<T>() -> T {
let mem = UnsafeMutablePointer<T>.alloc(sizeof(T.Type))
self.getBytes(mem, length: sizeof(T.Type))
return mem.move()
@agrippa1994
agrippa1994 / main.cpp
Created October 30, 2015 22:07
Byte Stuffing in C++11
#include <iostream>
#include <vector>
#include <string>
template<typename T>
T stuff(const T& input, typename T::value_type flag, typename T::value_type escape) {
if (flag == escape)
throw std::exception("Flag and escape are the same");
@agrippa1994
agrippa1994 / s1.xml
Created October 11, 2015 20:06 — forked from davybrion/s1.xml
code snippet for "Hosting a Node.js site through Apache" post
<VirtualHost 109.74.199.47:80>
ServerAdmin davy.brion@thatextramile.be
ServerName thatextramile.be
ServerAlias www.thatextramile.be
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
node-gyp rebuild --arch=ia32 --target=0.31.0 --dist-url=https://atom.io/download/atom-shell
#define GET_OFFSET_FROM_INITIALIZED_STRUCT(PTR, MEMBER) [&]() -> unsigned int { return (unsigned int)&PTR.MEMBER - (unsigned int)&PTR; }()
#define GET_OFFSET_FROM_NON_INITIALIZED_STRUCT(STRUCT, MEMBER) []() -> unsigned int { STRUCT s; return GET_OFFSET_FROM_INITIALIZED_STRUCT(s, MEMBER); }()
@agrippa1994
agrippa1994 / gist:24c1fd23ce7017f15934
Created October 6, 2014 16:13
JavaScript enumeration
var enumeration = function(initial) {
var _val = initial;
return {
get value() {
return (_val++);
}
};
};
@agrippa1994
agrippa1994 / test.swift
Created September 14, 2014 15:57
Costum Swift operators
prefix operator∫ { }
postfix operator∫ { }
class Pakets
{
enum PaketID: Int {
case Login
}
class ID
#include <iostream>
#include <string>
#include <type_traits>
#include <experimental/optional>
template<
typename pred, typename ...args,
typename ret = std::experimental::optional<typename std::result_of<pred(args...)>::type>
>
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);