scrounger.utils.android module
Module with android utility functions.
""" Module with android utility functions. """ from scrounger.utils.general import requires_binary from scrounger.utils.general import execute as _execute @requires_binary("adb") def _adb_command(command): """ Runs an adb command on the host :param str command: the adb command to run :return: stdout and stderr from the executed command """ return _execute("adb {}".format(command)).replace("\r\n", "\n") def devices(): """ Returns a list of devices connected to the host :return: a list of devices """ device_lines = _adb_command("devices").split("\n")[1:-2] devices = {} for device in device_lines: if device and "\t" in device: device_id, device_status = device.strip().split("\t", 1) devices[device_id] = device_status return devices def avds(): """ Returns a list of the installed AVDs :return: a list of installed avds """ @requires_binary("avdmanager") @requires_binary("grep") def _avds(): avds_raw = _execute("avdmanager list avd | grep Name:") return [avd.strip.split(": ", 1)[-1] for avd in avds_raw.split("\n")] return _avds() def decompile(apk_path, destination_path): """ Decompiles an apk file using apktool :param str apk_path: the path to the apk file :param str destination_path: the destination directory where to decompile the application to :return: stdout and stderr for debugging """ @requires_binary("apktool") def _decompile(apk_path, destination_path): return _execute("apktool -q d -f {} -o {}".format(apk_path, destination_path)) return _decompile(apk_path, destination_path) def recompile(decompiled_app_path, apk_file_path): """ Recompiles a decompiled app using apktool to a new apk file :param str decompiled_app_path: the path to the decompiled app :param str apk_file_path: the resulting apk file path and filename :return: stdout and stderr for debugging """ @requires_binary("apktool") def _recompile(decompiled_app_path, apk_file_path): return _execute("apktool b -o {} {}".format(apk_file_path, decompiled_app_path)) return _recompile(decompiled_app_path, apk_file_path) def sign(apk_file_path, signed_apk_file_path, signjar, certificate, pk8): """ Signs an apk file given a certificate, a pk8 file the signapk jar :param str apk_file_path: the apk file to be signed :param str signed_apk_file_path: the apk file result :param str signjar: the signapk.jar file to use for the signing :param str certificate: the certificate used to sign the apk file :param str pk8: the pk8 key file to use to sign the apk file :return: nothing """ @requires_binary("java") def _sign(apk_file_path, signjar, certificate, pk8): return _execute("java -jar {} {} {} {} {}".format(signjar, certificate, pk8, apk_file_path, signed_apk_file_path)) return _sign(apk_file_path, signjar, certificate, pk8) def jar(apk_path, jar_file_path): """ Extracts a jar file from an apk file :param str apk_path: the path to the apk file :param str jar_file_path: the path and name of the resulting jar file :return: nothing """ @requires_binary("d2j-dex2jar") def _jar(apk_path, jar_file_path): _execute("d2j-dex2jar --force -o {} {}".format(jar_file_path, apk_path)) _jar(apk_path, jar_file_path) def source(jar_file_path, destination_path): """ Decompiles a jar file into java classes using jd-cli - make sure it is in your path :param str jar_file_path: the path to the jar to be decompiled :param str destination_path: the directory to decompile the jar to :return: nothing """ @requires_binary("jd-cli") def _source(jar_file_path, destination_path): _execute("jd-cli {} -od {}".format(jar_file_path, destination_path)) return _source(jar_file_path, destination_path) def extract_providers(decompiled_app_path): """ Extracts provider paths from a decompiled app directory using grep :param str decompiled_app_path: the directory where to look for the providers :return: a sorted list of proviers """ from scrounger.utils.general import pretty_grep import re providers_regex = r"content://[a-zA-Z0-1.-@/]+" providers = [] grep_result = pretty_grep(providers_regex, decompiled_app_path) for filename in grep_result: for finding in grep_result[filename]: # needs regex search since grep returns the whole line provider_path = re.search(providers_regex, finding["details"]).group().split("://", 1)[-1].strip() # make sure that every provider follows a standard and has no / # in the end if provider_path.endswith("/"): provider_path = provider_path[:-1] # TODO: translate @string to value providers.append(provider_path) # creates a set to make sure there are no duplicates and returns a sorted # list return sorted(set(providers)) def smali_dirs(decompiled_apk_path): """ Returns a list of directories contianing smali code :param str decompiled_apk_path: the path to the decompiled apk directory :return: a list with smali directories or an empty list if no smali dir """ dirs = _execute("ls -d {}/smali*".format(decompiled_apk_path)) if "No such file or directory" in dirs: return [] return [directory.replace(decompiled_apk_path, "")[1:] for directory in dirs.split("\n") if directory] def extract_smali_method(method_name, smali_file): """ Extracts a smali method from a smali file :param str method_name: the method to be extracted :param str smali_file: the file to extract the method from :return: the extracted method or empty string if not found """ with open(smali_file, "r") as fd: smali_code = fd.read() smali_method = "" for line in smali_code.split("\n"): # if method has been found and end is in line if smali_method and ".end method" in line: return smali_method # if method has been found then start saving elif ".method" in line and method_name in line and not smali_method: smali_method = line elif smali_method: smali_method += "{}\n".format(line) return smali_method def method_name(main_line, smali_file): """ Returns the first line of the method - method definition - of a method that executes the given line :param int main_line: the executed line to get the method definition from :param str smali_file: the file to extract the method definition from :return: a pretty_grep list with the line with the method definition or an empty list if not found """ # prepare vraiables and read content main_line = int(main_line) with open(smali_file, "r") as fp: smali = fp.read() for i, line in enumerate(reversed(smali.split("\n")[:main_line])): if ".method " in line: return [{ "line": main_line - i, "details": line.strip() }] return [] def track_variable(name, line_used, smali_file): """ Tries to identify the last instance a variable was set on the file before the line where it was used :param str name: the name of the variable (e.g. p1, v2, etc.) :param int line_used: the line where the variable is being used :param str smali_file: path to the file to look for the variable :return: a list with lines where the variable has been set or empty list """ # prepare vraiables and read content older_lines =[] track_invoke = False name = name.lower() line_used = int(line_used) with open(smali_file, "r") as fp: smali = fp.read() # go through the lines in reverse looking for initialization for i, line in enumerate(reversed(smali.split("\n")[:line_used])): if name in line and ("new-" in line or "const" in line): return older_lines + [{ "line": line_used - i, "details": line.strip() }] elif "move-object" in line and name in line: older_lines += [{ "line": line_used - i, "details": line.strip() }] name = line.rsplit(",", 1)[-1].strip() elif track_invoke and "invoke" in line: return older_lines + [{ "line": line_used - i, "details": line.strip() }] # if "move-result" then need to check last invoke elif "move-result" in line and name in line: older_lines += [{ "line": line_used - i, "details": line.strip() }] track_invoke = True # reached method header elif ".method " in line: # if variable is pX and no other evidence was found then it has # been passed over on method call so just return method header if name.startswith("p"): return older_lines + [{ "line": line_used - i, "details": line.strip() }] # if not variable pX then nothing was found else: return [] return [] def string(string_variable, resources_strings_xml_file): """ Looks for a string variable in the resources files :param str string_variable: the string variable to look for :param str resources_strings_xml_file: the strings.xml file to look for the string variable :return: the string value of the variable or `string_variable` if not found """ from scrounger.utils.general import pretty_grep #replace @string if in variable name string_variable = string_variable.replace("@string/", "") grep_result = pretty_grep(string_variable, resources_strings_xml_file) # if variable was not found if len(grep_result) == 0: return string_variable # get the string from grep result string = grep_result.popitem()[1][0]["details"] # get the string between tags return string.split(">", 1)[-1].split("<", 1)[0] def parsed_providers(decompiled_app_path): """ Looks for providers and translates any variables returning a uniform list of providers :param str decompiled_app_path: the directory with the decompiled app :return: list with unique provider paths """ # strings xml file strings_xml = "{}/res/values/strings.xml".format(decompiled_app_path) # extract providers from decompiled app path all_providers = extract_providers(decompiled_app_path) # get providers from manifest manifest = Manifest("{}/AndroidManifest.xml".format(decompiled_app_path)) # get and parse manifest_providers manifest_providers = manifest.providers() for provider in manifest_providers: provider_string = string(provider["authority"], strings_xml) if string(provider["name"]).startswith("."): provider_string = "{}{}".format(provider_string, string(provider['name'], strings_xml)) # remove the last forward slash - it will be added in the end if provider_string.endswith("/"): provider_string = provider_string[:-1] all_providers += [provider_string] # add providers with a slash in the end slash_providers = [] for provider in all_providers: slash_providers += ["{}/".format(provider)] return sorted(set(all_providers + slash_providers)) class Manifest(object): """ This class represents an Android manifest file """ BROWSABLE_CATEGORY = "android.intent.category.BROWSABLE" def __init__(self, manifest_file_path): """ Create a representation of the Android Manifest object :param str manigest_file_path: the path to the manifest file to parse """ import xml.etree.ElementTree as ET # get manifest content with open(manifest_file_path, "r") as fd: manifest_content = fd.read() # adjust some content for xml parser to avoid having {android} manifest_content = manifest_content.replace( "xmlns:android=\"http://schemas.android.com/apk/res/android\" ", "").replace("android:", "") self._root = ET.fromstring(manifest_content) def __str__(self): """Returns a string representation of the manifest""" return "Android Manifest ({})".format(self.package()) def version(self): """ Returns the build version name for the app :return: the build version number of the app or an empty string if not found """ return self._root.get("platformBuildVersionName", "") def package(self): """ Returns the package name for the app :return: the package name or an empty string if not found """ return self._root.get("package", "") def permissions(self): """ Returns a list of permissions being used by the application :return: a list of the permissions used """ return [permission.get("name", "") for permission in self._root.findall("uses-permission")] def providers(self): """ Returns a list of providers specified in the manifest :return: a list of dicts of providers containing the name, authorities and if they are exported or not """ return [ { "name": provider.get("name", ""), "authorities": provider.get("authorities", ""), "exported": provider.get("exported", "false") == "true", } for provider in self._root.find("application").findall("provider")] def secret_codes(self): """ Returns any secret codes in the manifest :return: a list of secret codes """ secret_codes = [] for receiver in self._root.find("application").findall("receiver"): for intent_filter in receiver.findall("intent-filter"): for data in intent_filter.findall("data"): code, scheme = data.get("host", ""), data.get("scheme", "") if scheme and code and "android_secret_code" in scheme: secret_codes.append(code) return secret_codes def _intent_filters(self, activity): """ Returns a list of intenet filters for a given activity :param ET.Element activity: the activity to parse :return: returns a list of dict of intent-filters with their actions, data and categories """ filters = [] for intent_filter in activity.findall("intent-filter"): parsed_filter = {"actions": [], "categories": [], "data": []} # get actions for action in intent_filter.findall("action"): parsed_filter["actions"].append(action.get("name", "")) # get categories for category in intent_filter.findall("category"): parsed_filter["categories"].append(category.get("name", "")) # get data for data in intent_filter.findall("data"): # get key, value attributes parsed_filter["data"].append(data.attrib) filters.append(parsed_filter) return filters def activities(self): """ Returns a list of activities and their associated filters, actions, data and categories :return: a list of dict containing the activities name, their intent filters, actions, data and categories """ activities = [] for activity in self._root.find("application").findall("activity"): # add key, value attributes parsed_activity = activity.attrib # add intents filters parsed_activity["intent_filters"] = self._intent_filters(activity) activities.append(parsed_activity) return activities def browsable_activities(self): """ Returns all browsable activities names :return: a list of browsable activities names """ activities = [] for activity in self.activities(): for intent_filter in activity["intent_filters"]: if self.BROWSABLE_CATEGORY in intent_filter["categories"]: activities.append(activity["name"]) return activities def browsable_uris(self): """ Returns a list of browsable uris :return: a list of schema://host/path/prefic/pattern """ uris = [] for activity in self.activities(): for intent_filter in activity["intent_filters"]: if self.BROWSABLE_CATEGORY in intent_filter["categories"]: for data in intent_filter["data"]: # adjust port variable if "port" in data: data["port"] = ":{}".format(data["port"]) uris.append("{}://{}{}{}{}{}".format( data.get("scheme", ""), data.get("host", ""), data.get("port", ""), data.get("path", ""), data.get("pathPrefix", ""), data.get("pathPattern", ""))) return uris def main_activity(self): """ Returns the name of the main activity of the application :return: package.MainActivityName or None if not found """ MAIN_ACTIVITY_ACTION = "android.intent.action.MAIN" package = self.package() for activity in self.activities(): for intent_filter in activity["intent_filters"]: if MAIN_ACTIVITY_ACTION in intent_filter["actions"]: return "{}{}".format(package, activity["name"].replace( package, "")) return None def allow_backup(self): """ Checks if backups are allowed by the application :return: True if bakcups are allowed or False otherwise """ return self._root.find("application").get( "allowBackup", "false") == "true" def debuggable(self): """ Checks if the application is debuggable :return: True if the app is debuggable or False otherwise """ return self._root.find("application").get( "debuggable", "false") == "true" def _get_sdk(self, sdk_type): """ Returns an sdk attribute if defined :param str sdk_type: the type of sdk to get: min, max, target :return: the sdk attribute or empty string if not defined """ for sdk in self._root.find("application").findall("uses-sdk"): if "{}SDKVersion".format(sdk_type.lower()) in sdk.attrib: return sdk.get("{}SDKVersion".format(sdk_type.lower())) return "" def min_sdk(self): """ Returns the minimum SDK supported by the app :return: the minimum SDK supported or empty string if not defined """ return self._get_sdk("min") def max_sdk(self): """ Returns the maximum SDK supported by the app :return: the maximum SDK supported or empty string if not defined """ return self._get_sdk("max") def target_sdk(self): """ Returns the target SDK supported by the app :return: the target SDK supported or empty string if not defined """ return self._get_sdk("target") class ApktoolYaml(object): """ This object represents an apktool.yml file """ def __init__(self, yml_file_path): """ Create an object the will represent the Apktool Yaml file :param str yml_file_path: the path to the Yaml file """ with open(yml_file_path, 'r') as f: self._raw = f.read() def __str__(self): """Returns a string representation of the apktool yaml""" return "Apktool Yaml ({})".format(self.apk_filename()) def version(self): """ Returns the applications version :return: the application version or empty string if not defined """ for line in self._raw.split("\n"): if "versionName" in line: return line.split(":", 1)[-1].split("'")[1].strip() return "" def apk_filename(self): """ Returns the applications apk file name :return: the application apk file name or empty string if not defined """ for line in self._raw.split("\n"): if "apkFileName" in line: return line.split(":", 1)[-1].split("'", 1)[-1].replace( "'", "").strip() return "" def _get_sdk(self, sdk_type): """ Returns an sdk attribute if defined :param str sdk_type: the type of sdk to get: min, max, target :return: the sdk attribute or empty string if not defined """ for line in self._raw.split("\n"): if "{}SdkVersion".format(sdk_type.lower()) in line: return line.split(":", 1)[-1].split("'")[1].strip() return "" def min_sdk(self): """ Returns the minimum SDK supported by the app :return: the minimum SDK supported or empty string if not defined """ return self._get_sdk("min") def max_sdk(self): """ Returns the maximum SDK supported by the app :return: the maximum SDK supported or empty string if not defined """ return self._get_sdk("max") def target_sdk(self): """ Returns the target SDK supported by the app :return: the target SDK supported or empty string if not defined """ return self._get_sdk("target")
Functions
def avds(
)
Returns a list of the installed AVDs
:return: a list of installed avds
def avds(): """ Returns a list of the installed AVDs :return: a list of installed avds """ @requires_binary("avdmanager") @requires_binary("grep") def _avds(): avds_raw = _execute("avdmanager list avd | grep Name:") return [avd.strip.split(": ", 1)[-1] for avd in avds_raw.split("\n")] return _avds()
def decompile(
apk_path, destination_path)
Decompiles an apk file using apktool
:param str apk_path: the path to the apk file :param str destination_path: the destination directory where to decompile the application to :return: stdout and stderr for debugging
def decompile(apk_path, destination_path): """ Decompiles an apk file using apktool :param str apk_path: the path to the apk file :param str destination_path: the destination directory where to decompile the application to :return: stdout and stderr for debugging """ @requires_binary("apktool") def _decompile(apk_path, destination_path): return _execute("apktool -q d -f {} -o {}".format(apk_path, destination_path)) return _decompile(apk_path, destination_path)
def devices(
)
Returns a list of devices connected to the host
:return: a list of devices
def devices(): """ Returns a list of devices connected to the host :return: a list of devices """ device_lines = _adb_command("devices").split("\n")[1:-2] devices = {} for device in device_lines: if device and "\t" in device: device_id, device_status = device.strip().split("\t", 1) devices[device_id] = device_status return devices
def extract_providers(
decompiled_app_path)
Extracts provider paths from a decompiled app directory using grep
:param str decompiled_app_path: the directory where to look for the providers :return: a sorted list of proviers
def extract_providers(decompiled_app_path): """ Extracts provider paths from a decompiled app directory using grep :param str decompiled_app_path: the directory where to look for the providers :return: a sorted list of proviers """ from scrounger.utils.general import pretty_grep import re providers_regex = r"content://[a-zA-Z0-1.-@/]+" providers = [] grep_result = pretty_grep(providers_regex, decompiled_app_path) for filename in grep_result: for finding in grep_result[filename]: # needs regex search since grep returns the whole line provider_path = re.search(providers_regex, finding["details"]).group().split("://", 1)[-1].strip() # make sure that every provider follows a standard and has no / # in the end if provider_path.endswith("/"): provider_path = provider_path[:-1] # TODO: translate @string to value providers.append(provider_path) # creates a set to make sure there are no duplicates and returns a sorted # list return sorted(set(providers))
def extract_smali_method(
method_name, smali_file)
Extracts a smali method from a smali file
:param str method_name: the method to be extracted :param str smali_file: the file to extract the method from :return: the extracted method or empty string if not found
def extract_smali_method(method_name, smali_file): """ Extracts a smali method from a smali file :param str method_name: the method to be extracted :param str smali_file: the file to extract the method from :return: the extracted method or empty string if not found """ with open(smali_file, "r") as fd: smali_code = fd.read() smali_method = "" for line in smali_code.split("\n"): # if method has been found and end is in line if smali_method and ".end method" in line: return smali_method # if method has been found then start saving elif ".method" in line and method_name in line and not smali_method: smali_method = line elif smali_method: smali_method += "{}\n".format(line) return smali_method
def jar(
apk_path, jar_file_path)
Extracts a jar file from an apk file
:param str apk_path: the path to the apk file :param str jar_file_path: the path and name of the resulting jar file :return: nothing
def jar(apk_path, jar_file_path): """ Extracts a jar file from an apk file :param str apk_path: the path to the apk file :param str jar_file_path: the path and name of the resulting jar file :return: nothing """ @requires_binary("d2j-dex2jar") def _jar(apk_path, jar_file_path): _execute("d2j-dex2jar --force -o {} {}".format(jar_file_path, apk_path)) _jar(apk_path, jar_file_path)
def method_name(
main_line, smali_file)
Returns the first line of the method - method definition - of a method that executes the given line
:param int main_line: the executed line to get the method definition from :param str smali_file: the file to extract the method definition from :return: a pretty_grep list with the line with the method definition or an empty list if not found
def method_name(main_line, smali_file): """ Returns the first line of the method - method definition - of a method that executes the given line :param int main_line: the executed line to get the method definition from :param str smali_file: the file to extract the method definition from :return: a pretty_grep list with the line with the method definition or an empty list if not found """ # prepare vraiables and read content main_line = int(main_line) with open(smali_file, "r") as fp: smali = fp.read() for i, line in enumerate(reversed(smali.split("\n")[:main_line])): if ".method " in line: return [{ "line": main_line - i, "details": line.strip() }] return []
def parsed_providers(
decompiled_app_path)
Looks for providers and translates any variables returning a uniform list of providers
:param str decompiled_app_path: the directory with the decompiled app :return: list with unique provider paths
def parsed_providers(decompiled_app_path): """ Looks for providers and translates any variables returning a uniform list of providers :param str decompiled_app_path: the directory with the decompiled app :return: list with unique provider paths """ # strings xml file strings_xml = "{}/res/values/strings.xml".format(decompiled_app_path) # extract providers from decompiled app path all_providers = extract_providers(decompiled_app_path) # get providers from manifest manifest = Manifest("{}/AndroidManifest.xml".format(decompiled_app_path)) # get and parse manifest_providers manifest_providers = manifest.providers() for provider in manifest_providers: provider_string = string(provider["authority"], strings_xml) if string(provider["name"]).startswith("."): provider_string = "{}{}".format(provider_string, string(provider['name'], strings_xml)) # remove the last forward slash - it will be added in the end if provider_string.endswith("/"): provider_string = provider_string[:-1] all_providers += [provider_string] # add providers with a slash in the end slash_providers = [] for provider in all_providers: slash_providers += ["{}/".format(provider)] return sorted(set(all_providers + slash_providers))
def recompile(
decompiled_app_path, apk_file_path)
Recompiles a decompiled app using apktool to a new apk file
:param str decompiled_app_path: the path to the decompiled app :param str apk_file_path: the resulting apk file path and filename :return: stdout and stderr for debugging
def recompile(decompiled_app_path, apk_file_path): """ Recompiles a decompiled app using apktool to a new apk file :param str decompiled_app_path: the path to the decompiled app :param str apk_file_path: the resulting apk file path and filename :return: stdout and stderr for debugging """ @requires_binary("apktool") def _recompile(decompiled_app_path, apk_file_path): return _execute("apktool b -o {} {}".format(apk_file_path, decompiled_app_path)) return _recompile(decompiled_app_path, apk_file_path)
def sign(
apk_file_path, signed_apk_file_path, signjar, certificate, pk8)
Signs an apk file given a certificate, a pk8 file the signapk jar
:param str apk_file_path: the apk file to be signed :param str signed_apk_file_path: the apk file result :param str signjar: the signapk.jar file to use for the signing :param str certificate: the certificate used to sign the apk file :param str pk8: the pk8 key file to use to sign the apk file :return: nothing
def sign(apk_file_path, signed_apk_file_path, signjar, certificate, pk8): """ Signs an apk file given a certificate, a pk8 file the signapk jar :param str apk_file_path: the apk file to be signed :param str signed_apk_file_path: the apk file result :param str signjar: the signapk.jar file to use for the signing :param str certificate: the certificate used to sign the apk file :param str pk8: the pk8 key file to use to sign the apk file :return: nothing """ @requires_binary("java") def _sign(apk_file_path, signjar, certificate, pk8): return _execute("java -jar {} {} {} {} {}".format(signjar, certificate, pk8, apk_file_path, signed_apk_file_path)) return _sign(apk_file_path, signjar, certificate, pk8)
def smali_dirs(
decompiled_apk_path)
Returns a list of directories contianing smali code
:param str decompiled_apk_path: the path to the decompiled apk directory :return: a list with smali directories or an empty list if no smali dir
def smali_dirs(decompiled_apk_path): """ Returns a list of directories contianing smali code :param str decompiled_apk_path: the path to the decompiled apk directory :return: a list with smali directories or an empty list if no smali dir """ dirs = _execute("ls -d {}/smali*".format(decompiled_apk_path)) if "No such file or directory" in dirs: return [] return [directory.replace(decompiled_apk_path, "")[1:] for directory in dirs.split("\n") if directory]
def source(
jar_file_path, destination_path)
Decompiles a jar file into java classes using jd-cli - make sure it is in your path
:param str jar_file_path: the path to the jar to be decompiled :param str destination_path: the directory to decompile the jar to :return: nothing
def source(jar_file_path, destination_path): """ Decompiles a jar file into java classes using jd-cli - make sure it is in your path :param str jar_file_path: the path to the jar to be decompiled :param str destination_path: the directory to decompile the jar to :return: nothing """ @requires_binary("jd-cli") def _source(jar_file_path, destination_path): _execute("jd-cli {} -od {}".format(jar_file_path, destination_path)) return _source(jar_file_path, destination_path)
def string(
string_variable, resources_strings_xml_file)
Looks for a string variable in the resources files
:param str string_variable: the string variable to look for
:param str resources_strings_xml_file: the strings.xml file to look for the
string variable
:return: the string value of the variable or string_variable
if not found
def string(string_variable, resources_strings_xml_file): """ Looks for a string variable in the resources files :param str string_variable: the string variable to look for :param str resources_strings_xml_file: the strings.xml file to look for the string variable :return: the string value of the variable or `string_variable` if not found """ from scrounger.utils.general import pretty_grep #replace @string if in variable name string_variable = string_variable.replace("@string/", "") grep_result = pretty_grep(string_variable, resources_strings_xml_file) # if variable was not found if len(grep_result) == 0: return string_variable # get the string from grep result string = grep_result.popitem()[1][0]["details"] # get the string between tags return string.split(">", 1)[-1].split("<", 1)[0]
def track_variable(
name, line_used, smali_file)
Tries to identify the last instance a variable was set on the file before the line where it was used
:param str name: the name of the variable (e.g. p1, v2, etc.) :param int line_used: the line where the variable is being used :param str smali_file: path to the file to look for the variable :return: a list with lines where the variable has been set or empty list
def track_variable(name, line_used, smali_file): """ Tries to identify the last instance a variable was set on the file before the line where it was used :param str name: the name of the variable (e.g. p1, v2, etc.) :param int line_used: the line where the variable is being used :param str smali_file: path to the file to look for the variable :return: a list with lines where the variable has been set or empty list """ # prepare vraiables and read content older_lines =[] track_invoke = False name = name.lower() line_used = int(line_used) with open(smali_file, "r") as fp: smali = fp.read() # go through the lines in reverse looking for initialization for i, line in enumerate(reversed(smali.split("\n")[:line_used])): if name in line and ("new-" in line or "const" in line): return older_lines + [{ "line": line_used - i, "details": line.strip() }] elif "move-object" in line and name in line: older_lines += [{ "line": line_used - i, "details": line.strip() }] name = line.rsplit(",", 1)[-1].strip() elif track_invoke and "invoke" in line: return older_lines + [{ "line": line_used - i, "details": line.strip() }] # if "move-result" then need to check last invoke elif "move-result" in line and name in line: older_lines += [{ "line": line_used - i, "details": line.strip() }] track_invoke = True # reached method header elif ".method " in line: # if variable is pX and no other evidence was found then it has # been passed over on method call so just return method header if name.startswith("p"): return older_lines + [{ "line": line_used - i, "details": line.strip() }] # if not variable pX then nothing was found else: return [] return []
Classes
class ApktoolYaml
This object represents an apktool.yml file
class ApktoolYaml(object): """ This object represents an apktool.yml file """ def __init__(self, yml_file_path): """ Create an object the will represent the Apktool Yaml file :param str yml_file_path: the path to the Yaml file """ with open(yml_file_path, 'r') as f: self._raw = f.read() def __str__(self): """Returns a string representation of the apktool yaml""" return "Apktool Yaml ({})".format(self.apk_filename()) def version(self): """ Returns the applications version :return: the application version or empty string if not defined """ for line in self._raw.split("\n"): if "versionName" in line: return line.split(":", 1)[-1].split("'")[1].strip() return "" def apk_filename(self): """ Returns the applications apk file name :return: the application apk file name or empty string if not defined """ for line in self._raw.split("\n"): if "apkFileName" in line: return line.split(":", 1)[-1].split("'", 1)[-1].replace( "'", "").strip() return "" def _get_sdk(self, sdk_type): """ Returns an sdk attribute if defined :param str sdk_type: the type of sdk to get: min, max, target :return: the sdk attribute or empty string if not defined """ for line in self._raw.split("\n"): if "{}SdkVersion".format(sdk_type.lower()) in line: return line.split(":", 1)[-1].split("'")[1].strip() return "" def min_sdk(self): """ Returns the minimum SDK supported by the app :return: the minimum SDK supported or empty string if not defined """ return self._get_sdk("min") def max_sdk(self): """ Returns the maximum SDK supported by the app :return: the maximum SDK supported or empty string if not defined """ return self._get_sdk("max") def target_sdk(self): """ Returns the target SDK supported by the app :return: the target SDK supported or empty string if not defined """ return self._get_sdk("target")
Ancestors (in MRO)
- ApktoolYaml
- __builtin__.object
Methods
def __init__(
self, yml_file_path)
Create an object the will represent the Apktool Yaml file
:param str yml_file_path: the path to the Yaml file
def __init__(self, yml_file_path): """ Create an object the will represent the Apktool Yaml file :param str yml_file_path: the path to the Yaml file """ with open(yml_file_path, 'r') as f: self._raw = f.read()
def apk_filename(
self)
Returns the applications apk file name
:return: the application apk file name or empty string if not defined
def apk_filename(self): """ Returns the applications apk file name :return: the application apk file name or empty string if not defined """ for line in self._raw.split("\n"): if "apkFileName" in line: return line.split(":", 1)[-1].split("'", 1)[-1].replace( "'", "").strip() return ""
def max_sdk(
self)
Returns the maximum SDK supported by the app
:return: the maximum SDK supported or empty string if not defined
def max_sdk(self): """ Returns the maximum SDK supported by the app :return: the maximum SDK supported or empty string if not defined """ return self._get_sdk("max")
def min_sdk(
self)
Returns the minimum SDK supported by the app
:return: the minimum SDK supported or empty string if not defined
def min_sdk(self): """ Returns the minimum SDK supported by the app :return: the minimum SDK supported or empty string if not defined """ return self._get_sdk("min")
def target_sdk(
self)
Returns the target SDK supported by the app
:return: the target SDK supported or empty string if not defined
def target_sdk(self): """ Returns the target SDK supported by the app :return: the target SDK supported or empty string if not defined """ return self._get_sdk("target")
def version(
self)
Returns the applications version
:return: the application version or empty string if not defined
def version(self): """ Returns the applications version :return: the application version or empty string if not defined """ for line in self._raw.split("\n"): if "versionName" in line: return line.split(":", 1)[-1].split("'")[1].strip() return ""
class Manifest
This class represents an Android manifest file
class Manifest(object): """ This class represents an Android manifest file """ BROWSABLE_CATEGORY = "android.intent.category.BROWSABLE" def __init__(self, manifest_file_path): """ Create a representation of the Android Manifest object :param str manigest_file_path: the path to the manifest file to parse """ import xml.etree.ElementTree as ET # get manifest content with open(manifest_file_path, "r") as fd: manifest_content = fd.read() # adjust some content for xml parser to avoid having {android} manifest_content = manifest_content.replace( "xmlns:android=\"http://schemas.android.com/apk/res/android\" ", "").replace("android:", "") self._root = ET.fromstring(manifest_content) def __str__(self): """Returns a string representation of the manifest""" return "Android Manifest ({})".format(self.package()) def version(self): """ Returns the build version name for the app :return: the build version number of the app or an empty string if not found """ return self._root.get("platformBuildVersionName", "") def package(self): """ Returns the package name for the app :return: the package name or an empty string if not found """ return self._root.get("package", "") def permissions(self): """ Returns a list of permissions being used by the application :return: a list of the permissions used """ return [permission.get("name", "") for permission in self._root.findall("uses-permission")] def providers(self): """ Returns a list of providers specified in the manifest :return: a list of dicts of providers containing the name, authorities and if they are exported or not """ return [ { "name": provider.get("name", ""), "authorities": provider.get("authorities", ""), "exported": provider.get("exported", "false") == "true", } for provider in self._root.find("application").findall("provider")] def secret_codes(self): """ Returns any secret codes in the manifest :return: a list of secret codes """ secret_codes = [] for receiver in self._root.find("application").findall("receiver"): for intent_filter in receiver.findall("intent-filter"): for data in intent_filter.findall("data"): code, scheme = data.get("host", ""), data.get("scheme", "") if scheme and code and "android_secret_code" in scheme: secret_codes.append(code) return secret_codes def _intent_filters(self, activity): """ Returns a list of intenet filters for a given activity :param ET.Element activity: the activity to parse :return: returns a list of dict of intent-filters with their actions, data and categories """ filters = [] for intent_filter in activity.findall("intent-filter"): parsed_filter = {"actions": [], "categories": [], "data": []} # get actions for action in intent_filter.findall("action"): parsed_filter["actions"].append(action.get("name", "")) # get categories for category in intent_filter.findall("category"): parsed_filter["categories"].append(category.get("name", "")) # get data for data in intent_filter.findall("data"): # get key, value attributes parsed_filter["data"].append(data.attrib) filters.append(parsed_filter) return filters def activities(self): """ Returns a list of activities and their associated filters, actions, data and categories :return: a list of dict containing the activities name, their intent filters, actions, data and categories """ activities = [] for activity in self._root.find("application").findall("activity"): # add key, value attributes parsed_activity = activity.attrib # add intents filters parsed_activity["intent_filters"] = self._intent_filters(activity) activities.append(parsed_activity) return activities def browsable_activities(self): """ Returns all browsable activities names :return: a list of browsable activities names """ activities = [] for activity in self.activities(): for intent_filter in activity["intent_filters"]: if self.BROWSABLE_CATEGORY in intent_filter["categories"]: activities.append(activity["name"]) return activities def browsable_uris(self): """ Returns a list of browsable uris :return: a list of schema://host/path/prefic/pattern """ uris = [] for activity in self.activities(): for intent_filter in activity["intent_filters"]: if self.BROWSABLE_CATEGORY in intent_filter["categories"]: for data in intent_filter["data"]: # adjust port variable if "port" in data: data["port"] = ":{}".format(data["port"]) uris.append("{}://{}{}{}{}{}".format( data.get("scheme", ""), data.get("host", ""), data.get("port", ""), data.get("path", ""), data.get("pathPrefix", ""), data.get("pathPattern", ""))) return uris def main_activity(self): """ Returns the name of the main activity of the application :return: package.MainActivityName or None if not found """ MAIN_ACTIVITY_ACTION = "android.intent.action.MAIN" package = self.package() for activity in self.activities(): for intent_filter in activity["intent_filters"]: if MAIN_ACTIVITY_ACTION in intent_filter["actions"]: return "{}{}".format(package, activity["name"].replace( package, "")) return None def allow_backup(self): """ Checks if backups are allowed by the application :return: True if bakcups are allowed or False otherwise """ return self._root.find("application").get( "allowBackup", "false") == "true" def debuggable(self): """ Checks if the application is debuggable :return: True if the app is debuggable or False otherwise """ return self._root.find("application").get( "debuggable", "false") == "true" def _get_sdk(self, sdk_type): """ Returns an sdk attribute if defined :param str sdk_type: the type of sdk to get: min, max, target :return: the sdk attribute or empty string if not defined """ for sdk in self._root.find("application").findall("uses-sdk"): if "{}SDKVersion".format(sdk_type.lower()) in sdk.attrib: return sdk.get("{}SDKVersion".format(sdk_type.lower())) return "" def min_sdk(self): """ Returns the minimum SDK supported by the app :return: the minimum SDK supported or empty string if not defined """ return self._get_sdk("min") def max_sdk(self): """ Returns the maximum SDK supported by the app :return: the maximum SDK supported or empty string if not defined """ return self._get_sdk("max") def target_sdk(self): """ Returns the target SDK supported by the app :return: the target SDK supported or empty string if not defined """ return self._get_sdk("target")
Ancestors (in MRO)
- Manifest
- __builtin__.object
Class variables
var BROWSABLE_CATEGORY
Methods
def __init__(
self, manifest_file_path)
Create a representation of the Android Manifest object
:param str manigest_file_path: the path to the manifest file to parse
def __init__(self, manifest_file_path): """ Create a representation of the Android Manifest object :param str manigest_file_path: the path to the manifest file to parse """ import xml.etree.ElementTree as ET # get manifest content with open(manifest_file_path, "r") as fd: manifest_content = fd.read() # adjust some content for xml parser to avoid having {android} manifest_content = manifest_content.replace( "xmlns:android=\"http://schemas.android.com/apk/res/android\" ", "").replace("android:", "") self._root = ET.fromstring(manifest_content)
def activities(
self)
Returns a list of activities and their associated filters, actions, data and categories
:return: a list of dict containing the activities name, their intent filters, actions, data and categories
def activities(self): """ Returns a list of activities and their associated filters, actions, data and categories :return: a list of dict containing the activities name, their intent filters, actions, data and categories """ activities = [] for activity in self._root.find("application").findall("activity"): # add key, value attributes parsed_activity = activity.attrib # add intents filters parsed_activity["intent_filters"] = self._intent_filters(activity) activities.append(parsed_activity) return activities
def allow_backup(
self)
Checks if backups are allowed by the application
:return: True if bakcups are allowed or False otherwise
def allow_backup(self): """ Checks if backups are allowed by the application :return: True if bakcups are allowed or False otherwise """ return self._root.find("application").get( "allowBackup", "false") == "true"
def browsable_activities(
self)
Returns all browsable activities names
:return: a list of browsable activities names
def browsable_activities(self): """ Returns all browsable activities names :return: a list of browsable activities names """ activities = [] for activity in self.activities(): for intent_filter in activity["intent_filters"]: if self.BROWSABLE_CATEGORY in intent_filter["categories"]: activities.append(activity["name"]) return activities
def browsable_uris(
self)
Returns a list of browsable uris
:return: a list of schema://host/path/prefic/pattern
def browsable_uris(self): """ Returns a list of browsable uris :return: a list of schema://host/path/prefic/pattern """ uris = [] for activity in self.activities(): for intent_filter in activity["intent_filters"]: if self.BROWSABLE_CATEGORY in intent_filter["categories"]: for data in intent_filter["data"]: # adjust port variable if "port" in data: data["port"] = ":{}".format(data["port"]) uris.append("{}://{}{}{}{}{}".format( data.get("scheme", ""), data.get("host", ""), data.get("port", ""), data.get("path", ""), data.get("pathPrefix", ""), data.get("pathPattern", ""))) return uris
def debuggable(
self)
Checks if the application is debuggable
:return: True if the app is debuggable or False otherwise
def debuggable(self): """ Checks if the application is debuggable :return: True if the app is debuggable or False otherwise """ return self._root.find("application").get( "debuggable", "false") == "true"
def main_activity(
self)
Returns the name of the main activity of the application
:return: package.MainActivityName or None if not found
def main_activity(self): """ Returns the name of the main activity of the application :return: package.MainActivityName or None if not found """ MAIN_ACTIVITY_ACTION = "android.intent.action.MAIN" package = self.package() for activity in self.activities(): for intent_filter in activity["intent_filters"]: if MAIN_ACTIVITY_ACTION in intent_filter["actions"]: return "{}{}".format(package, activity["name"].replace( package, "")) return None
def max_sdk(
self)
Returns the maximum SDK supported by the app
:return: the maximum SDK supported or empty string if not defined
def max_sdk(self): """ Returns the maximum SDK supported by the app :return: the maximum SDK supported or empty string if not defined """ return self._get_sdk("max")
def min_sdk(
self)
Returns the minimum SDK supported by the app
:return: the minimum SDK supported or empty string if not defined
def min_sdk(self): """ Returns the minimum SDK supported by the app :return: the minimum SDK supported or empty string if not defined """ return self._get_sdk("min")
def package(
self)
Returns the package name for the app
:return: the package name or an empty string if not found
def package(self): """ Returns the package name for the app :return: the package name or an empty string if not found """ return self._root.get("package", "")
def permissions(
self)
Returns a list of permissions being used by the application
:return: a list of the permissions used
def permissions(self): """ Returns a list of permissions being used by the application :return: a list of the permissions used """ return [permission.get("name", "") for permission in self._root.findall("uses-permission")]
def providers(
self)
Returns a list of providers specified in the manifest
:return: a list of dicts of providers containing the name, authorities and if they are exported or not
def providers(self): """ Returns a list of providers specified in the manifest :return: a list of dicts of providers containing the name, authorities and if they are exported or not """ return [ { "name": provider.get("name", ""), "authorities": provider.get("authorities", ""), "exported": provider.get("exported", "false") == "true", } for provider in self._root.find("application").findall("provider")]
def secret_codes(
self)
Returns any secret codes in the manifest
:return: a list of secret codes
def secret_codes(self): """ Returns any secret codes in the manifest :return: a list of secret codes """ secret_codes = [] for receiver in self._root.find("application").findall("receiver"): for intent_filter in receiver.findall("intent-filter"): for data in intent_filter.findall("data"): code, scheme = data.get("host", ""), data.get("scheme", "") if scheme and code and "android_secret_code" in scheme: secret_codes.append(code) return secret_codes
def target_sdk(
self)
Returns the target SDK supported by the app
:return: the target SDK supported or empty string if not defined
def target_sdk(self): """ Returns the target SDK supported by the app :return: the target SDK supported or empty string if not defined """ return self._get_sdk("target")
def version(
self)
Returns the build version name for the app
:return: the build version number of the app or an empty string if not found
def version(self): """ Returns the build version name for the app :return: the build version number of the app or an empty string if not found """ return self._root.get("platformBuildVersionName", "")


