Skip to content

Instantly share code, notes, and snippets.

View antekone's full-sized avatar
🪤
Focusing

Grzegorz Antoniak antekone

🪤
Focusing
View GitHub Profile
@antekone
antekone / test.cpp
Created March 28, 2014 09:27
C designated initializer in C++ test
#include <cstdio>
#include <cstdarg>
using namespace std;
typedef struct {
int a;
int b;
int c;
} themespec_t;
(2:658)$ gdb -q --args cargo build
Reading symbols from cargo...done.
(gdb) r
Starting program: /home/antek/bin/cargo/cargo-nightly-i686-unknown-linux-gnu/bin/cargo build
warning: Could not load shared library symbols for linux-gate.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0xb73ffb40 (LWP 23218)]
[New Thread 0xb71feb40 (LWP 23219)]
import java.util.*;
import java.lang.*;
class Log {
public static void put(String fmt, Object... args) {
String data = String.format(fmt, args);
System.out.println(data);
}
}
trait Action {
fn invoke(&self);
fn revoke(&self);
}
struct RemoveAction {
dummy: int
}
impl RemoveAction {
@antekone
antekone / gist:f80dd4583c6672439124
Created January 16, 2015 13:28
prime generation by trial division testing
checkd :: [Int] -> Int -> Int
checkd [] n = n
checkd (prime:primes) n =
if (elem n primes || n `mod` prime == 0) then
prime
else
checkd primes n
preplist :: [Int] -> Int -> [Int]
preplist curlist n = filter (\ x -> x < (n `div` 2 + 1)) curlist
(ns s512.core
(:require [clojure.java.io :as io])
(:gen-class))
(set! *warn-on-reflection* true)
(defn data-file []
(io/file "out.bin"))
(defn data-stream []
import qualified Data.ByteString.Lazy as BL
import Data.Binary.Get
import Data.Word
readArray :: Get [Word8]
readArray = do
empty <- isEmpty
if empty
then return []
else do
import qualified Data.ByteString.Lazy as BL
import Data.Binary.Get
import Data.Word
import Data.Bits
import Data.Char
readArray :: Get [Word8]
readArray = do
empty <- isEmpty
if empty
#pragma once
#define NAMESPACE_ENDIANCONVERSION_BEGIN namespace EndianConversion {
#define NAMESPACE_ENDIANCONVERSION_END }
#include <stdint.h>
// __BYTE_ORDER__ is a gcc macro
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define __LESWAP(n, x) x