Skip to content

Instantly share code, notes, and snippets.

Alexander Slesarev nuald

Block or report user

Report or block nuald

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nuald
nuald / int2str.cpp
Created Jul 18, 2017
Sample code to generate binary string from the integer
View int2str.cpp
// 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
Waiting for the named USB device in macos.
View build.gradle
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 Jan 4, 2017
Gradle task for the verification that any Android device is connected and launching a simulator if not.
View build.gradle
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 Dec 8, 2016 — 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
View PersistentCookieStore.java
/*
* 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 Sep 28, 2016
Cordova gulp build hook
View buildCopy.js
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 Aug 2, 2016
Generate series for a breach detection sample
View gen.R
#!/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 Jan 26, 2018
Simple HTTP Server on Scala/Akka (directory listing)
View serve.scala
#!/usr/bin/env scalas
/***
scalaVersion := "2.12.4"
libraryDependencies += "com.typesafe.akka" %% "akka-http" % "10.0.11"
libraryDependencies += "com.github.scopt" %% "scopt" % "3.7.0"
*/
import akka.actor.ActorSystem
import akka.event.Logging
@nuald
nuald / listmacaddrs.c
Last active Nov 9, 2017
Getting MAC addresses
View listmacaddrs.c
#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 Jul 2, 2016
Multicasting chat sample
View chat.py
#!/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 Jul 2, 2016
Simple password generator
View pwd.py
#!/usr/bin/env python3
""" Simple password generator """
import random
import argparse
def main():
""" Main entry """
parser = argparse.ArgumentParser()
You can’t perform that action at this time.