Manc Tech Events
Welcome to Manc Tech Events - listing the best tech events in and around Manchester.


|
generated with STAXDoc v1.0.4 |
| Function Summary | |
HelloMain | Test runs OSPL on two nodes. |
HelloManual | The manual entry point for this test. |
| STAX Function Details |
Test runs OSPL on two nodes. A publisher is then started on one node. A subscriber is started on the other. The publisher publishes a sample. The subscriber reads it. If the sample is successfully read the test succeeds. Fails otherwise.
| This function does not allow any arguments |
The manual entry point for this test. Allows you to run this test from the console by specifying init values.
| This function takes a list of arguments | |||||
|---|---|---|---|---|---|
| Name | Description | Required | Private | Default | Properties |
| host_name1 |
The host name of the first machine you wish test on | Yes | No | N/A | |
| test_root1 |
Location of test case / source / build checkout on machine 1 | Yes | No | N/A | |
| ospl_home1 |
Location of test case / source / build checkout on machine 1 | Yes | No | N/A | |
| host_name2 |
The host name of the second machine you wish to test on | Yes | No | N/A | |
| test_root2 |
Location of test case / source / build checkout on machine 1 | Yes | No | N/A | |
| ospl_home2 |
Location of test case / source / build checkout on machine 1 | Yes | No | N/A |


