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
| (defn ascii->hex-string | |
| "Perform Hex Encoding of a string: String(208A) -> String(32303841)" | |
| [s] | |
| (->> s | |
| (map #(Integer/toHexString (int %))) | |
| (apply str))) |
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
| class Meta(type): | |
| def __new__(cls, name, bases, attrs): | |
| for n, v in attrs.viewitems(): | |
| if isinstance(v, E): | |
| v.b = n | |
| return super(Meta, cls).__new__(cls, name, bases, attrs) | |
| class E(object): | |
| def __init__(self, a): | |
| self.a = 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
| from types import MethodType | |
| def fn_factory(i, obj): | |
| """Function factory - avoids a late binding in closures""" | |
| def fn(self): | |
| return i | |
| return MethodType(fn, obj) | |
| class Aaa(object): | |
| def __init__(self, n): |
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 java.util.Iterator; | |
| import java.util.function.BiFunction; | |
| import java.util.stream.Stream; | |
| import java.util.stream.StreamSupport; | |
| /** | |
| * Zipping streams into parallel or sequential stream using JDK8 with lambda | |
| * | |
| * @author Karol Krol | |
| */ |
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
| from binascii import unhexlify | |
| from functools import partial | |
| from Crypto.Protocol import KDF | |
| from Crypto.Hash import SHA512, HMAC | |
| _SALT = unhexlify('48B755AB80CD1C3DA61182D3DCD2E3A2CA869B783618FF6551FB4B0CDC3B8066') # some salt | |
| _KEY_LENGTH = 32 | |
| key_derivation_fn = partial( | |
| KDF.PBKDF2, |
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
| (ns clipboard.core | |
| (:import (java.awt.datatransfer DataFlavor Transferable StringSelection) | |
| (java.awt Toolkit))) | |
| (defn get-clipboard | |
| [] | |
| (-> (Toolkit/getDefaultToolkit) | |
| (.getSystemClipboard))) | |
| (defn slurp-clipboard |
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
| (ns alert.core | |
| (:import (javax.swing JOptionPane))) | |
| (defn alert | |
| [^String msg] | |
| (JOptionPane/showMessageDialog nil msg)) |
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
| (defmacro forever [& body] | |
| `(while true ~@body)) |
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
| def coroutine(gen_fn): | |
| """Python decorator turning generator into coroutine""" | |
| def inner(*args, **kwargs): | |
| gen = gen_fn(*args, **kwargs) | |
| gen.next() | |
| return gen | |
| return inner | |
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
| @echo off | |
| set proceed=true | |
| if "%1"=="" set proceed=false | |
| if "%2"=="" set proceed=false | |
| if %proceed%==false ( | |
| echo. | |
| echo Create directory and move desired files to it. | |
| echo. |