Skip to content

Instantly share code, notes, and snippets.

View ocus's full-sized avatar
💩
No.

Matthieu Honel ocus

💩
No.
View GitHub Profile
import requests
import logging
from sys import version_info
if version_info[0] < 3:
import urllib
def encode_url_vars(vars):
return urllib.urlencode(vars)
else:
@ocus
ocus / build.gradle
Created January 19, 2017 15:38
Android Library Project - Copy AAR from build/outputs/aar/PROJECT-VARIANT.aar to build/PROJECT-VARIANT-VERSION_NAME.aar after each assembleVARIANT task
android.libraryVariants.all { variant ->
def variantName = variant.name.capitalize()
def copyTaskName = "copy${variantName}Artifacts"
def assembleTaskName = "assemble${variantName}"
task(copyTaskName, type: Copy, dependsOn: assembleTaskName, group: "build") {
variant.outputs.each { output ->
def newOutputName = output.outputFile.name.replace(".aar", "-" + android.defaultConfig.versionName + ".aar")
from(output.outputFile.parent) {
include output.outputFile.name
rename output.outputFile.name, newOutputName

The light show !

You are given the task to create the Java classes corresponding to light bulbs (of different characteristics) that can be individually plugged-in on one of the 4 sockets of a control panel allowing the light on or off at will.

The produced code must allow executing the "script" as follows:

static public void main(String[] args) {
    // Technicians are working hard to mount this...

LightBulb a1 = new LightBulb("yellow");

function rovarspraketEnc(s) {
return s.replace(/[b-df-hj-np-tv-xz]/ig, function (m) {
return m + "o" + m.toLowerCase();
});
}
function rovarspraketDec(s) {
return s.replace(/([b-df-hj-np-tv-xz])o\1/ig, function (m, n) {
return n;
});