For best results, use EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, FORMAT JSON)
Psql users can export the plan to a file using psql -qAt -f explain.sql > analyze.json
DISCLAIMER: Pev stores your plans locally (localStorage) and will not send them anywhere.


Legendary jockey Nakatani announces retirement
by Edited News ReleaseCorey Nakatani, a 10-time Breeders’ Cup-winning jockey, has called it a career.
Nakatani’s son and agent, Matt Nakatani, posted a news release Saturday afternoon on Twitter announcing his 49-year-old father’s retirement.
Corey Nakatani hasn’t raced since August 2018, when he injured in his back in a spill at Del Mar.
“The time has come to officially announce my retirement from the sport of horse racing,” the Covina, Calif., native Nakatani said in the release. “Although I never imagined this was how my career would end, I am very proud of my accomplishments and know that I competed at the very highest of levels, which gives me a sense of satisfaction.
“This game gave a young kid from Covina purpose in life and I will forever be grateful for the opportunities it has given me. Without these amazing horses, I never would have considered my family and myself so blessed.”
Nakatani finished his career with 3,909 winners out of 23,740 starts, earning $234,554,534 aboard his mounts. He boasts 120 Grade 1 wins, 341 graded stakes victories and 10 Southern California Riding Titles.
Nakatani won his first two Breeders’ Cup races in 1996 with Jewel Princess (Distaff) and Lit de Justice (Sprint) and his last in 2012 aboard Tapizar (Dirt Mile). His best Triple Crown finish was a second-place run with Nehro in the 2011 Kentucky Derby.
Nakatani served as go-to rider for trainers Bobby Frankel, Steve Asmussen, D. Wayne Lukas, Bob Baffert, Richard Mandella, Jerry Hollendorfer and Nick Zito at various points of his career.
Some of Nakatani’s notable mounts included Tapizar, Lava Man, Sandpit, My Miss Aurelia, Sarafan, Thor’s Echo, Aragorn, Silic, Sweet Catomine, Lit de Justice, Serena’s Song, Lite Light, General Challenge, Sharp Cat, Reraise, Elmhurst, Jackson Bend, Regally Ready, Bolt d’Oro and Shared Belief.
A winner’s circle ceremony will take place Nov. 30 at Del Mar, followed by a reception. Nakatani and his family extended an invitation to any and all friends, colleagues, owners, and trainers who are welcome to attend.


