Skip to content

Instantly share code, notes, and snippets.

View kimwalisch's full-sized avatar

Kim Walisch kimwalisch

  • Luxembourg
  • 05:45 (UTC +01:00)
View GitHub Profile
@kimwalisch
kimwalisch / find_files_by_keyword
Last active August 29, 2015 13:57
Find all files that contain a user specified keyword (UNix)
# Find all files KEYWORD
$ fgrep -R --files-with-matches KEYWORD .
# Find all files with FILENAME and KEYWORD
$ find . -name FILENAME -exec fgrep --files-with-matches KEYWORD {} \;
@kimwalisch
kimwalisch / oracle_sql_commands.sql
Last active August 29, 2015 14:00
oracle_sql_commands
-- Seach column name in database
select table_name from all_tab_columns where column_name like '%COLUMN_NAME%';
-- Seach table name in database
select table_name from all_tables where table_name like '%TABLE_NAME%';
// Author: Kim Walisch
// Released into public domain
#include <windows.h>
#include <cstdlib>
typedef BOOL (WINAPI *LPFN_GLPI)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
/// Get the CPU's cache size in bytes.
/// Works on Windows (MSVC, Intel C++ Compiler, Cygwin, ...).
@kimwalisch
kimwalisch / constexpr_sqrt.cpp
Last active August 29, 2015 14:12
Compile time square root using C++11 constexpr
///
/// @file constexpr_sqrt.cpp
/// @brief Calculate integer square roots at compile time using
/// C++11 constexpr.
/// @author Kim Walisch, <kim.walisch@gmail.com>
/// @license Public Domain
#include <iostream>
#include <cassert>
#include <cmath>
@kimwalisch
kimwalisch / sieving_loop.asm
Created November 9, 2015 21:01
primesieve inner sieving loop
; primesieve inner sieving loop
; Uses only 11 instructions (x86-64) to cross-off the next 8 multiples
.L99:
andb $-3, (%rax)
andb $-9, (%rax,%r14)
andb $127, (%rax,%r12)
andb $-33, (%rax,%rbp)
andb $-2, (%rax,%r10)
andb $-65, (%rax,%rbx)
andb $-5, (%rax,%r9)
@kimwalisch
kimwalisch / wget_list_of_urls
Created January 10, 2014 18:59
Download list of files from terminal using wget
wget --content-disposition -i urls.txt
struct libdivide_u64_t libdivide_u64_gen(uint64_t d) {
struct libdivide_u64_t result;
const uint32_t floor_log_2_d = 63 - libdivide__count_leading_zeros64(d);
uint64_t proposed_m, rem;
uint8_t more;
proposed_m = libdivide_128_div_64_to_64(1ULL << floor_log_2_d, 0, d, &rem); //== (1 << (64 + floor_log_2_d)) / d
LIBDIVIDE_ASSERT(rem > 0 && rem < d);
@kimwalisch
kimwalisch / primesieve_iterator.c
Last active August 16, 2016 20:17
primesieve_iterator C example
#include <primesieve.h>
#include <stdio.h>
int main()
{
primesieve_iterator it;
primesieve_init(&it);
uint64_t prime;
/* iterate over the primes below 10^6 */
# Compile using default C++ compiler
c++ -O2 segmented_sieve.cpp -o segmented_sieve
# Count the primes below 10^9
time ./segmented_sieve 1000000000
45a20e525e3c19fc98e583101af166fd5e6b2324 primesieve-5.7.2.tar.gz
064b79afeff39866b3c17d390c790778460e5a1c primesieve-5.7.2.zip
6fd3e6d98a6d4bf7a7234279deaa4eff193235b9 primesieve-5.7.0-win64.zip
c7f3e96c4e1a0e23131f6a39f4086d6d275b0b6c primesieve-5.7.0-win64-console.zip
8e3f62c850efe591286fcc2262a7f4af4cad285b primesieve-5.5.0-linux-x64.tar.gz
31215c1dcbc3899f4929b1291a0cb73522111b6d primesieve-5.7.0-linux-x64-console.tar.gz
4095d6d2f88a71f8bf86cea1332b539025320bec primesieve-5.5.0-macosx-x64.zip
7ea817d4555dc378e0abf9d14400af8de95dc9f7 primesieve-5.5.0-macosx-x64-console.zip
da7a99173692da005ace827b0df17cb3e7ab1356 primesieve-3.6-win32.zip
9d16566558aee0b71139f5f95dff23d808d2d886 primesieve-3.6-win32-console.zip