Skip to content

Instantly share code, notes, and snippets.

View dmikurube's full-sized avatar

Dai MIKURUBE dmikurube

View GitHub Profile
@dmikurube
dmikurube / JaxbInheritance.java
Last active August 29, 2015 14:17
JAXB annotations in inheritance
import javax.xml.bind.JAXB;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@XmlRootElement(name = "base")
interface BaseClass {
public class XorByte {
public static void main(String[] args) {
byte r;
byte x = 0x13;
byte y = (byte)0x9f;
r = x ^ y;
System.out.println(r);
}
}
#include <iostream>
class Base {
public:
virtual void common_func(int arg) {
std::cout << "Bas" << arg << std::endl;
}
};
template <class A>
#include <iostream>
class Base {
public:
virtual int func() {
return 0;
}
};
class Derived1 : public Base {
#include <iostream>
enum EntryIds {
Entry1,
NumberOfEntries
};
class EntryBase {
public:
EntryBase() : entry_id_(NumberOfEntries) {}
#include <cstdio>
#ifdef DECLARE_PRINTER_
#error "The macro DECLARE_PRINTER_ is duplicated."
#else
#define DECLARE_PRINTER_(SECTION, VALUE_NAME) \
void print_##SECTION##_##VALUE_NAME() { \
printf("%s - %s\n", #SECTION, #VALUE_NAME); \
}
#endif // DECLARE_PRINTER_
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
typedef unsigned long long uint64_t;
int presence(int pagemap_fd, uint64_t address) {
uint64_t index = (address / getpagesize()) * 8;
@dmikurube
dmikurube / importee1.py
Created January 24, 2014 07:46
Importing a file into a class dynamically
text = 'Test 1'
def print_text():
print text
class Shape(object):
def __new__(cls, desc, color='black'):
if cls is Shape:
if desc == 'sankaku':
return super(Shape, cls).__new__(Triangle, color)
elif desc == 'shikaku':
return super(Shape, cls).__new__(Rectangle, color)
else:
return super(Shape, cls).__new__(Shape, color)
else:
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#define A1 (1024 * 1024 * 200)
#define A2_PARENT (1024 * 1024 * 300)
#define A2_CHILD (1024 * 1024 * 500)
int main() {