Skip to content

Instantly share code, notes, and snippets.

View kimwalisch's full-sized avatar

Kim Walisch kimwalisch

  • Luxembourg
  • 06:03 (UTC +01:00)
View GitHub Profile
@kimwalisch
kimwalisch / l1d_cache_size.cpp
Last active November 2, 2022 00:27
Get L1 data cache size on most operating systems
///
/// @file l1d_cache_size.cpp
/// @brief Get the L1 cache size in kilobytes on Windows
/// and most Unix-like operating systems.
///
/// Copyright (C) 2015 Kim Walisch, <[email protected]>
///
/// This file is distributed under the BSD License.
///
@kimwalisch
kimwalisch / segmented_sieve.cpp
Last active July 31, 2020 08:33
Simple segmented sieve of Eratosthenes implementation
/// @file segmented_sieve.cpp
/// @author Kim Walisch, <[email protected]>
/// @brief This is a simple implementation of the segmented sieve of
/// Eratosthenes with a few optimizations. It generates the
/// primes below 10^9 in 0.8 seconds (single-threaded) on an
/// Intel Core i7-6700 3.4 GHz CPU.
/// @license Public domain.
#include <iostream>
#include <algorithm>
@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, <[email protected]>
/// @license Public Domain
#include <iostream>
#include <cassert>
#include <cmath>
// 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 / 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%';
@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 / wget_list_of_urls
Created January 10, 2014 18:59
Download list of files from terminal using wget
wget --content-disposition -i urls.txt