Skip to content

Instantly share code, notes, and snippets.

View andr1972's full-sized avatar

Andrzej Borucki andr1972

View GitHub Profile
@andr1972
andr1972 / euler_phi.cpp
Created September 30, 2016 16:31 — forked from cslarsen/euler_phi.cpp
Euler's totient function phi --- a fast implementation in C++
/*
* Euler's totient function phi(n).
* http://en.wikipedia.org/wiki/Euler%27s_totient_function
*
* This is an *EXTREMELY* fast function and uses
* several tricks to recurse.
*
* It assumes you have a list of primes and a fast
* isprime() function. Typically, you use a bitset
* to implement the sieve of Eratosthenes and use
#include <string.h>
#include "RCarry2.h"
static const unsigned long int mask_lo = 0x00ffffffUL; /* 2^24 - 1 */
static const unsigned long int mask_hi = ~0x00ffffffUL;
static const unsigned long int two24 = 16777216; /* 2^24 */
RCarry2::RCarry2(int32_t seed)
{
/* This is the initialization algorithm of F. James, widely in use
Pol
En-us-plum.ogg - plum,plumb
En-us-sulfur.ogg - sulfur,sulphur
En-us-number.ogg - number,number
En-us-stand.ogg - stand,anthem
En-uk-a minute.ogg - minute,minute
En-us-arm.ogg - arm,Arm
En-us-kit.ogg - kit,Kit
En-us-March.ogg - march,March
En-us-nix.ogg - nix,Nix
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <exception>
#include <assert.h>
#include "yAllocator.h"
#define min(a,b) a<b?a:b
#define BITSIZE(a) (sizeof(a)*8)
#define ISBITSET(x,k) (x & (1<<k))
@andr1972
andr1972 / setup.h
Last active December 2, 2015 23:16
Setup information from X11 protocol
#pragma once
typedef uint64_t CARD64;
typedef uint32_t CARD32;
typedef uint16_t CARD16;
typedef unsigned char CARD8;
typedef CARD8 BYTE;
typedef CARD8 BOOL;
@andr1972
andr1972 / xcb-no-decoration.cpp
Last active March 17, 2019 10:44
XCB library - show window without decoration
//http://stackoverflow.com/questions/5134297/xlib-how-does-this-removing-window-decoration-work
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <inttypes.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
//xcb_event.h
@andr1972
andr1972 / XCB timer
Last active March 20, 2021 09:01
XCB loop and timer event
CodeBlocks config:
Build options->Linker settings: rt xcb
Properties->Build targets: GUI application
#include "StdAfx.h"
#include "Common/MyInitGuid.h"
#include "SevenZipJBinding.h"
#include "JNITools.h"
#include "net_sf_sevenzipjbinding_SevenZip.h"
#include "CPPToJava/CPPToJavaInStream.h"
@andr1972
andr1972 / gist:6473786
Created September 7, 2013 08:06
Process.cpp
#include <jni.h>
#include "demopkg_Process.h"
JNIEXPORT void JNICALL Java_demopkg_Process_nativeLongOperation
(JNIEnv *env, jobject owner, jobject param1)
{
jclass clsICallback = env->GetObjectClass(param1);
jmethodID method1 = env->GetMethodID(clsICallback, "onPercent", "(I)V");
jmethodID method2 = env->GetMethodID(clsICallback, "onPercentEx", "(Ldemopkg/ComplexStruct;)V");
jclass clsComplexStruct = env->FindClass("demopkg/ComplexStruct");
@andr1972
andr1972 / gist:6473763
Last active December 22, 2015 12:39
demopkg.JNIdemo#main
public static void main(String[] args) {
Process process = new Process();
process.nativeLongOperation(new CallbackImpl());
}