You can use this form to register an account for the domain of your organization. You can also check whether the domain is available to register here.
Optionally you can choose to validate the domain, or can go ahead registering without validating the domain for the moment.
You need to provide the following information to register your organization.
| The Form Field | Description |
| Domain | Enter the domain name of your organization in here. |
| Admin Username | The username of the first admin account for your organization. You can use this account to login to all WSO2 Stratos services under your domain name. There is a user management UI that you can access after you login to the system where you can add new users (including users under admin role), new roles. |
| First Name | Your first name, which will be used to address you in the further communication and the notifications. |
| Last Name | Your last name. |
| Admin Password | The password of the startup admin account. You can change the password later from the user management UI. |
| Admin Password (Repeat) | Repeat the password you provided in the above field, so we can catch any typing mistake you made in there. |
| Your email address. This email will be used to complete the registration process and to contact you for any further requirement. | |
| Word Verification | Enter the letters shown in the above image in this text box. |
Once you completed the registration, you will be sent an email notification with the account verification information.
After verifying your registration, you can log in to the account using the log in page.


Crypto Pets
Crypto Pets is an ERC-721 token that enables anyone to tokenize their pets on the blockchain.
Create your very own Crypto Pet now!
Crypto Pets is an ERC-721 token that enables anyone to tokenize their pets on the blockchain.
Create your very own Crypto Pet now!


