Site: https://boxcar.io/
    API: http://help.boxcar.io/knowledgebase/topics/48115-boxcar-api
    Desc: Best app for system administrators
492814
def send(token, title, **kwargs):
    
    headers = {
        "Content-type": "application/x-www-form-urlencoded",
        "User-Agent": "DBMail/%s" % get_version(),
    }

    data = {
        "user_credentials": token,
        "notification[title]": from_unicode(title),
        "notification[sound]": "notifier-2"
    }

    for k, v in kwargs.items():
        data['notification[%s]' % k] = from_unicode(v)

    http = HTTPSConnection(kwargs.pop("api_url", "new.boxcar.io"))
    http.request(
        "POST", "/api/notifications",
        headers=headers,
        body=urlencode(data))
    response = http.getresponse()

    if response.status != 201:
        raise BoxcarError(response.reason)
    return True
106296
def get_driver_config(driver):  # noqa: E501
    

    response = errorIfUnauthorized(role='admin')
    if response:
        return response
    else:
        response = ApitaxResponse()

    # TODO: This needs an implementation, but likely requires a change to configs in apitaxcore

    return Response(status=200, body=response.getResponseBody())
795728
function parseChassisData(statusData) {
        // sample data : 20 00 60 71 or 20 00 60
        var numStr = statusData.replace(/\s/g, '');
        assert.ok(numStr.match(/^[0-9A-Fa-f]{8}$|^[0-9A-Fa-f]{6}$/),
                  "Invalid chassis status output : " + statusData);
        var uidCode = parseInt(numStr[4], 16);
        var powerCode = parseInt(numStr[1], 16);

        // UID status need last 2 bit , so use mask 0x3(0011)
        // Power status need last bit , so use mask 0x1(0001)
        return {
            uid: uidStatus[uidCode & 0x3],
            power: (powerCode & 0x1) === 1
        };
    }
793528
def as_dash_app(self):
        '''
        
        '''
        dateless_dash_app = getattr(self, '_stateless_dash_app_instance', None)
        if not dateless_dash_app:
            dateless_dash_app = get_stateless_by_name(self.app_name)
            setattr(self, '_stateless_dash_app_instance', dateless_dash_app)
        return dateless_dash_app
371814
def database_admin_api(self):
        """"""
        if self._database_admin_api is None:
            self._database_admin_api = DatabaseAdminClient(
                credentials=self.credentials, client_info=_CLIENT_INFO
            )
        return self._database_admin_api
621437
public function index()
    {
        //  Command line only
        $oInput = Factory::service('Input');
        if (Environment::is(Environment::ENV_PROD) && !$oInput::isCli()) {
            header($oInput->server('SERVER_PROTOCOL') . ' 401 Unauthorized');
            echo '<h1>' . lang('unauthorised') . '</h1>';
            exit(401);
        }

        // --------------------------------------------------------------------------

        /**
         * Look for a controller, app version first then the module's cron controllers directory
         */
        $aControllerPaths = [
            NAILS_APP_PATH . 'application/modules/cron/controllers/',
        ];

        $nailsModules = Components::modules();

        foreach ($nailsModules as $oModule) {

            if ($oModule->moduleName === $this->sModuleName) {
                $aControllerPaths[] = $oModule->path . 'cron/controllers/';
                break;
            }
        }

        //  Look for a valid controller
        $sControllerName    = ucfirst($this->sClassName) . '.php';
        $bDidfindController = false;

        foreach ($aControllerPaths as $sPath) {

            $sControllerPath = $sPath . $sControllerName;

            if (is_file($sControllerPath)) {
                $bDidfindController = true;
                break;
            }
        }

        if (!empty($bDidfindController)) {

            //  Load the file and try and execute the method
            require_once $sControllerPath;

            $this->sModuleName = 'Nails\\Cron\\' . ucfirst($this->sModuleName) . '\\' . ucfirst($this->sClassName);

            if (class_exists($this->sModuleName)) {

                //  New instance of the controller
                $oInstance = new $this->sModuleName($this);

                if (is_callable([$oInstance, $this->sMethod])) {

                    //  Begin timing
                    $this->writeLog('Starting job');

                    if (!empty($this->aParams)) {

                        $this->writeLog('Passed parameters');
                        $this->writeLog(print_r($this->aParams, true));
                    }

                    $iStart = microtime(true) * 10000;

                    call_user_func_array([$oInstance, $this->sMethod], $this->aParams);

                    $iEnd      = microtime(true) * 10000;
                    $iDuration = ($iEnd - $iStart) / 10000;
                    $this->writeLog('Finished job');
                    $this->writeLog('Job took ' . number_format($iDuration, 5) . ' seconds');

                } else {

                    $this->writeLog('Cannot call method "' . $this->sMethod . '"');
                }

            } else {

                $this->writeLog(
                    '"' . $this->sModuleName . '" is incorrectly configured; could not find class ' . $this->sModuleName . '  at path ' . $sControllerPath
                );
            }

        } else {

            $this->writeLog(
                '"' . $this->sModuleName . '/' . $this->sClassName . '/' . $this->sMethod . '" is not a valid route.'
            );
        }
    }
