Skip to content

Instantly share code, notes, and snippets.

View nuald's full-sized avatar

Alexander Slesarev nuald

View GitHub Profile
@nuald
nuald / int2str.cpp
Created July 18, 2017 08:32
Sample code to generate binary string from the integer
// Sample code to generate binary string from the integer
// To compile, please use:
// $ clang++ int2str.cpp --std=c++11 -Weverything -Wno-c++98-compat
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
@nuald
nuald / build.gradle
Last active May 12, 2017 11:40
Waiting for the named USB device in macos.
def APPLICATION_GROUP = 'Application'
ext {
device = 'Cruzer'
program = 'wait'
}
task compile(type: Exec) {
group APPLICATION_GROUP
description 'Compiles the native program.'
@nuald
nuald / build.gradle
Created January 4, 2017 07:24
Gradle task for the verification that any Android device is connected and launching a simulator if not.
apply plugin: 'com.android.application'
task connect(type: ConnectDevicesTask) {
description 'Verifies that any Android device is connected and runs a simulator if not.'
}
import com.android.ddmlib.AndroidDebugBridge
import com.android.ddmlib.IDevice
import org.gradle.tooling.BuildException
@nuald
nuald / PersistentCookieStore.java
Last active July 27, 2022 03:07 — forked from franmontiel/PersistentCookieStore.java
A persistent CookieStore implementation for use in Android with HTTPUrlConnection or OkHttp 2. -- For a OkHttp 3 persistent CookieJar implementation you can use this library: https://github.com/franmontiel/PersistentCookieJar
/*
* Copyright (c) 2015 Fran Montiel
* Copyright (c) 2016 Alexander Slesarev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@nuald
nuald / buildCopy.js
Created September 28, 2016 01:21
Cordova gulp build hook
module.exports = (ctx) => {
var Q = ctx.requireCordovaModule('q'),
shell = ctx.requireCordovaModule('shelljs');
var gulpDeferral = new Q.defer(),
exitDeferral = new Q.defer();
console.log("Building Web Project.");
shell.cd('../web/');
@nuald
nuald / gen.R
Created August 2, 2016 06:35
Generate series for a breach detection sample
#!/usr/bin/env Rscript
suppressPackageStartupMessages(library("argparse"))
parser <- ArgumentParser(
description="Generate series for a breach detection sample"
)
parser$add_argument("-N", "--checks", type="integer", default=5,
help="Number of checks [default %(default)s]",
metavar="checks")
parser$add_argument("-M", "--attempts", type="integer", default=6,
@nuald
nuald / serve.scala
Last active July 19, 2019 06:44
Simple HTTP Server on Scala/Akka (directory listing)
#!/usr/bin/env scalas
/***
scalaVersion := "2.13.0"
scalacOptions ++= Seq("-deprecation", "-feature")
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.5.23"
libraryDependencies += "com.typesafe.akka" %% "akka-stream" % "2.5.23"
libraryDependencies += "com.typesafe.akka" %% "akka-http" % "10.1.9"
libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.1"
*/
@nuald
nuald / listmacaddrs.c
Last active November 9, 2017 19:19
Getting MAC addresses
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#ifdef AF_LINK
# include <net/if_dl.h>
unsigned char *get_ptr(struct ifaddrs *ifaptr) {
if (((ifaptr)->ifa_addr)->sa_family == AF_LINK) {
return (unsigned char *)LLADDR((struct sockaddr_dl *)(ifaptr)->ifa_addr);
@nuald
nuald / chat.py
Last active July 2, 2016 05:45
Multicasting chat sample
#!/usr/bin/env python3
""" Multicasting chat application """
import socket
import struct
import sys
from threading import Thread
MADDX = '225.100.100.100'
PORT = 6543
@nuald
nuald / pwd.py
Created July 2, 2016 02:56
Simple password generator
#!/usr/bin/env python3
""" Simple password generator """
import random
import argparse
def main():
""" Main entry """
parser = argparse.ArgumentParser()