Survey
Name:
Question 1:
I want to see pets dressed up in costumes. (1-strongly disagree, 5-strongly agree)
1
2
3
4
5
Question 2:
I want to see non-traditional pets.
1
2
3
4
5
Question 3:
I like to see different species of pets everyday.
1
2
3
4
5
Question 4:
I want to see pets that are coiffed and primped.
1
2
3
4
5
Question 5:
I prefer furry pets.
1
2
3
4
5
Question 6:
I'd like to see pets that are happy.
1
2
3
4
5
Question 7:
I love differently-abled animals.
1
2
3
4
5
Question 8:
I think it's cute when my pet's tongue sticks out.
1
2
3
4
5
Question 9:
I want to see multiple pets at the same time.
1
2
3
4
5
Question 10:
I like athletic pets.
1
2
3
4
5
Submit


Math 3 : Precalculus OR Math 19A : Calculus for Sci, Eng, Math
AND
CMPS 10 : Intro to Computer Science OR CMPS 5J : Intro Programming in Java (no exp req) or CMPS 12A/L : Intro to Programming - Accelerated (programming exp. highly recommended)
Math 3 : Precalculus OR Math 19A : Calculus for Sci, Eng, Math
AND
CMPE 12/L : Computer Systems and Assembly Language/Lab (programming exp. requred) OR CMPE 8 : Robot Automation (no progarmming exp. required)