969087
def connect():
    """"""

    # Exchange authorization code for acceess token and create session
    session = auth_flow.get_session(request.url)
    client = UberRidesClient(session)

    # Fetch profile for driver
    profile = client.get_driver_profile().json

    # Fetch last 50 trips and payments for driver
    trips = client.get_driver_trips(0, 50).json
    payments = client.get_driver_payments(0, 50).json

    return render_template('driver_dashboard.html',
                           profile=profile,
                           trips=trips['trips'],
                           payments=payments['payments']
                           )
338492
protected function mapApiRoutes()
    {
        Route::group([
            'middleware' => 'api',
            'namespace'  => $this->namespace.'\Api',
            'domain'     => config('hstcms.apiDomain') ? config('hstcms.apiDomain') : env('APP_URL'),
            'prefix'     => config('hstcms.apiDomain') ? '' : config('hstcms.apiPrefix') ? config('hstcms.apiPrefix') : 'api',
        ], function ($router) {
             require __DIR__.'/../Routes/api.php';
        });
    }
226382
public function applicationConsole()
    {
        $this->setIsCli(true);
        $config = $this->getConfigArray();
        $config['defaultRoute'] = 'help';
        if (isset($config['components'])) {
            if (isset($config['components']['composition'])) {
                unset($config['components']['composition']);
            }
        }
        
        $this->includeYii();

        $baseUrl = null;
        if (isset($config['consoleBaseUrl'])) {
            $baseUrl = $config['consoleBaseUrl'];
        } elseif (isset($config['consoleHostInfo'])) {
            $baseUrl = '/';
        }
        
        $mergedConfig = ArrayHelper::merge($config, [
            'bootstrap' => ['luya\console\Bootstrap'],
            'components' => [
                'urlManager' => [
                    'class' => 'yii\web\UrlManager',
                    'enablePrettyUrl' => true,
                    'showScriptName' => false,
                    'baseUrl' => $baseUrl,
                    'hostInfo' => isset($config['consoleHostInfo']) ? $config['consoleHostInfo'] : null,
                ],
            ],
        ]);
        $this->app = new ConsoleApplication($mergedConfig);
        if (!$this->mockOnly) {
            exit($this->app->run());
        }
    }
776445
def _api_help(self):
        
        response.content_type = 'application/json; charset=utf-8'

        # Update the stat
        view_data = self.stats.get_plugin("help").get_view_data()
        try:
            plist = json.dumps(view_data, sort_keys=True)
        except Exception as e:
            abort(404, "Cannot get help view data (%s)" % str(e))
        return plist
1352708
public function dashboard()
    {
        //if the dev has chosen to use a dashboard
        if (config('administrator.use_dashboard')) {
            //set the layout dashboard
            $this->layout->dashboard = true;

            //set the layout content
            $this->layout->content = view(config('administrator.dashboard_view'));

            return $this->layout;
        }
        //else we should redirect to the menu item
        else {
            $configFactory = app('admin_config_factory');
            $home          = config('administrator.home_page');

            //first try to find it if it's a model config item
            $config = $configFactory->make($home);

            if (!$config) {
                throw new \InvalidArgumentException('Administrator: '.trans('administrator::administrator.valid_home_page'));
            } elseif ($config->getType() === 'model') {
                return redirect()->route('admin_index', array($config->getOption('name')));
            } elseif ($config->getType() === 'settings') {
                return redirect()->route('admin_settings', array($config->getOption('name')));
            }
        }
    }
