Skip to content

Instantly share code, notes, and snippets.

View Rulexec's full-sized avatar
💭
It's complicated

Alexander Ruliov Rulexec

💭
It's complicated
View GitHub Profile
@Rulexec
Rulexec / example.js
Last active November 5, 2024 09:34
const wialon = require('./wialon.node.js').wialon;
// Print message to log
function msg(text) { console.log(text); }
function init() { // Execute after login succeed
var sess = wialon.core.Session.getInstance(); // get instance of current Session
// flags to specify what kind of data should be returned
var flags = wialon.item.Item.dataFlag.base | wialon.item.Unit.dataFlag.lastMessage;
export { getResult };
function getResult() {
return 42;
}
// If you uncomment this, HRM in `main.js` will stop work and `getResult()` will return 42 everytime
//if (module.hot) module.hot.accept();
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
long size = 36L * 1024 * 1024 * 1024 - 1;
void *x = malloc(size);
printf("Malloc: %lld\n", (long long) x);
@Rulexec
Rulexec / crypto.js
Created January 27, 2018 21:39
Telegram crypto AES 256 IGE node.js implementation
var crypto = require('crypto');
/*
msg_key_large = SHA256 (substr (auth_key, 88+x, 32) + plaintext + random_padding);
msg_key = substr (msg_key_large, 8, 16);
sha256_a = SHA256 (msg_key + substr (auth_key, x, 36));
sha256_b = SHA256 (substr (auth_key, 40+x, 36) + msg_key);
aes_key = substr (sha256_a, 0, 8) + substr (sha256_b, 8, 16) + substr (sha256_a, 24, 8);
aes_iv = substr (sha256_b, 0, 8) + substr (sha256_a, 8, 16) + substr (sha256_b, 24, 8);
*/
import java.util.concurrent.atomic.AtomicInteger
interface IController {
fun handle(request: AtomicInteger)
}
fun createController(handler: (request: AtomicInteger) -> Unit): IController {
return object : IController {
override fun handle(request: AtomicInteger) = handler(request)
}
(defn id (x) x)
(defn inRange (c start end) (and (>= (ord c) (ord start)) (<= (ord c) (ord end))))
(defn tryParse (pattern text)
(let (patternType (head pattern))
(switch patternType
'single' (let
(parser (get 1 pattern)
handler (getOrDef id 2 pattern)
import sys
numbers = [2, 0, 1, 5, 2, 0, 1, 5]
k = len(numbers) - 1
indexed_tail = list(zip(range(k), numbers[1:]))
to_bin = 2 ** k - 1
variants = []
function showLobby(session) {
var lobby = new LobbyClient({session: session});
var lobbyUi = new LobbyUi({element: rootElement});
var processLobbyEventsUntilNotJoinRoom = lobbyUi.poll().bind(function(event) {
if (event.type === LobbyUi.EVENTS.JOIN_ROOM) {
this.cont(null, event.id);
} else {
return processLobbyEventsUntilNotJoinRoom;
}
import System.IO
import Control.Monad
whileFM :: (Monad m) => m Bool -> (s -> m s) -> s -> m s
whileFM b f s = b >>= while' where
while' False = return s
while' True = (f s) >>= (\newS -> whileFM b f newS)
andM :: (Monad m) => m Bool -> m Bool -> m Bool
andM a b = a >>= (\x ->