{{ partial "head.html" . }}
Sorry, there's nothing here. Head back home to try finding your way again.


|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IntSeqCounter
An IntSeqCounter
provides counts for sequences of
integers. This interface parallels CharSeqCounter
.
The method count(int[],int,int)
returns the basic count
for the specified integer sequence. The method extensionCount(int[],int,int)
is the sum of the counts for all
single integer extensions of the specified integer sequence. As
described in the class documentation for CharSeqCounter
,
these two methods are enough to compute a maximum likelihood
estimator of conditional integer likelihoods.
The method numExtensions(int[],int,int)
returns the
number of single integer extensions of the specified integer slice.
This is useful for computing interpolated estimates with
Witten-Bell smoothing.
| Method Summary | |
|---|---|
int |
count(int[] is,
int start,
int end)
Returns the count of the specified sequence of integers. |
long |
extensionCount(int[] is,
int start,
int end)
Returns the sum of the count of all sequences that extend the specified sequence by one integer. |
int[] |
integersFollowing(int[] is,
int start,
int end)
Returns an array of the integers that follow the specified integer array slice. |
int |
numExtensions(int[] is,
int start,
int end)
Returns the number of one integer extensions of the specified with non-zero counts. |
int[] |
observedIntegers()
Returns an array of all integers that have non-zero counts in the model. |
| Method Detail |
|---|
int count(int[] is, int start, int end)
is
- Underlying array of integers.start
- Index of first integer in the slice.end
- Index of one past the last integer in the slice.
IndexOutOfBoundsException
- If the start and end minus one
indices do not fall within the range of the integer array.long extensionCount(int[] is, int start, int end)
is
- Underlying array of integers.start
- Index of first integer in the slice.end
- Index of one past the last integer in the slice.
IndexOutOfBoundsException
- If the start and end minus one
indices do not fall within the range of the integer array.int numExtensions(int[] is, int start, int end)
is
- Underlying array of integers.start
- Index of first integer in the slice.end
- Index of one past the last integer in the slice.
IndexOutOfBoundsException
- If the start and end minus one
indices do not fall within the range of the integer array.int[] integersFollowing(int[] is, int start, int end)
is
- Underlying array of integers.start
- Index of first integer in the slice.end
- Index of one past the last integer in the slice.
IndexOutOfBoundsException
- If the start and end minus one
indices do not fall within the range of the integer array.int[] observedIntegers()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


Forrest Spencer Buster
Programming Enthusiast
"I want to be apart of advancing technology and at the forefront of the development of that technology. I have a strong enthusiasm and passion for Web Development, Business Economics, and Customer Service."
<EMAIL_ADDRESS>208-521-6978
941 W. Storey Ave.
Meridian, ID 83646
get in touch
-
Aug. 2015 - Nov. 2015
Boise Code Works
Boise, ID
Software/Web/App Development
Related course work: JavaScript, AngularJS, Node, Visual Studio C#, ASP.net, GIT - Source MongoDb - NoSQl, Security,
HTML5, CSSJ, Bootstrap
-
Jun. 2004 - Dec. 2005
Boise State University
Boise, ID
Business Management and Architecture
Related course work: Business Communications, marketing, economics, algebra, geometry, calculus, American Architecture,
Art History, and Microsoft Office.
-
Aug. 2003 - May 2004
Idaho State University
Idaho Falls, ID
Computer Sciences and Mathematics
Related course work: Calculus, HTML, CSS and C++ language programming.


