This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: libacpp.dll app.exe | |
GHC := stack ghc -- | |
%.o: %.cpp | |
$(CXX) -c $< -o $@ | |
libacpp.dll: acpp.o acpp_capi.o | |
$(CXX) $^ -shared -o $@ # On Linux/Unix, -fPIC is needed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeOperators #-} | |
module T where | |
-- | Infix application. | |
-- | |
-- @ | |
-- f :: IO $ Maybe Int | |
-- = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file contains default non-project-specific settings for 'stack', used | |
# in all projects. For more information about stack's configuration, see | |
# http://docs.haskellstack.org/en/stable/yaml_configuration.html | |
# | |
# {} | |
package-indices: | |
- require-hashes: false | |
gpg-verify: false | |
name: TUNA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
def get_cpu_number(): | |
''' Return the processors' number, an integer value. | |
''' | |
import os | |
return int(os.environ['NUMBER_OF_PROCESSORS']) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## place object files (.o) in two different folders to vaoid overlapping. | |
mkdir libA | |
cd libA | |
ar -x ../libA.a | |
cd .. | |
mkdir libB | |
cd libB | |
ar -x ../libB.a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* set geography data server *) | |
server := "http://www.staremapy.cz/naturalearth/`1`/`2`/`3`.png" | |
(* plot *) | |
GeoGraphics[{GeoStyling[Opacity[0.5], GeoServer -> server], | |
NightHemisphere[]}, | |
GeoBackground -> GeoStyling["ReliefMap", GeoServer -> server]] | |
(* more simple graph *) | |
GeoGraphics[{NightHemisphere[Now], Red, Point[$GeoLocation]}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
template<typename T, typename S> | |
auto max(T a, S b) -> decltype(a+b) { // note that T and S may be different. | |
// for numeric type, automatic type convension will be performed when compare two values. | |
if (a > b) { | |
return a; | |
} | |
else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <iostream> | |
#include <string> | |
// valid in C++14, but not valid in C++11. | |
// for statement not allowed in constexpr function in C++11. | |
constexpr size_t addition(size_t n) { | |
size_t s = 0; | |
for (size_t i = 0; i <= n; ++i) { | |
s += i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Control.Monad.ST | |
import System.IO.Unsafe | |
import Unsafe.Coerce | |
unsafePerformST :: ST s a -> a | |
unsafePerformST m = unsafePerformIO $ | |
stToIO $ -- unsafely do it | |
unsafeCoerce m -- convert to ST Realworld a | |
{-# NOINLINE unsafePerformST #-} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from time import time | |
import math | |
def prime_sum_impl(n): | |
r = int(math.sqrt(n)) | |
v = [n//i for i in range(1, r+1)] | |
v += list(range(v[-1]-1, 0, -1)) |