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 runhaskell | |
| check :: Maybe Int -> Maybe Int | |
| check Nothing = Nothing | |
| check (Just x) | |
| | x `mod` 4 == 0 = Just (f x) | |
| | otherwise = Nothing | |
| where f x = 5 * (floor $ (fromIntegral x) / 4) + 1 | |
| solution :: Int -> [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
| import functools | |
| def chain(*fs, reverse=True): | |
| def dec(g): | |
| @functools.wraps(g) | |
| def wrapper(*args, **kwargs): | |
| functions = reversed(fs) if reverse else fs | |
| a = lambda m, f: f(m) | |
| return functools.reduce(a, functions, g(*args, **kwargs)) |
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
| (defun vray/render-vrscene () | |
| (interactive) | |
| (let* ((vray "/usr/autodesk/maya2016/vray/bin/vray") | |
| (scene (buffer-file-name)) | |
| (cmd (format "%s -sceneFile=%s -imgFile=/tmp/output.png &" vray scene))) | |
| (shell-command cmd))) |
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
| proc int widest(float $ary[]) { | |
| int $w = 0; | |
| for ($i = 0; $i < size($ary); $i++) { | |
| string $asString = $ary[$i]; | |
| $w = max($w, size($asString)); | |
| } | |
| return $w; | |
| } | |
| proc string padFloat(float $value, int $width) { |
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
| (defun omg () | |
| (let ((ch last-command-event) | |
| (tm (current-time))) | |
| (message "ch=%ch, tm=%s" ch tm))) | |
| (add-hook 'post-self-insert-hook #'omg) |
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 runhaskell | |
| import System.Environment | |
| epochYear = 1970 | |
| -- Should start with [epochYear jan 1], [1970 jan 1] is Thursday. | |
| weekDays = ["Thursday", "Friday" , "Saturday", "Sunday", | |
| "Monday", "Tuesday", "Wednesday"] | |
| isLeap x = x `rem` 400 == 0 || (x `rem` 100 /= 0 && x `rem` 4 == 0) |
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 <algorithm> | |
| // #include <ostream> | |
| #include <iostream> | |
| #include <string> | |
| namespace lazy | |
| { | |
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
| template<typename T> | |
| class A | |
| { | |
| public: | |
| virtual T fn() = 0; | |
| }; | |
| class B : public A<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
| #!/usr/bin/env python3 | |
| ''' | |
| What happens when one of the barycentric coordinates is constant? :) | |
| http://i.imgur.com/gsO6egy.png | |
| ''' | |
| import numpy as np | |
| from matplotlib import pyplot as plt |
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
| // Open communication ports | |
| // | |
| commandPort -eo -n ":2222"; // reload.py | |
| commandPort -eo -n ":2223"; // Emacs | |
| // Open the plugin manager window | |
| // | |
| // PluginManager; // Always open plugin manager on start-up | |
| // Show stack traces on errors |