You see a large globe shaped device, and hear quiet crunching sounds. It seems that some unknown power is leaking from it. Quest


title: Crate and Docker: Scale your database like your application description: Using Docker Machine you can provision a Crate cluster in the cloud or locally in minutes. heroImg: wrapper-hero-frontpage og_image: https://cdn.crate.io./media/1503/crate-logo-165.png {% extends "base.html" %} {% block header %}
Use Docker Machine to create a repeatable process for both local development and production deployment to the cloud
Try Docker MachineDocker Machine is a Docker project that moved into beta at the end of February 2015. It is a tool for easily provisioning a Docker host in numerous environments. The command will create new a host, install Docker and then enable you to use your local client to manage the instance.
Using Docker Machine will reduce the time is takes to provision new Docker hosts and make the process repeatable and easier to automate. Also it is commonly used with Docker Swarm and Docker Compose to simplify the entire process of provisioning an environment, creating a cluster and deploying complex multi-container applications.
Docker Machine makes it easier and faster to deploy a new Crate cluster, we no longer need to manually prepare each node or worry about each environment's different arguments and configurations. We were also able to combine the benefits of Machine with Swarm to create an easily repeatable Crate cluster.
To use Docker Machine with Amazon Web Services you will need four things, an Access Key ID, Secret Access Key, a VPC ID, and to have Docker Machine installed on your local machine.
Start the cluster
docker-machine create \
--driver amazon \
--amazonec2-access-key xxxx \
--amazonec2-secret-key xxxx \
--amazonec2-vpc-id xxxx \
machine_name
--amazonec2-access-key
: Your access key id for AWS--amazonec2-ami
: To use an AMI other than the default--amazonec2-instance-type
: Default is t2.micro--amazonec2-region
: Default is us-east-1--amazonec2-root-size
Default is 16 (in GB)--amazonec2-secret-key
: Your secret access key for the AWS.--amazonec2-security-group
: Default is docker-machine--amazonec2-session-token
: Your session token for AWS.--amazonec2-subnet-id
: AWS VPC subnet id--amazonec2-vpc-id
: Your VPC ID for launching the instance in.--amazonec2-zone
: Default is aTo use Docker Machine with Microsoft Azure you will need three things, a certificate, an Azure subscription ID and to have Docker Machine installed on your local machine.
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
openssl pkcs12 -export -out mycert.pfx -in mycert.pem -name "My Certificate"
Start the cluster
docker-machine create \
--driver azure \
--azure-subscription-id xxxx \
--azure-subscription-cert xxxx \
machine_name
--azure-image
: Default is Ubuntu 14.04 LTS x64--azure-location
: Default is West US--azure-size
: Default is small--azure-subscription-cert
: Your self generated cert for Azure--azure-subscription-id
: Your Azure subscription ID located in your profileTo use Docker Machine with Google Compute Engine you will need three things, a project name, the ability to oAuth, and to have Docker Machine installed on your local machine.
Start the cluster
docker-machine create \
--driver google \
--google-project xxxx \
machine_name
--google-zone
: Default is us-central1-a--google-machine-type
: Default is f1-micro--google-project
: This is found in the GCE dashboard--google-disk-size
: Default is 10 (in GB)Now that you've learned how easy it is to get started with Docker Machine, you have a few options for where to go next. You can:


by Franjo Žilić
Groovy vs. Java
Spring with Groovy
Testing with Groovy
More testing with Groovy
Groovy is a dynamic language of JVM which adds features to well known Java syntax and JDK libraries inspired by languages like Python, Ruby, Smalltalk.
Makes Java code simpler and easier to read.
Interoperable with Java libraries.
Compiles into Java bytecode.
Let's you get more done by doing less.
Types are optional or checked.
Thought before syntax.
Easy to learn *if we know Java
Less code - fewer errors.
Less code - more tests.
Rewriting takes time.
Taking small steps.
Whole new ecosystem?
Being forced?
Ant
Maven
Gradle
Native groovyc integration
Supports any Groovy version
Uses stubs for joint (Java+Groovy) projects
... uses ant
Supports any Groovy version
Not a native maven-compiler plugin
Poor IDE integration (Eclipse)
Uses stubs...
Native maven-compiler-plugin
Good IDE integration (Eclipse, IntelliJ)
Restricts Groovy version
No support for invoke-dynamic
Uses groovyc ant task, so applies as for ant
Decent IDE integration
Let's say we have a model
... we can't change it
... we get a list of UglyJavaModel objects
... anything can be null
someone said:
Let's just count those they want
final List<UglyJavaModel> list = thirdPartyService.onlyWayToGetData();
int countOfThoseWithBooleanTrue = 0;
for (final UglyJavaModel uglyJavaModel : list) {
if (uglyJavaModel.getNested() != null
&& uglyJavaModel.getNested().getNested() != null
&& uglyJavaModel.getNested().getNested().getNested() != null
&& uglyJavaModel.getNested().getNested().getNested()
.getTheAllImportantBoolean() == true) {
countOfThoseWithBooleanTrue++;
}
}
model.addAttribute("countWithBooleanTrue", countOfThoseWithBooleanTrue);
Java can do better, but...
And just top three
final List<UglyJavaModel> list = thirdPartyService.onlyWayToGetData();
list.sort(new Comparator<UglyJavaModel>() {
@Override
public int compare(final UglyJavaModel left, final UglyJavaModel right) {
return left.getNested().getSomeMonetaryValue()
.compareTo(right.getNested().getSomeMonetaryValue()) * -1;
}
});
final List<String> topThree = new ArrayList<String>(3);
for (final UglyJavaModel uglyJavaModel : list.subList(0, 3)) {
topThree.add(uglyJavaModel.getSomeName());
}
model.addAttribute("topThree", topThree);
I know, this is boring
def list = thirdPartyService.onlyWayToGetData()
model.addAttribute("countWithBooleanTrue", list.count {
it?.nested?.nested?.nested?.theAllImportantBoolean
})
model.addAttribute("topThree", list.sort {
a, b ->
b.nested.someMonetaryValue <=> a.nested.someMonetaryValue
}[0..2]*.someName)
JUnit is good enough
... but we still have to write a lot of code
... and we need a lot of libraries
simpler asserts
dynamic groovy
less code
@RunWith(MockitoJUnitRunner.class) //omitted imports - Mockito, Assertions
public class TipicalJunitTest {
@Test //ommited mocks and prepare data
public void testUglyJavaControllerReturingCorrectCount() {
final UglyJavaController controller = new UglyJavaController(service);
final ArrayList<UglyJavaModel> uglyJavaModels = prepareData();
when(service.onlyWayToGetData()).thenReturn(uglyJavaModels);
final String view = controller.showSomething(model);
assertThat(view).isEqualTo("ugly");
verify(model).addAttribute(eq("countWithBooleanTrue"), eq(1));
verify(model).addAttribute(eq("topThree"), captor.capture());
verify(service).onlyWayToGetData();
verifyNoMoreInteractions(service, model);
assertThat(captor.getValue()).containsExactly("first","third","second");
}
}
class GroovyJunitTest {
def data = [/* prepare data*/] // use mocks if you want
@Test
void testUglyJavaControllerReturingCorrectCount() {
def controller = new UglyJavaController([onlyWayToGetData: {
return data }] as ThirdPartyService)
assert controller.showSomething([addAttribute: { String attr, value ->
if (attr == 'countWithBooleanTrue') {
assert value == 1
} else if (attr == 'topThree') {
assert value == ['first', 'third', 'second']
} else {
assert false
}
}] as Model) == 'ugly'
}
}
... the dreaded Parameterized runner
What about data driven with Spring context?
No out of the box solution.
... an expressive testing and specification framework
brings new meaning to data driven
Written in Groovy, inspired by others*, compatible with JUnit
*JUnit, jMock, Mockito, RSpec...
@ContextConfiguration(['classpath:spring/test-config.xml'])
class SneakPeekSpockSpecification extends Specification {
@Autowired
SimpleSpringService service
@Unroll
void "just a simple sneak peak for spock"() {
given:
def testService = new SpockDemoService(service)
expect: "dependencies are met"
service
when: "calculate average for #booleanValue #givenValues.inspect()"
def average = testService.averageValueFor(booleanValue, givenValues.collect {
return new UglyJavaModel(nested:
new UglyJavaModelNested(someMonetaryValue: it.d, nested:
new UglyJavaModelNestedNested(nested:
new UglyJavaModelNestedNestedNested(theAllImportantBoolean: it.b))))
})
then: "average value should be #expected"
average == expected
where:
booleanValue|givenValues || expected
true |[[b:true,d:42.98],[b:false,d:4.3],[b:true,d:27.31]]||35.14
false |[[b:true,d:42.98],[b:false,d:4.3],[b:true,d:27.31]]||4.3
true |[[b:true,d:42.98],[b:true,d:4.3],[b:true,d:27.31]] ||24.86
}
}
https://github.com/fzilic/making-java-groovy