170457
def help_me(parser, opt):
    """"""
    print("aomi v%s" % version)
    print('Get started with aomi'
          ' https://autodesk.github.io/aomi/quickstart')
    if opt.verbose == 2:
        tf_str = 'Token File,' if token_file() else ''
        app_str = 'AppID File,' if appid_file() else ''
        approle_str = 'Approle File,' if approle_file() else ''
        tfe_str = 'Token Env,' if 'VAULT_TOKEN' in os.environ else ''
        appre_str = 'App Role Env,' if 'VAULT_ROLE_ID' in os.environ and \
                    'VAULT_SECRET_ID' in os.environ else ''
        appe_str = 'AppID Env,' if 'VAULT_USER_ID' in os.environ and \
                   'VAULT_APP_ID' in os.environ else ''

        LOG.info(("Auth Hints Present : %s%s%s%s%s%s" %
                  (tf_str, app_str, approle_str, tfe_str,
                   appre_str, appe_str))[:-1])
        LOG.info("Vault Server %s" %
                 os.environ['VAULT_ADDR']
                 if 'VAULT_ADDR' in os.environ else '??')

    parser.print_help()
    sys.exit(0)
840774
public function askAuthorization(){
        $rest = $this->getService( self::API_LOGIN_AUTHORIZE);
        $rest->POST([
            'app_id'        => $this->application->getId(),
            'app_name'      => $this->application->getName(),
            'app_version'   => $this->application->getVersion(),
            'device_name'   => gethostname(),
        ]);

        $this->app_token = $rest->getResult()['app_token'];
        $this->track_id  = $rest->getResult()['track_id'];

        $this->application->getLogger()->addInfo( 'Authorization send to Freebox. Waiting for response...');

        return $rest->getResult();
    }
687065
public function main()
    {
        $options = (array)$this->params;
        $options['bundle'] = empty($options['bundle']) ? null : $options['bundle'];

        if (empty($options['use'])) {
            $this->err(__d('eav', 'You must indicate a table alias name using the "--use" option. Example: "Articles.Users"'));

            return false;
        }

        try {
            $table = TableRegistry::get($options['use']);
        } catch (\Exception $ex) {
            $table = false;
        }

        if (!$table) {
            $this->err(__d('eav', 'The specified table does not exists.'));

            return false;
        } elseif (!$table->behaviors()->has('Eav')) {
            $this->err(__d('eav', 'The specified table is not using EAV behavior.'));

            return false;
        }

        $columns = $table->listColumns($options['bundle']);
        ksort($columns, SORT_LOCALE_STRING);
        $rows = [
            [
                __d('eav', 'Column Name'),
                __d('eav', 'Data Type'),
                __d('eav', 'Bundle'),
                __d('eav', 'Searchable'),
            ]
        ];

        foreach ($columns as $name => $info) {
            $rows[] = [
                $name,
                $info['type'],
                (!empty($info['bundle']) ? $info['bundle'] : '---'),
                (!empty($info['searchable']) ? 'no' : 'yes'),
            ];
        }

        $this->out();
        $this->out(__d('eav', 'EAV information for table "{0}":', $options['use']));
        $this->out();
        $this->helper('table')->output($rows);

        return true;
    }
816864
def request_system_arm(blink, network):
    
    url = "{}/network/{}/arm".format(blink.urls.base_url, network)
    return http_post(blink, url)
1294419
def get_box_reminders(self, box_key):
		'''
		'''
		#required sanity check
		if box_key:
			return requests.codes.bad_request, None

		uri = '/'.join([self.api_uri,
						self.boxes_suffix, 
						box_key,
						self.reminders_suffix
						])

		return self._req('get', uri)
1039499
def headers
      {
        'X-EBAY-API-COMPATIBILITY-LEVEL' => @compatability_level.to_s,
        'X-EBAY-API-DEV-NAME' => dev_id.to_s,
        'X-EBAY-API-APP-NAME' => app_id.to_s,
        'X-EBAY-API-CERT-NAME' => cert_id.to_s,
        'X-EBAY-API-CALL-NAME' => @command.to_s,
        'X-EBAY-API-SITEID' => @site_id.to_s,
        'Content-Type' => 'text/xml'
      }
    end