Created: 07/02/2013
By: LITTLE NEKO
<EMAIL_ADDRESS>Thank you for purchasing our theme. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here. Thanks so much!
You can view this template in any web browser from your desktop computer. Because the files are written in HTML, you do not need an internet connection in order to display or edit the template.
This theme has a responsive layout with a variation of column layouts depending on the page. This theme uses the TWIITER BOOTSTRAP (12 columns) which will help streamline any customization you wish to make. If you're unfamiliar with the Bootstrap system, be sure to read about it here.
The main structure of this site is wrapped in a '.container' div and a '.row' div. Inside of that div you will find each major section of the site given an appropriate column size all equalling 12 columns in length. For example, if you want a two columns layout width the same width you would create two div's 'span6' . The total columns equals 12.
You can also easily include columns layout within a Bootstrap column by using one of the following css class (all sizes of these classes are expressed in % to always fill up the right space of any container)
If you would like to edit the colors of any elements in one of these columns, you would do the following in color.css :
#mainLogo { color: #someColor; }
If you find that your new style is not overriding, it is most likely because of a specificity problem. Scroll down in your CSS file and make sure that there isn't a similar style that has more weight.
I.E.
header #mainLogo { color: #someColor; }
So, to ensure that your new styles are applied, make sure that they carry enough "weight" and that there isn't a style lower in the CSS file that is being applied after yours.
We are using a set of two main CSS files (layout.css and color.css) in this theme which you are free to modify depending on the customization you require. There are also one additional style sheet that we do not recommend changing. Those style sheets reside in the 'CSS' folder. The style sheets are:
The main CSS file contains all of the specific stylings for the page. The file is separated into sections using:
/* #NAME OF THE SECTION ================================================== */
/* Table of Content ================================================== */ #Custom Reset #Typography #Boostrap customization #Site Styles #HomePage Styles #Page Styles #Shortcodes classes #Forms #Sliders Styles #Media Queries
The color.css file contains all colors and styles for the color scheme you choosed. This file is also where you would make any changes to the main look of the theme since it overrides all css rules found in layout.css.
If you would like to edit a specific section of the site, simply find the appropriate label in the CSS file, and then scroll down until you find the appropriate style that needs to be edited.
This template uses several javascript files, all of them are placed a folder called "js-plugin" and on googleapis servers. All javascript files are called in the bottom of the page to speed up the loading time. The custom.js file, which is located in the js folder, is where we have placed all plugin calls and custom functions such as flexslider "captions" custom animations.

We have included all bootstrap shortcodes, classes and javascript plugins so that you can easly customize your theme. You can find a complete explanation of how it works here
We have included Icon fonts so that your icon will always look great no matter which screen they are displayed on. We have included a custom icon font pack. Here is a example on how to use these icons fonts

Just change the class name to switch the icon inside you html element. Here is a link showing the complete custom pack included with your theme.
You can extend the icons with the Fontello library. To add more icons to the set:
Twitter's decision to discontinue their unauthenticated v1.0 API means that old javascripts widgets stopped working. Twitter wants your only option for on-page widgets to be their own Embedded Timelines and follow their display requirements ( https://dev.twitter.com/terms/display-requirements ). That is why we decided to not include Twitter JS widget in our templates in order to follow the twitter guidelines. You may find alternatives (most using a php script) to display the tweets in a different way, breaking the Twitter rules, but we rather provide a safe solution for our buyers.
We included our own Twitter timeline in this template
To create a timeline you must be signed in to twitter.com and visit the widgets section of your settings page. From this page you can see a list of the timelines you've configured and create new timelines. Click the “Create new” button to build a new timeline for your website, choose the type, and complete the fields in the form; most fields are optional.  Here's an example embed code:
Tweets by @twitterapi

Twitter code

Demo images (NOT included in the package) http://www.shutterstock.com/
Once again, thank you so much for purchasing this theme. As We said at the beginning, we'd be glad to help you if you have any questions relating to this template. Please contact us via my author contact form. We'll do our best to assist you!
LITTLE NEKO


Query builder for pyelasticsearch
A set of utility methods to build the kinds of queries that are needed by elastic recheck to talk with elastic search.
Utility function for encoding logstash queries.
This is used when generating url’s for links in report pages.
Input is a string representing the logstash query and an optional timeframe argument.
A facetted query to ensure all the required files exist.
When changes are uploaded to elastic search there is a delay in getting all the required log fixes into the system. This query returns facets for the failure on the filename, which ensures that we’ve found all the files in the system.
Base query builder
Takes a raw_query string for elastic search. This is typically the same content that you’ve typed into logstash to get to a unique result.
Optionally supports a facet, which is required for certain operations, like ensuring that all the expected log files for a job have been uploaded.
A query to determine if we have a failure for a particular patch.
This is looking for a particular FAILURE line in the console log, which lets us know that we’ve got results waiting that we need to process.
A query for a single patch (review + revision).
This is used to narrow down a particular kind of failure found in a particular patch iteration.
A query for a single queue.


Created by Jane Dimeski / @janedimeski
© 2020/2021 Seavus Education & Development CenterThe best known form on the web is probably the search box that sits right in the middle of Google's homepage
There are several types of form controls that you can use to collect information from visitors to your site
More on forms here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form
<form action="login.cs" method="post">

</form>
Username:
<input type="text" name="username" id="user" />
Username:
<input type="text" name="username" id="user" />
Password:
<input type="password" name="password" id="pass" />
Tell us your story:
<textarea id="story" name="story" cols="33" rows="5">
It was a dark and stormy night...
</textarea>

Please select your favorite genre:

<input type="radio" name="genre" value="rock" id="rock" checked />
Rock
<input type="radio" name="genre" value="pop" id="pop" />
Pop
<input type="radio" name="genre" value="jazz" id="jazz" />
Jazz
*checked is a boolean attribute

Please select your favorite music streaming service(s):

<input type="checkbox" name="service"
value="AppleMusic" checked id="apple" />
AppleMusic
<input type="checkbox" name="service"
value="GoogleMusic" id="google" />
GoogleMusic
<input type="checkbox" name="service"
value="Spotify" id="spotify" />
Spotify
*checked is a boolean attribute
What device do you listen to music on?
<select name="devices" id="devices">
<option value="Phone" selected>Phone</option>
<option value="Desktop">Desktop</option>
<option value="CarRadio">Car Radio</option>
<option value="RecordPlayer">Record Player</option>
</select>
*selected is a boolean attribute
Do you play any of these instruments?
<select name="instruments" id="instruments" size="4" multiple>
<option value="guitar" selected>Guitar</option>
<option value="drums">Drums</option>
<option value="keyboard">Keyboard</option>
<option value="bass" selected>Bass</option>
</select>
*multiple is a boolean attribute
Upload your song in MP3 format:
<input type="file" name="user-song" id="song" />
<input type="submit" value="Send" />
<input type="reset" value="Reset Form" />
<button type="submit">

Add
</button>
<input type="hidden" name="product-code" value="P1234" />
*<input> elements of type hidden let web developers include data that cannot be seen or modified by users when a form is submitted.
*For example, the ID of the content that is currently being ordered or edited, or a unique security token. Hidden inputs are completely invisible in the rendered page, and there is no way to make it visible in the page's content.
<input type="email" />
<input type="tel" />
<input type="url" />
<input type="number" />
<input type="date" />
<input type="time" />
<input type="search" />
<input type="color" />
<input type="range" />
Check out the MDN page to read more about the <input> elements:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
*required is a boolean attribute
*Don't use placeholder as a raplacement for label
*visually
<fieldset>
<legend>Contact info</legend>
Your Name:
<input type="text" name="FullName" id="full-name" />
Email:
<input type="email" name="email" id="email" />
Phone:
<input type="tel" name="phone" id="phone" />
</fieldset>
Title: Working with forms
Description: Create a valid HTML5 document that contains a form that represents the choises available from the provided image
MDN recource: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form