Dataset Viewer
Auto-converted to Parquet
text
stringlengths
20
812k
id
stringlengths
40
40
metadata
dict
# Server Routes ``` / /lobby /game ``` ## overview Route: / ### Enter lobby: expects: { "request" : "enter_lobby", "data" : { "player_name": <player_name> } } returns: { "name" : "enter_lobby", "data" : { "session": <session> } } Client should redirect to ```/lobby?session=<session>``` Some kind of overview page. Shows highscore, register and login players. ### login A session key is generated and it is stored locally inside the URL as get parameter `?session=@@@@@@@`. ## lobby __Route:__ /lobby __Sends frequently:__ { "name" : "game_list", "data" : { games : [ { "game_id" : <game_id>, "game_label" : <label of the game>, "player_list" : [], "game_status" : <initialized | started | finished> } ] } } __Requests:__ ### Create a game: expects: { "request" : "create_game", "data" : { "game_label" : "<label_of_the_game>" } } returns: { "name" : "create_game", "data" : { "game_id": <game_id> } } Client should redirect to ```/game?game_id=<game_id>&session=<session>``` ## Game __Route:__ /game __Incoming Events:__ ``` { "name" : "possible_requests", "data" : { requests : [{request:<request>, data: {}}] } } ``` ``` { "name" : "error", "data" : { "id" : <id>, "message" : <message> } } ``` Where id is: EXPECT_EQ(Error::NoError, 0); EXPECT_EQ(Error::InvalidRoute, 1); EXPECT_EQ(Error::UnsupportedAction, 2); EXPECT_EQ(Error::MalformedRequest, 3); EXPECT_EQ(Error::InvalidRequest, 4); EXPECT_EQ(Error::InternalError, 5); EXPECT_EQ(Error::InsufficientMoney, 6); EXPECT_EQ(Error::InsufficientCoins, 7); ``` { "name" : "money_change", "data" : { player: <name>, deposit: <new_value> } } ``` ``` { "name" : "property_change", "data" : { index: <index>, owner: <player_name>, construction_level: <level> } } ``` ``` { "name" : "player_move", "data" : { player_name : <player_name>, type : <forward | backward | jump> target : <field_index> } } ``` ``` { "name" : "end_game" } ``` __Requests:__ ### Game Board Expects: { "request" : "game_board" } Returns: { "name" : "game_board", "data" : { fields : [ { name : <field_name>, type : < start | street | station | event_card | society_card | jail | free | go_to_jail | tax | utility >, group : < 0 | 1 | ... | 9 >, price : <price>, house_price : <price>, rent : [ <base_rent>, <one_house_rent>, ..., <hotel_rent> ] }, ... ] } } ### Join Game Expects: { "request" : "join_game" } Returns: { "name" : "join_game", "data" : { player_name : <player_name> } } ### Ready Expects: { "request" : "player_ready" } Returns: { "name" : "player_ready", "data" : { player_name : <player_name> } } ### Start a game: Expects: { "request" : "game_start" } Returns: { "name" : "game_start" } ### End turn: Expects: { "request" : "end_turn" } Returns: { "name" : "change_turn", "data" : { player_name : <player_name> } } ### Roll dices: Expects: { "request" : "roll_dice" } Returns: { "name" : "roll_dice", "data" : { player_name : <player_name>, eyes : [<eye1>, <eye2>] } } ### Don't buy a Street Possible Request: ``` { "request" : "dont_buy_field", } ``` ### Buy a Street Possible Request: ``` { "request" : "buy_field", } ``` Returns: on success: ``` { "name" : "property_change", "data" : { index: <index>, owner: <player_name>, construction_level: <level> } } ``` or on failure: ``` { "name" : "error", "data" : { "id" : <id>, "message" : <message> } } ``` ### Pay a Debt Possible Request: ``` { "request" : pay_debt, "data": { "amount": <amount>, "beneficiary" : <name> } } ``` Request: ``` { "request" : pay_debt, "data": { "beneficiary": <name> } } ``` Returns: on success: ``` { "name" : "money_change", "data" : { player: <name>, deposit: <new_value> } } ``` or on failure: ``` { "name" : "error", "data" : { "id" : <id>, "message" : <message> } } ``` ### Build Houses Possible Request: ``` { "request" : build_houses, "data": { "groups": [<group_id>, ...] } } ``` Request: Construction level needs to be in range from 0 = no building, 1 = one house, ... up to 5 = hotel. A request can only contain fields from one group. ``` { "request" : build_houses, "data": { "building_sites": { <field_id> : <construction_level>, ... } } } ``` Returns: on success: ``` { "name" : "property_change", "data" : { index: <index>, owner: <player_name>, construction_level: <level> } } ``` or on failure: ``` { "name" : "error", "data" : { "id" : <id>, "message" : <message> } } ``` # ## Watson Is a game manipulating instance, which allows the player to cheat around in the game. But it comes for a price. Watson demands real life actions and informations. Some actions have direct impact on the game while others generate Watson Coins. __Watson Coins__ can be used as currency by the course of 1 coin to 50 ingame money. ### Advertising Client sends on click to server: ``` { "request" : "clicked_on_add", "data" : { "add_name" : <add_name> } } ``` Effect: Server manipulates the current players roll dice result. ### Scanned GMail Account Client sends on scan gmail account to server: ``` { "request" : "scanned_gmail_account", "data" : { "dices" : [ <eyes>, <eyes> ] } } ``` Effect: Player will roll the requested eyes on next roll dice. ### Add Watson Coins Client sends for each round a player hast activated bitcoin mining a request to add a watson coin: ``` { "request" : "add_watson_coin", "data" : { "amount" : <amount>, "source" : "bitcoin_mining" } } ```
b3c8348d7a51d916aff62ce6a238ef0f8972a71e
{ "blob_id": "b3c8348d7a51d916aff62ce6a238ef0f8972a71e", "branch_name": "refs/heads/master", "committer_date": "2018-10-07T08:36:53", "content_id": "26ea4a46f3ddabe79389171a717a26b7b78f25c4", "detected_licenses": [ "MIT" ], "directory_id": "a3cf247e8702f42566f631022c79947e1bfa04a6", "extension": "md", "filename": "api.md", "fork_events_count": 0, "gha_created_at": "2018-04-20T09:12:56", "gha_event_created_at": "2019-01-31T08:09:57", "gha_language": "C++", "gha_license_id": "MIT", "github_id": 130338757, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 7326, "license": "MIT", "license_type": "permissive", "path": "/api/api.md", "provenance": "stack-edu-markdown-0006.json.gz:51695", "repo_name": "ratnim/SelfawareMonopoly", "revision_date": "2018-10-07T08:36:53", "revision_id": "d378d3d30a8d432113a881f335e5272842f65d12", "snapshot_id": "a3e01151d11ce76aeb83139bfa32dff946b28756", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/ratnim/SelfawareMonopoly/d378d3d30a8d432113a881f335e5272842f65d12/api/api.md", "visit_date": "2021-07-05T21:48:29.889288", "added": "2024-11-18T19:14:19.162046+00:00", "created": "2018-10-07T08:36:53", "int_score": 3, "score": 3.296875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0006.json.gz" }
--- title: bud.when description: Conditionally execute a function based on conditions --- Executes a function if a given test is `true`. - The first parameter is the conditional check. - The second parameter is the function to run if `true`. - The third parameter is optional; executed if the conditional is not `true`. ## Usage Only produce a vendor bundle when running in `production` mode: ```js bud.when(bud.isProduction, () => bud.vendor()) ``` Use `eval` sourcemap in development mode and `hidden-source-map` in production: ```js bud.when( bud.isDevelopment, () => bud.devtool('eval'), () => bud.devtool('hidden-source-map'), ) ``` For clarity, here is a very verbose version of the same thing: ```js const test = bud.isDevelopment const inProduction = () => bud.devtool('eval') const inDevelopment = () => bud.devtool('hidden-source-map') bud.when(test, inProduction, inDevelopment) ```
7013511ba68a819a974178ea55a401b73a1d69c9
{ "blob_id": "7013511ba68a819a974178ea55a401b73a1d69c9", "branch_name": "refs/heads/main", "committer_date": "2023-08-24T16:36:33", "content_id": "3eadd1d0bdd58e1e717ec486a2db5e098c9087e9", "detected_licenses": [ "MIT" ], "directory_id": "ce7b6b3a0f405a965e44dc3bcc7ea6e9e36e7bc2", "extension": "mdx", "filename": "bud.when.mdx", "fork_events_count": 45, "gha_created_at": "2020-06-13T07:56:37", "gha_event_created_at": "2023-09-13T16:35:03", "gha_language": "TypeScript", "gha_license_id": "MIT", "github_id": 271965695, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 910, "license": "MIT", "license_type": "permissive", "path": "/sources/@repo/docs/content/reference/bud.when.mdx", "provenance": "stack-edu-markdown-0005.json.gz:206609", "repo_name": "roots/bud", "revision_date": "2023-08-24T16:36:33", "revision_id": "189de01ad6611d6a9f14c015ce69e93eafa73cf9", "snapshot_id": "db0d45e87c945ea79987cc54db27c4a216cf92f8", "src_encoding": "UTF-8", "star_events_count": 277, "url": "https://raw.githubusercontent.com/roots/bud/189de01ad6611d6a9f14c015ce69e93eafa73cf9/sources/@repo/docs/content/reference/bud.when.mdx", "visit_date": "2023-08-24T16:49:13.767031", "added": "2024-11-18T22:10:07.855053+00:00", "created": "2023-08-24T16:36:33", "int_score": 4, "score": 3.859375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0005.json.gz" }
<div class="h-50 h-width-100" style="text-align:center"> <div style="text-align:center" id="top1"> <img style="width:400px" src="https://i.ibb.co/9tKSzNv/h-Trixx-Framework-Logo-Small.png" id="htrixxLogo" /> </div> <br /> <br /> <h5 class="h-p-30 h-p-r-300 h-p-l-300" id="use0"> Htrixx is an open-source web development framework. In htrixx you will find many html components that will change from the moment you add hTrixx as a reference in your project. </h5> <h6 class="h-p-30 h-p-r-300 h-p-l-300" id="use0"> Some things about hTrixx: </h6> <p class="h-p-r-400 h-p-l-400" id="use2"> ✓ It is very easy to use </p> <p class="h-p-r-400 h-p-l-400" id="use1"> ✓ It can be used together with Bootstrap and jQuery </p> <p class="h-p-r-400 h-p-l-400" id="use1"> ✓ Contains all HTML elements </p> <p class="h-p-r-400 h-p-l-400" id="use1"> ✓ It's responsive </p> <p class="h-p-r-400 h-p-l-400" id="use1"> ✓ It is free and so it will always be </p> <p class="h-p-r-400 h-p-l-400" id="use1"> ✓ New components are still being developed which will be released after testing </p> </div> <div class="h-grey-b-new h-50 h-width-100"> <br /> <br /> <h5 class="h-p-r-300 h-p-l-300 text-center h-white"> Explore our components </h5> <br /> <div class="row h-m-30 h-white"> <div class="col-md-12 col-12 text-center"> <p>hTrixx is constantly developing. All the components will remain unchanged, so you can work with the current version, and instead new components will be added.</p> </div> </div> <address class="text-center h-white"> <strong>Contact me at:</strong> <a href="mailto:s.darco.stefan<EMAIL_ADDRESS> </address> <br /> <br /> </div>
84ad90008559d595458f9d00eb27731e18cdab30
{ "blob_id": "84ad90008559d595458f9d00eb27731e18cdab30", "branch_name": "refs/heads/master", "committer_date": "2022-04-07T17:25:50", "content_id": "cf6d6e6efc5e5e058b8cc21048030170e56303f7", "detected_licenses": [ "MIT" ], "directory_id": "880addb5a98c5c3f4552d0eaa5c7cd433a6968ef", "extension": "md", "filename": "README.md", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 184127173, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 1918, "license": "MIT", "license_type": "permissive", "path": "/README.md", "provenance": "stack-edu-markdown-0003.json.gz:162769", "repo_name": "darcostoianov/hTrixx", "revision_date": "2022-04-07T17:25:50", "revision_id": "c7ec3ca9a6212cbe5fee13ff8556469ef885868a", "snapshot_id": "4e683daa5de927be110336ee6cee66c991551536", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/darcostoianov/hTrixx/c7ec3ca9a6212cbe5fee13ff8556469ef885868a/README.md", "visit_date": "2022-05-05T07:23:06.767637", "added": "2024-11-18T22:19:33.869434+00:00", "created": "2022-04-07T17:25:50", "int_score": 2, "score": 2.03125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0003.json.gz" }
<?php namespace App\Facades\Components; class FileCheck { /** * ファイルサイズが指定した最大サイズより小さいかどうか * * @param int $maxSize * @param int $fileSize * @return bool */ public function isLowerMaxSize(int $maxSize, int $fileSize){ return ($maxSize > $fileSize) ? true : false; } /** * ファイルが指定した拡張子かどうか * * @param array $extensions * @param string $fileExtension * @return bool */ public function isExtension(array $extensions, string $fileExtension) { return in_array($fileExtension, $extensions ) ? true : false; } }
57c67fda7806239160454388a0b825a4c798f707
{ "blob_id": "57c67fda7806239160454388a0b825a4c798f707", "branch_name": "refs/heads/master", "committer_date": "2019-07-06T04:03:52", "content_id": "f6004555cd38eda3a5b6b19e6614b5a5a8926101", "detected_licenses": [ "MIT" ], "directory_id": "561bb49e484579b3cfd379d16f5777470c9b6560", "extension": "php", "filename": "FileCheck.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 182502938, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 742, "license": "MIT", "license_type": "permissive", "path": "/application/app/Facades/Components/FileCheck.php", "provenance": "stack-edu-0053.json.gz:272599", "repo_name": "suupoo/kss-lab", "revision_date": "2019-07-06T04:03:52", "revision_id": "2f3e226ecdddc535b006b10cd52ffbb715022cd5", "snapshot_id": "c7beb8a2db55b08ab21615619dd4e7ebc10a0cc4", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/suupoo/kss-lab/2f3e226ecdddc535b006b10cd52ffbb715022cd5/application/app/Facades/Components/FileCheck.php", "visit_date": "2022-03-13T13:21:30.275972", "added": "2024-11-18T23:15:20.830281+00:00", "created": "2019-07-06T04:03:52", "int_score": 3, "score": 2.984375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0071.json.gz" }
// // AdvancedSearchBandsResultsViewController.swift // Metal Archives // // Created by Thanh-Nhon Nguyen on 12/03/2019. // Copyright © 2019 Thanh-Nhon Nguyen. All rights reserved. // import UIKit import Toaster import FirebaseAnalytics final class AdvancedSearchBandsResultsViewController: RefreshableViewController { var optionsList: String! private var bandAdvancedSearchResultPagableManager: PagableManager<AdvancedSearchResultBand>! weak var simpleNavigationBarView: SimpleNavigationBarView? override func viewDidLoad() { super.viewDidLoad() initBandAdvancedSearchResultPagableManager() bandAdvancedSearchResultPagableManager.fetch() } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) simpleNavigationBarView?.setRightButtonIcon(nil) simpleNavigationBarView?.isHidden = false } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) simpleNavigationBarView?.isHidden = !isMovingToParent } override func initAppearance() { super.initAppearance() tableView.contentInset = UIEdgeInsets(top: baseNavigationBarViewHeightWithoutTopInset, left: 0, bottom: UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0, right: 0) AdvancedBandNameTableViewCell.register(with: tableView) LoadingTableViewCell.register(with: tableView) } override func refresh() { bandAdvancedSearchResultPagableManager.reset() tableView.reloadData() DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) { self.bandAdvancedSearchResultPagableManager.fetch() } Analytics.logEvent("refresh_advanced_search_band_results", parameters: nil) } func initBandAdvancedSearchResultPagableManager() { guard var formattedOptionsList = optionsList.addingPercentEncoding(withAllowedCharacters: customURLQueryAllowedCharacterSet) else { assertionFailure("Error adding percent encoding to option list.") return } // encode space by + instead of %20 formattedOptionsList = formattedOptionsList.replacingOccurrences(of: "%20", with: "+") bandAdvancedSearchResultPagableManager = PagableManager<AdvancedSearchResultBand>(options: ["<OPTIONS_LIST>": formattedOptionsList]) bandAdvancedSearchResultPagableManager.delegate = self } private func updateTitle() { guard let totalRecords = bandAdvancedSearchResultPagableManager.totalRecords else { simpleNavigationBarView?.setTitle("No result found") return } if totalRecords == 0 { simpleNavigationBarView?.setTitle("No result found") } else if totalRecords == 1 { simpleNavigationBarView?.setTitle("Loaded \(bandAdvancedSearchResultPagableManager.objects.count) of \(totalRecords) result") } else { simpleNavigationBarView?.setTitle("Loaded \(bandAdvancedSearchResultPagableManager.objects.count) of \(totalRecords) results") } } } //MARK: - PagableManagerDelegate extension AdvancedSearchBandsResultsViewController: PagableManagerDelegate { func pagableManagerDidBeginFetching<T>(_ pagableManager: PagableManager<T>) where T : Pagable { simpleNavigationBarView?.setTitle("Loading...") showHUD() } func pagableManagerDidFailFetching<T>(_ pagableManager: PagableManager<T>) where T : Pagable { hideHUD() endRefreshing() Toast.displayMessageShortly(errorLoadingMessage) } func pagableManagerDidFinishFetching<T>(_ pagableManager: PagableManager<T>) where T : Pagable { hideHUD() endRefreshing() updateTitle() tableView.reloadData() } } //MARK: - UITableViewDelegate extension AdvancedSearchBandsResultsViewController: UITableViewDelegate { func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) guard let manager = bandAdvancedSearchResultPagableManager else { return } if manager.objects.indices.contains(indexPath.row) { let result = manager.objects[indexPath.row] pushBandDetailViewController(urlString: result.band.urlString, animated: true) Analytics.logEvent("select_an_advanced_search_result", parameters: nil) } } func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { guard let _ = bandAdvancedSearchResultPagableManager.totalRecords else { return } if bandAdvancedSearchResultPagableManager.moreToLoad && indexPath.row == bandAdvancedSearchResultPagableManager.objects.count { bandAdvancedSearchResultPagableManager.fetch() } else if !bandAdvancedSearchResultPagableManager.moreToLoad && indexPath.row == bandAdvancedSearchResultPagableManager.objects.count - 1 { Toast.displayMessageShortly(endOfListMessage) } } } //MARK: - UITableViewDataSource extension AdvancedSearchBandsResultsViewController: UITableViewDataSource { func numberOfSections(in tableView: UITableView) -> Int { return 1 } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { guard let manager = bandAdvancedSearchResultPagableManager else { return 0 } if manager.moreToLoad { if manager.objects.count == 0 { return 0 } return manager.objects.count + 1 } return manager.objects.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if bandAdvancedSearchResultPagableManager.moreToLoad && indexPath.row == bandAdvancedSearchResultPagableManager.objects.count { let loadingCell = LoadingTableViewCell.dequeueFrom(tableView, forIndexPath: indexPath) loadingCell.displayIsLoading() return loadingCell } let cell = AdvancedBandNameTableViewCell.dequeueFrom(tableView, forIndexPath: indexPath) let result = bandAdvancedSearchResultPagableManager.objects[indexPath.row] cell.fill(with: result) cell.tappedThumbnailImageView = { [unowned self] in self.presentPhotoViewerWithCacheChecking(photoUrlString: result.band.imageURLString, description: result.band.name, fromImageView: cell.thumbnailImageView) Analytics.logEvent("view_advanced_search_result_thumbnail", parameters: nil) } return cell } } // MARK: - UIScrollViewDelegate extension AdvancedSearchBandsResultsViewController: UIScrollViewDelegate { func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { simpleNavigationBarView?.transformWith(scrollView) } }
0e8fffbd4fd91f5c75b494f3a56d5bbca5b3caef
{ "blob_id": "0e8fffbd4fd91f5c75b494f3a56d5bbca5b3caef", "branch_name": "refs/heads/master", "committer_date": "2021-03-27T21:08:03", "content_id": "cdb3983c189e499e5c45c1f8f98c25691b5209b7", "detected_licenses": [ "Apache-2.0" ], "directory_id": "69a4ccf0fe074f924c5c2746c86d971da3cb5582", "extension": "swift", "filename": "AdvancedSearchBandsResultsViewController.swift", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Swift", "length_bytes": 7136, "license": "Apache-2.0", "license_type": "permissive", "path": "/Metal Archives/Metal Archives/Controllers/Search/AdvancedSearch/AdvancedSearchBands/AdvancedSearchBandsResultsViewController.swift", "provenance": "stack-edu-0071.json.gz:722076", "repo_name": "mohsinalimat/Metal-Archives-iOS", "revision_date": "2021-03-27T21:08:03", "revision_id": "274527b791c90b916511d76f6e37982fb5742a42", "snapshot_id": "b5d9b271cf92566b454d77399e6b0942ec24a1f2", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/mohsinalimat/Metal-Archives-iOS/274527b791c90b916511d76f6e37982fb5742a42/Metal Archives/Metal Archives/Controllers/Search/AdvancedSearch/AdvancedSearchBands/AdvancedSearchBandsResultsViewController.swift", "visit_date": "2023-04-02T22:47:34.281621", "added": "2024-11-18T21:24:20.429614+00:00", "created": "2021-03-27T21:08:03", "int_score": 2, "score": 2.296875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0089.json.gz" }
#coding:utf-8 #创建和使用字典 def first(): phonebook = {'Alice':'2341','Beth':'9102','Cecil':'3258'} print phonebook,phonebook['Alice'] #dict函数通过其他映射或者键值对的序列建立字典 def second(): items = [('name','Gumby'),('age',42)] d = dict(items) print d['name'],'\n',d dic = dict(name = 'fuzongjian',age = 42) print dic #基本字典操作 ''' len(dict)返回dict中项(键-值对)的数量 del dict[k]删除键为k的项 k in dict 检查d中是否含有键为k的项 ''' def third(): people = { 'Alice':{ 'phone':'1234', 'addr':'Foo drive 23' }, 'Beth':{ 'phone':'2364', 'addr':'Foo drive 23' }, 'Cecil':{ 'phone':'2345', 'addr':'Foo drive 23' } } print len(people) #字典的格式化字符串 def firth(): template = ''' <html> <head><title>%(title)s</title></head> <body> <h1>%(title)s</h1> <p>%(text)s</p> </body> </html> ''' data = {'title':'My Home Page','text':'Welcome to my home page!'} print template % data #字典方法 from copy import deepcopy def fifth(): #clear方法清除字典中的所有想。 dic = {} dic['name'] = 'fuzongjian' print dic,'-----',dic.clear(),'-----',dic #copy方法返回一个具有相同键值对的新字典-----浅复制 print '浅复制' x = {'name':'fuzongjian','age':['1','2','3']} y = x.copy() print x,'---',y y['name'] = 'fuzongyang' y['age'].remove('1') print x,'---',y #deepcopy深复制 print '深复制' d = {} d['name'] = ['fuzongjian','fuzongyang'] c = d.copy() dc = deepcopy(d) d['name'].append('fuzonglin') print c,'---',dc print 'fromkeys方法使用给定的键建立新的字典,每个键都对应一个默认的值None' print {}.fromkeys(['name','age']) print dict.fromkeys(['name','age']) print dict.fromkeys(['name','age'],'(unknown)') print 'get方法是个更宽松的访问字典项的方法' ''' 当我们使用dict[key]时,如果key不存在的话,一般会报错,而选择dict.get(key)不会报错,会返回一个None,同时自己也可自定义 一个“默认值”,替换None ''' test = {} print test.get('name') print test.get('name','fuzongjian') #has_key方法可以检查字典中是否含有特定的键 sy = {'name':'fuzongjian'} print sy.has_key('age'),'---',sy.has_key('name') #items和iteritems #items方法将字典所有的项以列表的方式返回,列表中的每一项都标示为键值对的形式,但是项在返回时并没有遵循特定的次序 wx = {'name':'fuzongjian','age':20,'hobby':'running'} print wx.items() #iteritems方法的作用大致相同,但是返回一个迭代器对象而不是列表 print wx.iteritems(),'---',list(wx.iteritems()) #key和iterkeys ----values和itervalues #key方法将字典中的键以列表形式返回,而iterkeys则返回针对键的迭代器 print wx.keys(),'---',wx.iterkeys(),'---',list(wx.iterkeys()) print wx.values(),'---',wx.itervalues(),'---',list(wx.itervalues()) #pop方法用来获取对应于给定键的值,然后将这个键-值对从字典中移除 nb = {'name':'fuzongjian','hobby':'running'} print nb.pop('hobby'),'---',nb #popitem方法类似于list.pop,后者会弹出列表的最后一个元素,popitem弹出随机的项,因为字典元素随机 ue = {'name':'fuzongjian','hobby':'running','age':1993} print ue.popitem() #setdefault方法在某种程度上类似于get方法,能够获得与给定键相关联的值, #除此之外,setdefault还能在字典这个不含有给定键的情况下设定相应的键值 xn = {} print xn.setdefault('name','fuzongjian') xn['name'] = 'rabbit' print xn.setdefault('name','1234') print xn print xn.setdefault('age') #update方法可以利用一个字典更新另外一个字典 vr = {'name':'fuzongjian'} ar = {'age':1993} vr.update(ar) print vr def appRun(): fifth() # firth() # third() # second() # first() if __name__ == '__main__': appRun()
e1cd3f4e53cdd8d7c645519b0fc4b72692fa096e
{ "blob_id": "e1cd3f4e53cdd8d7c645519b0fc4b72692fa096e", "branch_name": "refs/heads/master", "committer_date": "2016-12-19T11:58:55", "content_id": "960290ae3dc234fa9289eafbebe0a9edd6fa0cf0", "detected_licenses": [ "Apache-2.0" ], "directory_id": "4df7feb529d6f57d00a61f9f47634ddeadc9a8f7", "extension": "py", "filename": "base.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 67490254, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 3942, "license": "Apache-2.0", "license_type": "permissive", "path": "/字典/base.py", "provenance": "stack-edu-0058.json.gz:332264", "repo_name": "fuzongjian/PythonStudy", "revision_date": "2016-12-19T11:58:55", "revision_id": "1977b08733235946230bb73d3ad92d4853e12f7d", "snapshot_id": "42ee59d3719a1ed5e88cc7428b5b107f52bad84d", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/fuzongjian/PythonStudy/1977b08733235946230bb73d3ad92d4853e12f7d/字典/base.py", "visit_date": "2020-09-10T08:18:08.354978", "added": "2024-11-19T00:43:45.826813+00:00", "created": "2016-12-19T11:58:55", "int_score": 4, "score": 4.5, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0076.json.gz" }
from datetime import datetime,timedelta import numpy ''' ----------------------------------------------------------------- mydatetime v0.2 for python Copyright (c) 2015 hadacchi ----------------------------------------------------------------- *** This script requires numpy, i.e. numerical python *** This script converts from/into date into/from serial date. MS Excel counts 1900/2/29 (ref. Microsoft Help & Support No. 214019), but python doesn't count. Thus, return value from this script `toSerial()' is equals only after 1900/3/1 If you need valid serial date, change base date `__ZERODATE' from (datetime.datetime(1970,1,1),25569) to (datetime.datetime(1900,1,1),1) ''' class mydatetime(datetime): ## base date # to identify Excels __ZERODATE=(datetime(1970,1,1,0,0,0,0),25569) # to return valid serial date #__ZERODATE=(datetime(1900,1,1,0,0,0,0),1) ## expression for milliseconds __MILLIFMT='%u' def __sub__(self,t): # if return value is <type 'timedelta'> if t.__class__ == self.__class__ or \ t.__class__ == self.__ZERODATE[0].__class__: #return super(mydatetime,self).__sub__(self,t) return super().__sub__(t) # else (mydatetime-timedelta) should be mydatetime else: #tmp = super(mydatetime,self).__sub__(t) tmp = super().__sub__(t) return self.__class__( tmp.year,tmp.month,tmp.day,tmp.hour, tmp.minute,tmp.second,tmp.microsecond,tmp.tzinfo ) def __add__(self,t): # if return value is <type 'timedelta'> if t.__class__ == self.__class__ or \ t.__class__ == self.__ZERODATE[0].__class__: return datetime.__add__(t) # else (mydatetime-timedelta) should be mydatetime else: #tmp = super(mydatetime,self).__add__(self,t) tmp = super().__add__(t) return self.__class__( tmp.year,tmp.month,tmp.day,tmp.hour, tmp.minute,tmp.second,tmp.microsecond,tmp.tzinfo ) def strftime(self,fmt): '''milliseconds (output by %u) is implemented''' tmp=[] for i in fmt.split('%%'): tmp.append(('%06d'%self.microsecond)[:3]\ .join(i.split(self.__MILLIFMT))) return super(mydatetime,self).strftime(self,'%%'.join(tmp)) def toSerial(self): '''return serial date''' tmp=self-self.__ZERODATE[0] serial_val=self.__ZERODATE[1]+tmp.days serial_val=serial_val+float(tmp.seconds)/24/3600\ +float(tmp.microseconds)/24/3600/1000000 return serial_val @staticmethod def fromTuple(d,t=(0,0,0)): '''d=(year,month,day),t=(hour,min,sec),sec can be float''' if type(t[2]) is float: f=int(t[2]*1000000-int(t[2])*1000000) elif len(t)>=4: f=t[3] else: f=0 # call parent's constructor return mydatetime(d[0],d[1],d[2],t[0],t[1],int(t[2]),f) @staticmethod def fromSerial(val): '''return mydatetime from serial value''' tmp=val-mydatetime._mydatetime__ZERODATE[1] day=int(tmp) sec=round((tmp-day)*24*3600,3) dt=timedelta(days=day,seconds=sec) tmp=mydatetime._mydatetime__ZERODATE[0]+dt # call parent's constructor return mydatetime(tmp.year,tmp.month,tmp.day, tmp.hour,tmp.minute,tmp.second,tmp.microsecond,tmp.tzinfo) @staticmethod def Serial2Sec(val,comp=False): '''if comp is True, return complete seconds(LongInt) from ZERODATE ''' if type(val)!=numpy.ndarray: if type(val)!=type([]): numpy.array([val]) else: numpy.array(val) else: True c=24*3600 if not comp: return numpy.round((val-numpy.array(val,dtype=int))*c,3) else: val=val-mydatetime._mydatetime__ZERODATE[1] return numpy.round((val-numpy.array(val,dtype=int))*c+numpy.array(val,dtype=int)*c,3) if len(ret)==1: return ret[0] else: return ret
7dd43b2d969279641dc8d71a33090478634f9a05
{ "blob_id": "7dd43b2d969279641dc8d71a33090478634f9a05", "branch_name": "refs/heads/master", "committer_date": "2017-02-06T12:51:07", "content_id": "fe33d14f3ce3fbab01a6b3264f0122a30e8220d0", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "2b2d4e0eaff5953f68b150f5611936ec652e9316", "extension": "py", "filename": "mydatetime.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 43641323, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 4126, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/mydatetime.py", "provenance": "stack-edu-0054.json.gz:777761", "repo_name": "hadacchi/mydatetime", "revision_date": "2017-02-06T12:51:07", "revision_id": "7fdcc682be3ede7cd22ee9221a4ee90d4ded4c14", "snapshot_id": "d4d891d2859e28129ce31be8fcc0e84f9a4a1869", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/hadacchi/mydatetime/7fdcc682be3ede7cd22ee9221a4ee90d4ded4c14/mydatetime.py", "visit_date": "2021-01-17T14:51:06.518323", "added": "2024-11-19T00:07:11.707961+00:00", "created": "2017-02-06T12:51:07", "int_score": 3, "score": 3.15625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0072.json.gz" }
--- name: Bug report about: Create a report to help us improve title: '' labels: bug assignees: '' --- **Before you open an issue** - [ ] Are you using [the latest Gordon version](https://github.com/Banno/Gordon/releases/latest)? If not, try updating. - [ ] Are you using [the latest Gradle version](https://gradle.org/releases)? If not, try updating. If you can't update your Gradle version, you may have to use an older Gordon version that supports the outdated Gradle version. - [ ] Are you using [the latest Android Gradle Plugin version](https://developer.android.com/studio/releases/gradle-plugin)? If not, try updating. If you can't update your AGP version, you may have to use an older Gordon version that supports the outdated AGP version. - [ ] Are you sure this is a bug? If it's a feature request or idea for improvement, or if you're just not sure that your problem is caused by a Gordon bug rather than something else, consider posting in the ["Ideas"](https://github.com/Banno/Gordon/discussions/categories/ideas) or ["Q&A"](https://github.com/Banno/Gordon/discussions/categories/q-a) Discussion categories instead of opening an issue. **Describe the bug** <!-- A clear and concise description of what the bug is --> **To Reproduce** <!-- Edit the following example steps to explain exactly how to reproduce your issue --> 1. Apply Gordon to an Android [app|library|feature] module. 2. The module has the following special setup (or n/a if it has fairly standard setup). Feel free to paste your whole buildscript with any proprietary details redacted. 3. Run the following gradle task with these arguments. 4. See error **Expected behavior** <!-- A clear and concise description of what you expected to happen --> **Additional context** <!-- Any other context about the problem -->
447e9048da6ff1197d75a46051585f910c5e2d1e
{ "blob_id": "447e9048da6ff1197d75a46051585f910c5e2d1e", "branch_name": "refs/heads/main", "committer_date": "2023-07-06T14:42:39", "content_id": "cdb084185b2f0869f3609da852de8faf0e5c1611", "detected_licenses": [ "Apache-2.0" ], "directory_id": "15043d686442ad4576f97ba5fe6e23a110689fe0", "extension": "md", "filename": "bug_report.md", "fork_events_count": 18, "gha_created_at": "2019-10-25T14:57:10", "gha_event_created_at": "2023-09-08T21:46:09", "gha_language": "Kotlin", "gha_license_id": "Apache-2.0", "github_id": 217557173, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 1803, "license": "Apache-2.0", "license_type": "permissive", "path": "/.github/ISSUE_TEMPLATE/bug_report.md", "provenance": "stack-edu-markdown-0003.json.gz:305540", "repo_name": "Banno/Gordon", "revision_date": "2023-07-06T14:42:39", "revision_id": "12df78e9ebe1f08c244434d38092b06adf86cab6", "snapshot_id": "9ca57afeaf4a109bc56943ff84ca102078e35545", "src_encoding": "UTF-8", "star_events_count": 160, "url": "https://raw.githubusercontent.com/Banno/Gordon/12df78e9ebe1f08c244434d38092b06adf86cab6/.github/ISSUE_TEMPLATE/bug_report.md", "visit_date": "2023-07-23T03:16:27.844635", "added": "2024-11-18T21:28:30.831320+00:00", "created": "2023-07-06T14:42:39", "int_score": 3, "score": 3.453125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0003.json.gz" }
### [CVE-2007-6753](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-6753) ![](https://img.shields.io/static/v1?label=Product&message=n%2Fa&color=blue) ![](https://img.shields.io/static/v1?label=Version&message=n%2Fa&color=blue) ![](https://img.shields.io/static/v1?label=Vulnerability&message=n%2Fa&color=brighgreen) ### Description Untrusted search path vulnerability in Shell32.dll in Microsoft Windows 2000, Windows XP, Windows Vista, Windows Server 2008, and Windows 7, when using an environment configured with a string such as %APPDATA% or %PROGRAMFILES% in a certain way, allows local users to gain privileges via a Trojan horse DLL under the current working directory, as demonstrated by iTunes and Safari. ### POC #### Reference - http://blog.acrossecurity.com/2010/10/breaking-setdlldirectory-protection.html #### Github No PoCs found on GitHub currently.
04be1356778cb8d73f7518fa9b2630a2184b54d7
{ "blob_id": "04be1356778cb8d73f7518fa9b2630a2184b54d7", "branch_name": "refs/heads/main", "committer_date": "2023-08-22T10:57:28", "content_id": "262801dbf7a96b4e1aee6e65872608ad7303e9c9", "detected_licenses": [ "MIT" ], "directory_id": "9b96a77fdd7eeba74a3d66d09eb8ebbf28b7b8b9", "extension": "md", "filename": "CVE-2007-6753.md", "fork_events_count": 647, "gha_created_at": "2022-01-31T13:23:51", "gha_event_created_at": "2023-05-24T04:54:19", "gha_language": "HTML", "gha_license_id": "MIT", "github_id": 454015416, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 880, "license": "MIT", "license_type": "permissive", "path": "/2007/CVE-2007-6753.md", "provenance": "stack-edu-markdown-0010.json.gz:287425", "repo_name": "trickest/cve", "revision_date": "2023-08-22T10:57:28", "revision_id": "193d43877d4d88120833461ebab51acc2e5e37f0", "snapshot_id": "2d5fdbb47e0baf6ce74e016190dec666cdfd9bfe", "src_encoding": "UTF-8", "star_events_count": 5091, "url": "https://raw.githubusercontent.com/trickest/cve/193d43877d4d88120833461ebab51acc2e5e37f0/2007/CVE-2007-6753.md", "visit_date": "2023-08-22T19:53:39.850122", "added": "2024-11-19T01:53:15.637727+00:00", "created": "2023-08-22T10:57:28", "int_score": 3, "score": 3.125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0010.json.gz" }
<?php declare(strict_types=1); /* * +----------------------------------------------------------------------+ * | ThinkSNS Plus | * +----------------------------------------------------------------------+ * | Copyright (c) 2017 Chengdu ZhiYiChuangXiang Technology Co., Ltd. | * +----------------------------------------------------------------------+ * | This source file is subject to version 2.0 of the Apache license, | * | that is bundled with this package in the file LICENSE, and is | * | available through the world-wide-web at the following url: | * | http://www.apache.org/licenses/LICENSE-2.0.html | * +----------------------------------------------------------------------+ * | Author: Slim Kit Group <master@zhiyicx.com> | * | Homepage: www.thinksns.com | * +----------------------------------------------------------------------+ */ namespace Zhiyi\Component\ZhiyiPlus\PlusComponentFeed\Tests\API2; use Zhiyi\Plus\Models\User; use Zhiyi\Plus\Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseTransactions; class TestGetDetailFeed extends TestCase { use DatabaseTransactions; private $user; /** * 前置条件. */ public function setUp() { parent::setUp(); $this->user = factory(User::class)->create(); $this->user->roles()->sync([2]); } public function testGetFeedList() { $this->addTestFeedData($this->user); $response = $this->get('/api/v2/feeds/'.$this->feed['id']); $response->assertStatus(200) ->assertJsonStructure([ 'id', 'user_id', 'feed_content', 'feed_from', 'like_count', 'feed_view_count', 'feed_comment_count', 'feed_latitude', 'feed_longtitude', 'feed_geohash', 'audit_status', 'feed_mark', 'created_at', 'updated_at', 'deleted_at', 'has_collect', 'has_like', 'reward', 'images', 'paid_node', 'likes', ]); } /** * @param $user * @return mixed */ protected function addTestFeedData($user) { $data = [ 'feed_content' => '单元测试动态数据', 'feed_from' => 1, 'feed_mark' => time(), 'feed_latitude' => '', 'feed_longtitude' => '', 'feed_geohash' => '', 'amount' => 100, 'images' => [], ]; $this->feed = $this->actingAs($user, 'api')->post('api/v2/feeds', $data)->json(); } }
3ccc8a0aca1cbb2ac47eafbf6dd848c9bf72636c
{ "blob_id": "3ccc8a0aca1cbb2ac47eafbf6dd848c9bf72636c", "branch_name": "refs/heads/master", "committer_date": "2018-02-06T10:24:22", "content_id": "37c70cedc2d1dcb046c3562d66b37ebe41688ff1", "detected_licenses": [ "Apache-2.0" ], "directory_id": "df980e64e6e6c998fa66f8a9f869020929e9b6a4", "extension": "php", "filename": "TestGetDetailFeed.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 2912, "license": "Apache-2.0", "license_type": "permissive", "path": "/packages/slimkit-plus-feed/tests/API2/TestGetDetailFeed.php", "provenance": "stack-edu-0052.json.gz:901057", "repo_name": "XiaoqingWang/thinksns-plus", "revision_date": "2018-02-06T10:24:22", "revision_id": "013e65d1326fdca6588c181778e63a8af8676486", "snapshot_id": "50c17682bb9c6ebc4c20d3326f9b81d99aa351d3", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/XiaoqingWang/thinksns-plus/013e65d1326fdca6588c181778e63a8af8676486/packages/slimkit-plus-feed/tests/API2/TestGetDetailFeed.php", "visit_date": "2021-05-03T15:15:22.480427", "added": "2024-11-18T22:56:39.064538+00:00", "created": "2018-02-06T10:24:22", "int_score": 2, "score": 2.125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0070.json.gz" }
import numpy as np from scipy.optimize import linear_sum_assignment def intersection_over_union(segmented_map, gt_map): s_array = segmented_map.getEmMap().data() gt_array = gt_map.getEmMap().data() labels = np.unique(gt_array) if s_array.shape != gt_array.shape: return ValueError("Arrays must have same shape") else: iou_list = [] for label in labels: if label == 0: continue s_mask = s_array == label gt_mask = gt_array == label overlap = np.sum(np.logical_and(s_mask,gt_mask)) union = np.sum(np.logical_or(s_mask,gt_mask)) iou_list.append(overlap/union) iou = np.mean(iou_list) return iou def iou(s_array, gt_array, restricted=False): if restricted: labels = np.unique(gt_array) else: labels = np.unique(s_array) if s_array.shape != gt_array.shape: return ValueError("Arrays must have same shape") else: iou_list = [] for label in labels: if label == 0: continue s_mask = s_array == label gt_mask = gt_array == label overlap = np.sum(np.logical_and(s_mask,gt_mask)) union = np.sum(np.logical_or(s_mask,gt_mask)) iou_list.append(overlap/union) iou = np.mean(iou_list) return iou def matching_iou(segmented_map, gt_map): s_array = segmented_map.getEmMap().data() gt_array = gt_map.getEmMap().data() segmented_labels = np.unique(s_array) segmented_labels = segmented_labels[segmented_labels!=0] gt_labels = np.unique(gt_array) gt_labels = gt_labels[gt_labels!=0] print(segmented_labels) print(gt_labels) iou_tensor = np.zeros([len(segmented_labels), len(gt_labels)]) for i,s in enumerate(segmented_labels): for j,g in enumerate(gt_labels): seg_mask = s_array==s gt_mask = gt_array==g iou_tensor[i, j] = iou(seg_mask, gt_mask) row_ind, col_ind = linear_sum_assignment(iou_tensor, maximize=True) last_label = len(segmented_labels) label_replace_dict = {segmented_labels[r]:gt_labels[c]+last_label for c,r in zip(col_ind,row_ind)} label_replace_back_dict = {v:v-last_label for v in label_replace_dict.values() } iou_after = iou(s_array,gt_array) print("**",label_replace_dict) print("**",label_replace_back_dict) vol_before = { l:np.sum(s_array==l) for l in np.unique(s_array)} for k in label_replace_dict.keys(): s_array[s_array==k]=label_replace_dict[k] for k in label_replace_back_dict.keys(): new_label = label_replace_back_dict[k] existing_labels = np.unique(s_array) if new_label in existing_labels: s_array[s_array==new_label]= np.max(existing_labels)+1 s_array[s_array==k]= new_label vol_after = {l:np.sum(s_array==l) for l in np.unique(s_array)} print("**vol before: ", vol_before) print("**vol after ", vol_after) return iou(s_array,gt_array) def average_precision(segmented_map, gt_map, thresholds=np.arange(0.05,0.95,0.1)): segmented_array = segmented_map.getEmMap().data() gt_array = gt_map.getEmMap().data() segmented_labels = np.unique(segmented_array) segmented_labels = segmented_labels[segmented_labels!=0] gt_labels = np.unique(gt_array) gt_labels = gt_labels[gt_labels!=0] segmented_masks = [ segmented_array==l for l in segmented_labels ] gt_masks = [ gt_array==l for l in gt_labels ] iou_tensor = np.zeros([len(thresholds), len(segmented_masks), len(gt_masks)]) for i,seg_mask in enumerate(segmented_masks): for j,gt_mask in enumerate(gt_masks): iou_tensor[:, i, j] = iou_at_thresholds(gt_mask, seg_mask, thresholds) TP = np.sum((np.sum(iou_tensor, axis=2) == 1), axis=1) FP = np.sum((np.sum(iou_tensor, axis=1) == 0), axis=1) FN = np.sum((np.sum(iou_tensor, axis=2) == 0), axis=1) precision = TP / (TP + FP + FN + np.finfo(float).eps) print(precision) return np.mean(precision) def iou_at_thresholds(seg_mask, gt_mask, thresholds=np.arange(0.05,0.95,0.1)): intersection = np.logical_and(gt_mask, seg_mask) union = np.logical_or(gt_mask, seg_mask) iou = np.sum(intersection > 0) / np.sum(union > 0) return iou > thresholds def dice(segmented_map, gt_map): s_array = segmented_map.getEmMap().data() gt_array = gt_map.getEmMap().data() labels = np.unique(gt_array) if s_array.shape != gt_array.shape: return ValueError("Arrays must have same shape") else: dice_list = [] for label in labels: #if label == 0: # continue s_mask = s_array == label gt_mask = gt_array == label overlap = np.sum(np.logical_and(s_mask,gt_mask)) added = np.sum(s_mask) + np.sum(gt_mask) dice_list.append(2*overlap/added) dice = np.mean(dice_list) return dice def homogenity(segmented_map, gt_map): s_array = segmented_map.getEmMap().data() gt_array = gt_map.getEmMap().data() labels = np.unique(s_array) if s_array.shape != gt_array.shape: return ValueError("Arrays must have same shape") else: h_list = [] for label in labels: if label == 0: continue s_mask = s_array == label gt_mask = gt_array == label overlap = np.sum(np.logical_and(s_mask,gt_mask)) volume = np.sum(gt_mask) h_list.append(overlap/(volume+np.finfo(float).eps)) print("label {} overlap {} falses {} result {}".format(label, overlap,volume, overlap/(volume+np.finfo(float).eps))) h = np.mean(h_list) return h def proportion(segmented_map, gt_map): s_array = segmented_map.getEmMap().data() gt_array = gt_map.getEmMap().data() labels = np.unique(gt_array) if s_array.shape != gt_array.shape: return ValueError("Arrays must have same shape") else: p_list = [] count_labels = 0 for label in labels: if label == 0: continue s_mask = s_array == label gt_mask = gt_array == label s_mask_non_background = s_array != 0 proportion_mask = gt_mask * s_mask_non_background # need to check if should remove 0s num_labels = len(np.unique(s_array[proportion_mask])) p_list.append(num_labels) count_labels +=1 print("label {} proportion {}".format(label, num_labels)) p = np.sum(p_list)/count_labels return p def consistency(segmented_map, gt_map): s_array = segmented_map.getEmMap().data() gt_array = gt_map.getEmMap().data() labels = np.unique(gt_array) if s_array.shape != gt_array.shape: return ValueError("Arrays must have same shape") else: volumes_dict = {} for label in labels: if label == 0: continue s_mask = s_array == label gt_mask = gt_array == label volumes_dict[label] = np.sum(s_mask) label = max(volumes_dict, key=volumes_dict.get) gt_mask = gt_array == label c = len(np.unique(s_array[gt_mask])) return c
180abff5811182532ee07bfd44c920e1845d1f79
{ "blob_id": "180abff5811182532ee07bfd44c920e1845d1f79", "branch_name": "refs/heads/master", "committer_date": "2021-06-05T20:21:45", "content_id": "1053671d2efb3bcbff0f12731c2f9a421bb4da2e", "detected_licenses": [ "Apache-2.0" ], "directory_id": "38453ed90ea825bda25e6fcdda05744eefda855e", "extension": "py", "filename": "metrics.py", "fork_events_count": 0, "gha_created_at": "2019-01-08T18:53:02", "gha_event_created_at": "2023-01-07T18:31:01", "gha_language": "PLpgSQL", "gha_license_id": "Apache-2.0", "github_id": 164712917, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 7377, "license": "Apache-2.0", "license_type": "permissive", "path": "/em/src/dataset/metrics.py", "provenance": "stack-edu-0061.json.gz:570564", "repo_name": "tecdatalab/biostructure", "revision_date": "2021-06-05T20:21:45", "revision_id": "a30e907e83fa5bbfb934d951b7c663b622104fcc", "snapshot_id": "4b50f297932b2394d924e7de64f0d957f219dffd", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/tecdatalab/biostructure/a30e907e83fa5bbfb934d951b7c663b622104fcc/em/src/dataset/metrics.py", "visit_date": "2023-08-31T00:32:08.694944", "added": "2024-11-19T03:12:09.709491+00:00", "created": "2021-06-05T20:21:45", "int_score": 3, "score": 2.625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0079.json.gz" }
<?php namespace App\Http\Controllers; use App\Http\Requests\LoginRequest; use App\Http\Requests\SignUpRequest; use App\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; class AuthController extends Controller { // protected $user; public function __construct(User $user) { $this->user = $user; } public function getSignup() { return view('layout.signup'); } public function signup(Signuprequest $request) { $user = $request->all(); $this->user->createUser($user); // dd($user); return redirect()->route('login')->with('key', 'Đăng ký thành công'); } public function getLogin() { return view('layout.login'); } public function login(LoginRequest $request) { if (Auth::attempt(['username' => $request->username, 'password' => $request->password])) { // login thành công // check xem user này thuộc cái nào. và chuyển hướng tới cái đó. if (Auth::user()->user_type == 3) { return redirect()->route('getuser')->with('key', 'Đăng nhập thành công'); } elseif (Auth::user()->user_type == 2) { return redirect()->route('listtopic')->with('key', 'Đăng nhập thành công'); } elseif (Auth::user()->user_type == 1) { return redirect()->route('gettopic')->with('key', 'Đăng nhập thành công'); } } else { return redirect()->route('login')->with('error', 'Sai username hoặc mật khẩu'); } } public function logout() { Auth::logout(); return redirect()->route('login'); } }
9f50a46452849d7ab3d733e0613bc7eb67f99950
{ "blob_id": "9f50a46452849d7ab3d733e0613bc7eb67f99950", "branch_name": "refs/heads/master", "committer_date": "2020-12-23T13:52:35", "content_id": "a6344401f98ba9d39ee2053ab6e003acd2606ecd", "detected_licenses": [ "MIT" ], "directory_id": "87e51d4b338c13b7e56b63cdfded7ea280f0a196", "extension": "php", "filename": "AuthController.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 323913827, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 1766, "license": "MIT", "license_type": "permissive", "path": "/app/Http/Controllers/AuthController.php", "provenance": "stack-edu-0046.json.gz:449830", "repo_name": "thanhtrung1999/projectregister", "revision_date": "2020-12-23T13:52:35", "revision_id": "90dd69d4b304e9229e245ef40e90f46c4d1c3db9", "snapshot_id": "6efab33540e54a2040401949a8c3e229489976dc", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/thanhtrung1999/projectregister/90dd69d4b304e9229e245ef40e90f46c4d1c3db9/app/Http/Controllers/AuthController.php", "visit_date": "2023-02-03T14:51:31.680395", "added": "2024-11-19T00:43:34.717563+00:00", "created": "2020-12-23T13:52:35", "int_score": 3, "score": 2.59375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0064.json.gz" }
<?php namespace realSamy\reBot\Abstracts; /** * This object represents a bot command. * * @property string $command text of the command, 1-32 characters. can contain only lowercase english letters, * digits and underscores. * @property string $description description of the command, 3-256 characters. * @package realSamy\reBot\Abstracts */ abstract class BotCommand { }
4750c12e283c589d8a5abf84a00f4554d177b64e
{ "blob_id": "4750c12e283c589d8a5abf84a00f4554d177b64e", "branch_name": "refs/heads/master", "committer_date": "2021-01-01T14:03:52", "content_id": "f172a54972ec6af49547195e451792442faae829", "detected_licenses": [ "MIT" ], "directory_id": "448a4fdb87cadf25b74c0c807d00391af1769ba3", "extension": "php", "filename": "BotCommand.php", "fork_events_count": 1, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 325378206, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 405, "license": "MIT", "license_type": "permissive", "path": "/src/reBot/Abstracts/BotCommand.php", "provenance": "stack-edu-0052.json.gz:926936", "repo_name": "realSamy/reBot", "revision_date": "2021-01-01T14:03:52", "revision_id": "da773e4230400b0f5411994d3cf1fcfe194bdaf9", "snapshot_id": "1c30f5d2fe2cd269bb59ebb03c8349d498aa34c7", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/realSamy/reBot/da773e4230400b0f5411994d3cf1fcfe194bdaf9/src/reBot/Abstracts/BotCommand.php", "visit_date": "2023-02-08T07:49:23.635490", "added": "2024-11-19T01:09:36.098276+00:00", "created": "2021-01-01T14:03:52", "int_score": 3, "score": 2.828125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0070.json.gz" }
import os, os.path as op import numpy as np import cv2 import logging from glob import glob import shutil import simplejson as json from progressbar import progressbar from pprint import pformat from shuffler.backend import backend_db from shuffler.backend import backend_media from shuffler.utils import general as general_utils def add_parsers(subparsers): importCityscapesParser(subparsers) exportCityscapesParser(subparsers) def _importJson(c, jsonpath, imagefile, imheight, imwidth): ''' Imports one file with polygons of Cityscapes format. ''' with open(jsonpath) as f: image_dict = json.load(f) if image_dict['imgHeight'] != imheight or image_dict['imgWidth'] != imwidth: raise Exception('Image size is inconsistent to json: %dx%d vs %dx%d' % (image_dict['imgHeight'], image_dict['imgWidth'], imheight, imwidth)) objects = image_dict['objects'] for object_ in objects: name = object_['label'] polygon = object_['polygon'] x1 = np.min([point[0] for point in polygon]) y1 = np.min([point[1] for point in polygon]) x2 = np.max([point[0] for point in polygon]) y2 = np.max([point[1] for point in polygon]) width = x2 - x1 height = y2 - y1 c.execute( 'INSERT INTO objects(imagefile,x1,y1,width,height,name) ' 'VALUES (?,?,?,?,?,?)', (imagefile, x1, y1, width, height, name)) objectid = c.lastrowid for point in polygon: s = 'INSERT INTO polygons(objectid,x,y) VALUES (?,?,?)' c.execute(s, (objectid, point[0], point[1])) def importCityscapesParser(subparsers): parser = subparsers.add_parser( 'importCityscapes', description='Import Cityscapes annotations into the database. ' 'Images are assumed to be from leftImg8bit. For the CityScapes format, ' 'please visit https://github.com/mcordts/cityscapesScripts.') parser.set_defaults(func=importCityscapes) parser.add_argument( '--cityscapes_dir', required=True, help='Root directory of Cityscapes. It should contain subdirs ' '"gtFine_trainvaltest", "leftImg8bit_trainvaltest", etc.') parser.add_argument( '--type', default='gtFine', choices=['gtFine', 'gtCoarse'], help='Which annotations to parse. ' 'Will not parse both to keep the logic straightforward.') parser.add_argument( '--splits', nargs='+', default=['train', 'test', 'val'], choices=['train', 'test', 'val', 'train_extra', 'demoVideo'], help='Splits to be parsed.') parser.add_argument('--mask_type', choices=['labelIds', 'instanceIds', 'color'], help='Which mask to import, if any.') parser.add_argument('--display', action='store_true') def importCityscapes(c, args): if args.display: imreader = backend_media.MediaReader(args.rootdir) logging.info('Will load splits: %s', args.splits) logging.info('Will load json type: %s', args.type) logging.info('Will load mask type: %s', args.mask_type) if not op.exists(args.cityscapes_dir): raise Exception('Cityscape directory "%s" does not exist' % args.cityscapes_dir) # Directory accessed by label type and by split. dirs_by_typesplit = {} for type_ in [args.type, 'leftImg8bit']: type_dir_template = op.join(args.cityscapes_dir, '%s*' % type_) for type_dir in [x for x in glob(type_dir_template) if op.isdir(x)]: logging.debug('Looking for splits in %s', type_dir) for split in args.splits: typesplit_dir = op.join(type_dir, split) if op.exists(typesplit_dir): logging.debug('Found split %s in %s', split, type_dir) # Add the info into the main dictionary "dirs_by_typesplit". if split not in dirs_by_typesplit: dirs_by_typesplit[split] = {} dirs_by_typesplit[split][type_] = typesplit_dir logging.info('Found the following directories: \n%s', pformat(dirs_by_typesplit)) for split in args.splits: # List of cities. assert 'leftImg8bit' in dirs_by_typesplit[split] leftImg8bit_dir = dirs_by_typesplit[split]['leftImg8bit'] cities = os.listdir(leftImg8bit_dir) cities = [x for x in cities if op.isdir(op.join(leftImg8bit_dir, x))] logging.info('Found %d cities in %s', len(cities), leftImg8bit_dir) for city in cities: image_names = os.listdir(op.join(leftImg8bit_dir, city)) logging.info('In split "%s", city "%s" has %d images', split, city, len(image_names)) for image_name in image_names: # Get the image path. image_path = op.join(leftImg8bit_dir, city, image_name) name_parts = op.splitext(image_name)[0].split('_') if len(name_parts) != 4: raise Exception( 'Expect to have 4 parts in the name of image "%s"' % image_name) if name_parts[0] != city: raise Exception('The first part of name of image "%s" ' 'is expected to be city "%s".' % (image_name, city)) if name_parts[3] != 'leftImg8bit': raise Exception('The last part of name of image "%s" ' 'is expected to be city "leftImg8bit".' % image_name) imheight, imwidth = backend_media.getPictureSize(image_path) imagefile = op.relpath(image_path, args.rootdir) c.execute( 'INSERT INTO images(imagefile,width,height) VALUES (?,?,?)', (imagefile, imwidth, imheight)) # Get the json label. if args.type in dirs_by_typesplit[split]: city_dir = op.join(dirs_by_typesplit[split][args.type], city) if op.exists(city_dir): json_name = '_'.join(name_parts[:3] + [args.type, 'polygons']) + '.json' json_path = op.join(city_dir, json_name) if op.exists(json_path): _importJson(c, json_path, imagefile, imheight, imwidth) if args.mask_type is not None: mask_name = '_'.join( name_parts[:3] + [args.type, args.mask_type]) + '.png' mask_path = op.join(city_dir, mask_name) if op.exists(mask_path): maskfile = op.relpath(mask_path, args.rootdir) c.execute( 'UPDATE images SET maskfile=? WHERE imagefile=?', (maskfile, imagefile)) if args.display: img = imreader.imread(imagefile) c.execute( 'SELECT objectid,name FROM objects WHERE imagefile=?', (imagefile, )) for objectid, name in c.fetchall(): # Draw polygon. c.execute('SELECT y, x FROM polygons WHERE objectid=?', (objectid, )) polygon = c.fetchall() general_utils.drawScoredPolygon(img, polygon, name) cv2.imshow('importCityscapes', img[:, :, ::-1]) if cv2.waitKey(-1) == 27: args.display = False cv2.destroyWindow('importCityscapes') # Statistics. c.execute('SELECT COUNT(1) FROM images') logging.info('Imported %d images', c.fetchone()[0]) c.execute('SELECT COUNT(1) FROM images WHERE maskfile IS NOT NULL') logging.info('Imported %d masks', c.fetchone()[0]) c.execute('SELECT COUNT(DISTINCT(imagefile)) FROM objects') logging.info('Objects are found in %d images', c.fetchone()[0]) def _makeLabelName(name, city, type_, was_imported_from_cityscapes): ''' If a name is like {X}_{Y}_{Z}, then city_{Y}_type. If a name is like {Y}, then city_{Y}_type. ''' # Drop extension. core = op.splitext(name)[0] # Split into parts, and put them together with correct city and type. if was_imported_from_cityscapes: core_parts = core.split('_') if len(core_parts) >= 3: core = '_'.join(core_parts[1:-1]) out_name = '_'.join([city, core, type_]) logging.debug('Made name "%s" out of input name "%s".', out_name, name) return out_name def _exportLabel(c, out_path_noext, imagefile): ''' Writes objects to json file. Please use https://github.com/mcordts/cityscapesScripts to generate masks. ''' c.execute('SELECT width,height FROM images WHERE imagefile=?', (imagefile, )) imgWidth, imgHeight = c.fetchone() data = {'imgWidth': imgWidth, 'imgHeight': imgHeight, 'objects': []} c.execute('SELECT * FROM objects WHERE imagefile=?', (imagefile, )) for object_ in c.fetchall(): objectid = backend_db.objectField(object_, 'objectid') name = backend_db.objectField(object_, 'name') # Polygon = [[x1, y1], [x2, y2], ...]. # Check if the object has a polygon. c.execute('SELECT x,y FROM polygons WHERE objectid=?', (objectid, )) polygon = c.fetchall() if len(polygon) == 0: # If there is no polygon, make one from bounding box. [y1, x1, y2, x2] = backend_db.objectField(object_, 'roi') polygon = [(x1, y1), (x2, y1), (x2, y2), (x1, y2)] color = (255, ) cv2.rectangle(mask, (x1, y1), (x2, y2), color, -1) data['objects'].append({'label': name, 'polygon': polygon}) json_path = '%s_polygons.json' % out_path_noext with open(json_path, 'w') as f: json.dump(data, f, indent=4) def exportCityscapesParser(subparsers): parser = subparsers.add_parser( 'exportCityscapes', description='Export the database into Cityscapes format. ' 'Export to a single annotations <type>. Furthermore, export to a ' 'single <split> and <city> or infer them from the folder structure. ' 'If an object has no polygons, a rectangular polygon is generated from ' 'its bounding box. To generate masks from polygons, use the official ' 'tool from CityScapes: https://github.com/mcordts/cityscapesScripts') parser.set_defaults(func=exportCityscapes) parser.add_argument('--cityscapes_dir', required=True, help='Root directory of Cityscapes') parser.add_argument( '--image_type', default='leftImg8bit', help='If specified, images will be copied to that folder.' 'If NOT specified, images will not be exported in any way.') parser.add_argument( '--type', default='gtFine', help='Will use this type name. Cityscapes uses "gtFine", "gtCoarse".') parser.add_argument( '--split', help='If specified, will use this split name. ' 'Cityscapes uses "train", "val", "test". If NOT specified, will infer ' 'from the grandparent directory of each imagefile.') parser.add_argument( '--city', help='If specified, only that city will be used. If NOT specified, ' 'will infer from the parent directory of each imagefile.') parser.add_argument( '--was_imported_from_cityscapes', action='store_true', help='"Imagefiles" with underscore are parsed as ' '{city}_{name}_{type}{ext}, ' '{City} and {type} are changed according to the export settings.') def exportCityscapes(c, args): c.execute('SELECT imagefile FROM images') for imagefile, in progressbar(c.fetchall()): # Parse the image name, city, and split. imagename = op.basename(imagefile) city = args.city if args.city is not None else op.basename( op.dirname(imagefile)) split = args.split if args.split is not None else op.basename( op.dirname(op.dirname(imagefile))) logging.debug('Will write imagefile %s to split %s and city %s.', imagefile, split, city) out_name = _makeLabelName(imagename, city, args.type, args.was_imported_from_cityscapes) # Write image. if args.image_type: in_imagepath = op.join(args.rootdir, imagefile) if not op.exists(in_imagepath): raise Exception( 'Problem with the database: image does not exist at %s. ' 'Check that imagefile refers to an image (not a video frame).' % in_imagepath) # TODO: do something if the input is video. out_imagedir = op.join(args.cityscapes_dir, args.image_type, split, city) if not op.exists(out_imagedir): os.makedirs(out_imagedir) out_imagepath = op.join(out_imagedir, '%s.png' % out_name) shutil.copyfile(in_imagepath, out_imagepath) # TODO: do something if the inout is not png. # Write label. out_labeldir = op.join(args.cityscapes_dir, args.type, split, city) if not op.exists(out_labeldir): os.makedirs(out_labeldir) out_path_noext = op.join(out_labeldir, out_name) _exportLabel(c, out_path_noext, imagefile)
e604267143dcb0fdd7ca55185ad8c6be31b0decf
{ "blob_id": "e604267143dcb0fdd7ca55185ad8c6be31b0decf", "branch_name": "refs/heads/master", "committer_date": "2023-06-24T20:20:52", "content_id": "eb77433022c6edcd361173f52368b21835f4eb9d", "detected_licenses": [ "MIT" ], "directory_id": "7a539354d327d8a17db160f231e6b74410c6f433", "extension": "py", "filename": "cityscapes.py", "fork_events_count": 2, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 137785127, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 14081, "license": "MIT", "license_type": "permissive", "path": "/shuffler/operations/datasets/cityscapes.py", "provenance": "stack-edu-0063.json.gz:299796", "repo_name": "kukuruza/shuffler", "revision_date": "2023-06-24T20:20:52", "revision_id": "af6ab60f299ef339408bd22151cf270a2da33997", "snapshot_id": "431d44f0ac28092fa510083fea8c936c7c47f648", "src_encoding": "UTF-8", "star_events_count": 24, "url": "https://raw.githubusercontent.com/kukuruza/shuffler/af6ab60f299ef339408bd22151cf270a2da33997/shuffler/operations/datasets/cityscapes.py", "visit_date": "2023-07-17T15:06:43.199004", "added": "2024-11-18T21:10:50.501970+00:00", "created": "2023-06-24T20:20:52", "int_score": 2, "score": 2.328125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0081.json.gz" }
<?php /** * Storage class for MySQL type. */ class Storage { var $db_link = 0; /** * Check content file to see if it exists, then save data. * @param string $name Content area name. * @param string $data Content area data. */ function ContentSave($name, $data) { $this->ContentCheck($name, "Edit Me!"); // Make sure database entry exists. $this->db_link = @mysqli_connect(NC_DB_HOST, NC_DB_USER, NC_DB_PASSWORD); $this->db_link = $this->DatabaseLink($this->db_link, NC_DB_DATABASE); $db_result = mysqli_query($this->db_link, "UPDATE ".NC_DB_PREFIX."content SET content='".$this->EscapeString($this->db_link, $data)."' WHERE name='".$name."'"); if(!$db_result) // Check for query errors. { NCUtility::Error("MySQL reported: ".mysqli_error($this->db_link)); exit(); } mysqli_close($this->db_link); // Close connection. } /** * Check content file to see if it exists, if not, create it. Open it and return data. * @param string $name Content area name. * @return $data Data found in storage. */ function ContentLoad($name) { $this->ContentCheck($name, "Edit Me! (".$name.")"); // Make sure database entry exists. $this->db_link = mysqli_connect(NC_DB_HOST, NC_DB_USER, NC_DB_PASSWORD); $this->db_link = $this->DatabaseLink($this->db_link, NC_DB_DATABASE); $db_result = mysqli_query($this->db_link, "SELECT name,content FROM ".NC_DB_PREFIX."content WHERE name='".$name."'"); if(!$db_result) // Check for query errors. { NCUtility::Error("MySQL reported: ".mysqli_error($this->db_link)); exit(); } $row = mysqli_fetch_row($db_result); $data = $row[1]; mysqli_close($this->db_link); // Close connection. return $data; } /** * USED INTERNALLY. Check content file to see if it exists. And if it doesn't, create it. $path contains the file path, $default contains the default text to go in the file if it is new. * @param string $name Content area name. */ function ContentCheck($name, $default) { $create_entry = false; $this->db_link = mysqli_connect(NC_DB_HOST, NC_DB_USER, NC_DB_PASSWORD); $this->db_link = $this->DatabaseLink($this->db_link, NC_DB_DATABASE); $db_result = mysqli_query($this->db_link, "SELECT name FROM ".NC_DB_PREFIX."content WHERE name='".$name."'"); if(!$db_result) // Check for query errors. { NCUtility::Error("MySQL reported: ".mysqli_error($this->db_link)); exit(); } // See if a row exsists if(mysqli_num_rows($db_result) < 1) $create_entry = true; mysqli_close($this->db_link); // Close connection. if ($create_entry) // No entries existed. Create one instead. { $this->db_link = mysqli_connect(NC_DB_HOST, NC_DB_USER, NC_DB_PASSWORD); $this->db_link = $this->DatabaseLink($this->db_link, NC_DB_DATABASE); $db_result = mysqli_query($this->db_link, "INSERT INTO ".NC_DB_PREFIX."content (name,content) VALUES ('".$name."','".$default."')"); if(!$db_result) // Check for query errors. { NCUtility::Error("MySQL reported: ".mysqli_error($this->db_link)); exit(); } mysqli_close($this->db_link); // Close connection. } } /** * USED INTERNALLY. Checks the validity of the mysql link. Selects the database. Returns the db link, presents any errors if any are found. * @param string $name Content area name. */ function DatabaseLink($link, $_database) { if ($link) { if (mysqli_select_db($link, $_database)) return $link; else { NCUtility::Error("MySQL reported: ".mysqli_error($link)); exit(); } } else { NCUtility::Error("MySQL reported: ".mysqli_error($link)); exit(); } } /** * USED INTERNALLY. Escapes the string passed to it for secuirty. * @param string $name Content area name. */ function EscapeString($link, $string) { if(get_magic_quotes_gpc()) $string = stripslashes($string); // Remove PHP magic quotes because we don't want to double-escape. return mysqli_real_escape_string($link, $string); } }
5fa7d1b185a661daf91241daa5128f262d3c5cc2
{ "blob_id": "5fa7d1b185a661daf91241daa5128f262d3c5cc2", "branch_name": "refs/heads/master", "committer_date": "2023-02-12T11:51:25", "content_id": "cd10f4a3e55220ec33723c5c944272219fe0234e", "detected_licenses": [ "Zlib" ], "directory_id": "0a9f74cca56902a398d32a35dbdb1b48d56d52ab", "extension": "php", "filename": "MySQL.php", "fork_events_count": 0, "gha_created_at": "2020-02-16T18:17:23", "gha_event_created_at": "2020-02-22T10:47:32", "gha_language": "PHP", "gha_license_id": null, "github_id": 240941479, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 3971, "license": "Zlib", "license_type": "permissive", "path": "/nc-cms/system/lib/storage/MySQL.php", "provenance": "stack-edu-0048.json.gz:573348", "repo_name": "tirun/nc-cms", "revision_date": "2023-02-12T11:51:25", "revision_id": "09ad823dfe5ad101ed8e56063e32933b053ea6aa", "snapshot_id": "27439c333605f95f6aa3a216052d1f910837f188", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/tirun/nc-cms/09ad823dfe5ad101ed8e56063e32933b053ea6aa/nc-cms/system/lib/storage/MySQL.php", "visit_date": "2023-02-16T15:47:41.022936", "added": "2024-11-18T21:01:15.901466+00:00", "created": "2023-02-12T11:51:25", "int_score": 3, "score": 3.234375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0066.json.gz" }
package ch.uzh.ifi.seal.soprafs20.repository; import ch.uzh.ifi.seal.soprafs20.constant.GameStatus; import ch.uzh.ifi.seal.soprafs20.entity.Game; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import static org.junit.jupiter.api.Assertions.*; @DataJpaTest public class GameRepositoryIntegrationTest { @Qualifier("gameRepository") @Autowired private GameRepository gameRepository; @Test public void findByGameId_success() { // given Game game = new Game(); game.setGameId(1L); game.setGameStatus(GameStatus.WAITING); game.setIsWhiteTurn(true); // save game in database gameRepository.save(game); gameRepository.flush(); // when Game found = gameRepository.findByGameId(game.getGameId()); // then assertNotNull(found.getGameId()); assertEquals(game.getGameStatus(), GameStatus.WAITING); assertTrue(game.getIsWhiteTurn()); } }
05689ca6b7f436ae4d267182503b59cbaf9d798f
{ "blob_id": "05689ca6b7f436ae4d267182503b59cbaf9d798f", "branch_name": "refs/heads/master", "committer_date": "2020-05-24T19:56:46", "content_id": "9baa568b81f0de7a45f800f3e14537b3015b9e33", "detected_licenses": [ "Apache-2.0" ], "directory_id": "b3a15759f1538975c4c52e7a8bede9af078a4dfc", "extension": "java", "filename": "GameRepositoryIntegrationTest.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 248264368, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 1154, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/test/java/ch/uzh/ifi/seal/soprafs20/repository/GameRepositoryIntegrationTest.java", "provenance": "stack-edu-0021.json.gz:9936", "repo_name": "sopra-fs20-group02/sopra-fs20-group02-server", "revision_date": "2020-05-24T19:56:46", "revision_id": "cfa011ec626f4daa0e8c71078e5be8c79c4be521", "snapshot_id": "ef084cfda78643ca32789cb4b1c1bf60cbd8f22e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/sopra-fs20-group02/sopra-fs20-group02-server/cfa011ec626f4daa0e8c71078e5be8c79c4be521/src/test/java/ch/uzh/ifi/seal/soprafs20/repository/GameRepositoryIntegrationTest.java", "visit_date": "2021-04-02T10:35:25.706499", "added": "2024-11-18T22:42:16.637525+00:00", "created": "2020-05-24T19:56:46", "int_score": 2, "score": 2.328125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0039.json.gz" }
using System; using System.Threading.Tasks; using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using Knowledgebase.Models; using Knowledgebase.Models.Thread; namespace Knowledgebase.Api.Controllers { [ApiController] [Route("api/[controller]")] public class ThreadsController : ControllerBase { private readonly Application.Services.ThreadService _threadService; public ThreadsController( Application.Services.ThreadService threadService) { _threadService = threadService; } [HttpGet] public IActionResult GetThreads(Guid? category_id, Guid? tag_id, string keyword) { var data = _threadService.GetAll(new ThreadSearch { TagId = tag_id, CategoryId = category_id, Keyword = keyword }); return Ok(data); } [HttpGet("{id}")] public IActionResult GetSingleThread(Guid id) { var data = _threadService.GetDetails(id); return Ok(data); } [HttpPost] [Filters.Transactional] public IActionResult CreateThread([FromBody] ThreadCreate input) { var result = _threadService.Create(input); return Ok(result); } [HttpPut] [Filters.Transactional] public IActionResult UpdateThread([FromBody] ThreadUpdate input) { _threadService.UpdateThread(input); return Ok(); } [HttpPut("title")] [Filters.Transactional] public IActionResult UpdateThreadTitle([FromBody] ThreadUpdateTitle input) { _threadService.UpdateThreadTitle(input); return Ok(); } [HttpPut("tags")] [Filters.Transactional] public IActionResult UpdateThreadTags([FromBody] ThreadUpdateTags input) { _threadService.UpdateThreadTags(input); return Ok(); } [HttpPut("contents")] [Filters.Transactional] public IActionResult UpdateThreadContents([FromBody] ThreadUpdateContents input) { var result = _threadService.UpdateThreadContents(input); return Ok(result); } [HttpDelete("{id}")] [Filters.Transactional] public IActionResult DeleteThread(Guid id) { _threadService.DeleteThread(id); return Ok(); } [HttpGet("{thread_id}/contents")] public IActionResult GetContentsOfThread(Guid thread_id) { var data = _threadService.GetAllContents(thread_id); return Ok(data); } [HttpGet("contents/{content_id}")] public IActionResult GetContentDetails(Guid content_id) { var data = _threadService.GetContent(content_id); return Ok(data); } [HttpGet("tags")] public IActionResult GetAllTags() { var result = _threadService.GetAllTags(); return Ok(result); } } }
3d04d7b1f3a8ef7e762ba8d821e41b8a25e53e3a
{ "blob_id": "3d04d7b1f3a8ef7e762ba8d821e41b8a25e53e3a", "branch_name": "refs/heads/master", "committer_date": "2020-08-06T17:30:35", "content_id": "182867056e9fbc55020a49af2fea660336461f3e", "detected_licenses": [ "MIT" ], "directory_id": "e24e85b1ecf82028116a8f072c2ef8467922110d", "extension": "cs", "filename": "ThreadsController.cs", "fork_events_count": 0, "gha_created_at": "2020-07-19T08:32:45", "gha_event_created_at": "2020-08-03T13:20:34", "gha_language": null, "gha_license_id": "MIT", "github_id": 280824492, "is_generated": false, "is_vendor": false, "language": "C#", "length_bytes": 3132, "license": "MIT", "license_type": "permissive", "path": "/src/Knowledgebase.Api/Controllers/ThreadsController.cs", "provenance": "stack-edu-0011.json.gz:171065", "repo_name": "deploca/knowledgebase", "revision_date": "2020-08-06T17:30:35", "revision_id": "990f192026d44bee7147d0076e6cee2eef406b0b", "snapshot_id": "8c17b7d1baf0eb69711fdbe742839e09d4cf359e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/deploca/knowledgebase/990f192026d44bee7147d0076e6cee2eef406b0b/src/Knowledgebase.Api/Controllers/ThreadsController.cs", "visit_date": "2022-11-26T05:57:05.185084", "added": "2024-11-19T02:14:20.163708+00:00", "created": "2020-08-06T17:30:35", "int_score": 2, "score": 2.40625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0029.json.gz" }
/* eslint-disable no-param-reassign */ import * as t from '../constants/MutationTypes'; const mutations = { [t.CHANGE_GRADE](state, payload) { state.grades.splice(payload.index, 1, payload.grade); }, [t.CHANGE_DESIRED_GRADE](state, payload) { state.desiredGrade = payload.grade; }, [t.CHANGE_WEIGHT](state, payload) { state.weights.splice(payload.index, 1, payload.weight); }, }; export default mutations;
fa6d9fa4913b4314ff630fdcc47274df3ce66568
{ "blob_id": "fa6d9fa4913b4314ff630fdcc47274df3ce66568", "branch_name": "refs/heads/master", "committer_date": "2017-01-01T18:39:23", "content_id": "59fa0e9e0dd9a74a78d043263eb5771d76e3bfd6", "detected_licenses": [ "MIT" ], "directory_id": "86f4d2456deb2470e4885f6ea7aeaf1b8c627e85", "extension": "js", "filename": "mutations.js", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 77647424, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 432, "license": "MIT", "license_type": "permissive", "path": "/src/store/mutations.js", "provenance": "stack-edu-0033.json.gz:591956", "repo_name": "nathanhleung/vue-gradecalculator", "revision_date": "2017-01-01T18:39:23", "revision_id": "493f507031201179f2148b6f336ff9e030fc96ac", "snapshot_id": "de24bcf9724785dbe397c7c931d2f64c921caa96", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/nathanhleung/vue-gradecalculator/493f507031201179f2148b6f336ff9e030fc96ac/src/store/mutations.js", "visit_date": "2021-01-13T03:11:27.208311", "added": "2024-11-19T00:07:39.124508+00:00", "created": "2017-01-01T18:39:23", "int_score": 2, "score": 2.1875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0051.json.gz" }
// // Tools.swift // ClogAmpSwift // // Created by Roessel, Pascal on 13.02.19. // Copyright © 2019 Pascal Roessel. All rights reserved. // import Foundation public func delayWithSeconds(_ seconds: Double, closure: @escaping () -> ()) { DispatchQueue.main.asyncAfter(deadline: .now() + seconds, qos: .userInitiated) { closure() } }
5f09ee2c20085316fe1e4d5c73fd9db6274cacd2
{ "blob_id": "5f09ee2c20085316fe1e4d5c73fd9db6274cacd2", "branch_name": "refs/heads/master", "committer_date": "2023-07-19T13:27:26", "content_id": "f761a2ba5454a3434d0ce39d6df5557183302fbf", "detected_licenses": [ "MIT" ], "directory_id": "c41b60a6c87f4f4ab214a4def82b89a26f3018c7", "extension": "swift", "filename": "Tools.swift", "fork_events_count": 1, "gha_created_at": "2018-04-13T06:31:44", "gha_event_created_at": "2019-11-19T13:53:41", "gha_language": "Swift", "gha_license_id": "MIT", "github_id": 129358851, "is_generated": false, "is_vendor": false, "language": "Swift", "length_bytes": 355, "license": "MIT", "license_type": "permissive", "path": "/ClogAmpSwift/Utils/Tools.swift", "provenance": "stack-edu-0072.json.gz:138261", "repo_name": "lunk22/ClogAmpSwift", "revision_date": "2023-07-19T12:49:31", "revision_id": "2ce4e36c40df055e198e6b0160767719485243b0", "snapshot_id": "8311574b530876fd1249a5e19364b4fd682046cf", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/lunk22/ClogAmpSwift/2ce4e36c40df055e198e6b0160767719485243b0/ClogAmpSwift/Utils/Tools.swift", "visit_date": "2023-07-21T11:10:58.366446", "added": "2024-11-19T02:38:07.581051+00:00", "created": "2023-07-19T12:49:31", "int_score": 2, "score": 2.5, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0090.json.gz" }
<?php namespace App\Vehicle\Domain; interface VehicleInterface { public function getId(): string; public function getManufacturer(): string; public function getModel(): string; }
100573bb87258541417f518ef60013428340cc2f
{ "blob_id": "100573bb87258541417f518ef60013428340cc2f", "branch_name": "refs/heads/master", "committer_date": "2023-02-23T20:28:06", "content_id": "5a05b9fca413c42d06663453f85d1b2f7021956a", "detected_licenses": [ "MIT" ], "directory_id": "65f55851117f72227f00ac86fec6709af00cd254", "extension": "php", "filename": "VehicleInterface.php", "fork_events_count": 5, "gha_created_at": "2018-05-10T12:58:16", "gha_event_created_at": "2023-04-19T21:25:10", "gha_language": "PHP", "gha_license_id": "MIT", "github_id": 132900635, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 195, "license": "MIT", "license_type": "permissive", "path": "/src/Vehicle/Domain/VehicleInterface.php", "provenance": "stack-edu-0048.json.gz:90146", "repo_name": "Samffy/graphql-poc", "revision_date": "2023-02-23T20:28:06", "revision_id": "d62cd064badac64d529acf715dcb500edf9691f9", "snapshot_id": "9cbffb3a86cb69397d2e4189a49767fd9b148283", "src_encoding": "UTF-8", "star_events_count": 22, "url": "https://raw.githubusercontent.com/Samffy/graphql-poc/d62cd064badac64d529acf715dcb500edf9691f9/src/Vehicle/Domain/VehicleInterface.php", "visit_date": "2023-05-04T00:32:12.970024", "added": "2024-11-18T21:53:47.626576+00:00", "created": "2023-02-23T20:28:06", "int_score": 3, "score": 2.828125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0066.json.gz" }
<?php declare(strict_types=1); namespace EonX\EasyDoctrine\Events; interface EntityActionEventInterface { /** * @return array<string, mixed> */ public function getChangeSet(): array; public function getEntity(): object; }
f9dda65fca45c2dca98175205f83d8084b848145
{ "blob_id": "f9dda65fca45c2dca98175205f83d8084b848145", "branch_name": "refs/heads/master", "committer_date": "2022-10-27T23:58:22", "content_id": "bff6bb68b291a889647b4528086b0130685aec02", "detected_licenses": [ "MIT" ], "directory_id": "ea39c7b4f0c8db5d34787b781c4242db07abdf4c", "extension": "php", "filename": "EntityActionEventInterface.php", "fork_events_count": 0, "gha_created_at": "2020-03-04T01:46:51", "gha_event_created_at": "2020-03-04T01:46:52", "gha_language": null, "gha_license_id": "MIT", "github_id": 244782947, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 248, "license": "MIT", "license_type": "permissive", "path": "/packages/EasyDoctrine/src/Events/EntityActionEventInterface.php", "provenance": "stack-edu-0047.json.gz:201774", "repo_name": "dextercampos/easy-monorepo", "revision_date": "2022-10-27T23:58:22", "revision_id": "bbd61b5a4123a27335cd6550b84efe79160bcbeb", "snapshot_id": "df5ed27a75edb478cf499e12e93852d46c6381e3", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/dextercampos/easy-monorepo/bbd61b5a4123a27335cd6550b84efe79160bcbeb/packages/EasyDoctrine/src/Events/EntityActionEventInterface.php", "visit_date": "2022-11-13T15:33:54.799219", "added": "2024-11-18T20:57:08.289524+00:00", "created": "2022-10-27T23:58:22", "int_score": 2, "score": 2.25, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0065.json.gz" }
import numpy as np from typing import List, Optional, Dict, Tuple from camera.image_recognition import Point, PolarPoint try: dataclass # python 3.7.1 except: from dataclasses import dataclass class StreamingMovingAverage: def __init__(self, window_size): self.window_size = window_size self.values = [] self.sum = 0 def __call__(self, value): if np.isnan(value): return value self.values.append(value) self.sum += value if len(self.values) > self.window_size: self.sum -= self.values.pop(0) return float(self.sum) / len(self.values) Centimeter = float @dataclass class RecognitionState: """Class for keeping track of the recognition state.""" balls: List[PolarPoint] = list goal_yellow: Optional[PolarPoint] = None goal_blue: Optional[PolarPoint] = None closest_edge: Optional[PolarPoint] = None angle_adjust: float = None h_bigger: int = None h_smaller: int = None field_contours: List[Tuple[int, int, int, int]] = None goal_yellow_rect: List[Tuple[int, int, int, int]] = None goal_blue_rect: List[Tuple[int, int, int, int]] = None @staticmethod # for some reason type analysis didn't work for classmethod def from_dict(packet: dict) -> 'RecognitionState': balls: List[PolarPoint] = [PolarPoint(**b) for b in packet.get('balls', [])] goal_yellow: Optional[PolarPoint] = packet.get('goal_yellow') and PolarPoint(**packet['goal_yellow']) goal_blue: Optional[PolarPoint] = packet.get('goal_blue') and PolarPoint(**packet['goal_blue']) closest_edge: Optional[PolarPoint] = packet.get('closest_edge') and PolarPoint(**packet['closest_edge']) angle_adjust, h_bigger, h_smaller = packet.get('goal_angle_adjust', [None, None, None]) field_contours = packet.get('field_contours', []) goal_yellow_rect = packet.get('goal_yellow_rect', []) goal_blue_rect = packet.get('goal_blue_rect', []) return RecognitionState( balls, goal_yellow, goal_blue, closest_edge, angle_adjust, h_bigger, h_smaller, field_contours, goal_yellow_rect, goal_blue_rect)
46e99476198c8a82b5d05d470577f3fa43efe94b
{ "blob_id": "46e99476198c8a82b5d05d470577f3fa43efe94b", "branch_name": "refs/heads/master", "committer_date": "2019-12-01T02:32:09", "content_id": "e0d1ef0e794d8aed1da2cbe7d07502d9a99af8c6", "detected_licenses": [ "MIT" ], "directory_id": "a195ccf86fc3cf401c5993071d28588a01f959ab", "extension": "py", "filename": "utils.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2201, "license": "MIT", "license_type": "permissive", "path": "/khajiit/utils.py", "provenance": "stack-edu-0060.json.gz:269747", "repo_name": "vegetablejuiceftw/zoidberg", "revision_date": "2019-12-01T02:32:09", "revision_id": "46eaef75db7caac95a6c0089f04c720fd1936e5b", "snapshot_id": "4a1a3f9842ece51a2c7d785254c45c346dbdde5c", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/vegetablejuiceftw/zoidberg/46eaef75db7caac95a6c0089f04c720fd1936e5b/khajiit/utils.py", "visit_date": "2021-01-08T01:08:35.772584", "added": "2024-11-19T00:36:47.302657+00:00", "created": "2019-12-01T02:32:09", "int_score": 3, "score": 2.640625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0078.json.gz" }
$(document) .ready(function() { var height = $(window) .height() - 57; $(".selected") .css("color", "white"); $(".codecontainer") .css("height", height + "px"); $(".selector") .click(function() { $(this) .toggleClass("selected"); var id = $(this) .attr("name"); var clase = $(this) .attr("class"); if (clase == "selector selected") { $(this) .css("color", "white"); } else { $(this) .css("color", "transparent"); } if (id == "html" && clase == "selector selected") { $(this) .css("background-color", "#E44D26"); } else if (id == "css" && clase == "selector selected") { $(this) .css("background-color", "#379AD6"); } else if (id == "js" && clase == "selector selected") { $(this) .css("background-color", "#F0DB4F"); } else if (id == "result" && clase == "selector selected") { $(this) .css("background-color", "green"); } else { $(this) .css("background-color", "grey"); } $("#" + id + "Container") .toggle(); var number = $('.codecontainer') .filter(function() { return $(this) .css('display') !== 'none'; }) .length; var width = 100 / number; $(".codecontainer") .css("width", width + "%"); //show codemirror windows already at line #1. htmlCodeMirror.refresh(); cssCodeMirror.refresh(); jsCodeMirror.refresh(); }); //Setup codemirror editors $("#run") .click(function() { $('#resultFrame') .contents() .find('html') .html("<style>" + cssCodeMirror.getValue() + "</style>" + htmlCodeMirror.getValue()); document.getElementById('resultFrame') .contentWindow.eval(jsCodeMirror.getValue()); }); $("#htmlClear").click(function() { htmlCodeMirror.setValue(""); }); $("#cssClear").click(function() { cssCodeMirror.setValue(""); }); $("#jsClear").click(function() { jsCodeMirror.setValue(""); }); //Asks user if he really wants to leave when refreshing or backspacing window.onbeforeunload = function() { return ""; }; });
86f99abacfa06a51b9362a08bbbbf83a8f8ebd37
{ "blob_id": "86f99abacfa06a51b9362a08bbbbf83a8f8ebd37", "branch_name": "refs/heads/master", "committer_date": "2017-05-14T07:27:09", "content_id": "dcf72858c03fdee735d3a4b419adc0785375aabf", "detected_licenses": [ "MIT" ], "directory_id": "5a04737bdd91f128ec1a92652c6e5609bebc346d", "extension": "js", "filename": "script.js", "fork_events_count": 1, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 90172398, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 2142, "license": "MIT", "license_type": "permissive", "path": "/javascript/script.js", "provenance": "stack-edu-0033.json.gz:570290", "repo_name": "OscarAD/CodeFiddle", "revision_date": "2017-05-14T07:27:09", "revision_id": "3262dddf8623051bf4fb3a2906158347aab97da2", "snapshot_id": "f3104af7ba21f9e0d922dabf1db25a4a152974a1", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/OscarAD/CodeFiddle/3262dddf8623051bf4fb3a2906158347aab97da2/javascript/script.js", "visit_date": "2021-01-20T08:38:13.187654", "added": "2024-11-19T01:41:54.777590+00:00", "created": "2017-05-14T07:27:09", "int_score": 2, "score": 2.375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0051.json.gz" }
import React, { Component } from 'react'; import { Text, StyleSheet, View } from 'react-native'; import { colors } from '../utils'; const styles = StyleSheet.create({ container: { borderRadius: 8, backgroundColor: colors.WHITE, paddingVertical: 5, paddingHorizontal: 10, marginTop: 5, marginRight: 5, elevation: 3, shadowColor: colors.SHADOW, shadowOffset: { width: 2, height: 2 }, shadowOpacity: 0.8, shadowRadius: 2, }, title: { fontWeight: 'bold', }, text: { fontSize: 15, textAlign: 'right', }, }); class AssetInfoBox extends Component { render() { return ( <View style={styles.container}> <Text style={styles.title}>{this.props.title}</Text> <Text style={styles.text}> {this.props.text} {this.props.children} </Text> </View> ); } } export default AssetInfoBox;
968fbe9c5bbe9b81a9d6f297ecd6ba13187f5249
{ "blob_id": "968fbe9c5bbe9b81a9d6f297ecd6ba13187f5249", "branch_name": "refs/heads/master", "committer_date": "2019-06-17T23:41:32", "content_id": "a3fa7d79c0d19d4e31a36c9f56850884720509d2", "detected_licenses": [ "MIT" ], "directory_id": "9d9dce4fe3b905d8e6bd1f3c7229725179658f70", "extension": "js", "filename": "AssetInfoBox.js", "fork_events_count": 1, "gha_created_at": "2019-08-07T09:00:32", "gha_event_created_at": "2019-08-07T09:00:32", "gha_language": null, "gha_license_id": "MIT", "github_id": 201012952, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 905, "license": "MIT", "license_type": "permissive", "path": "/src/components/AssetInfoBox.js", "provenance": "stack-edu-0045.json.gz:208632", "repo_name": "wepobid/personal-cryptofolio", "revision_date": "2019-06-17T23:41:32", "revision_id": "6733236e2031d76eb50febb0fcd15ddc7fafd1e3", "snapshot_id": "ffeafe3ce0cd94539e5f39f15db1529cdab4fb69", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/wepobid/personal-cryptofolio/6733236e2031d76eb50febb0fcd15ddc7fafd1e3/src/components/AssetInfoBox.js", "visit_date": "2020-07-01T01:53:41.309881", "added": "2024-11-19T00:11:55.783713+00:00", "created": "2019-06-17T23:41:32", "int_score": 2, "score": 2.234375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0063.json.gz" }
import { calculateVectorArea } from './calculateVectorArea'; import { createVector } from './createVector'; describe('calculateVectorArea', () => { it('the area of 2,3 should be 6', () => { expect(calculateVectorArea(createVector(2, 3))).toBe(6); }); });
86fc581aee6e6a16b6223f194fb038adb4f139fb
{ "blob_id": "86fc581aee6e6a16b6223f194fb038adb4f139fb", "branch_name": "refs/heads/master", "committer_date": "2020-04-05T01:14:56", "content_id": "d53214cf63a861bd8cd610c69edd46b906c09d79", "detected_licenses": [ "MIT" ], "directory_id": "0a648f8f5a6e1950e304d969f9df2374c1505af8", "extension": "ts", "filename": "calculateVectorArea.test.ts", "fork_events_count": 0, "gha_created_at": "2019-06-27T22:18:31", "gha_event_created_at": "2023-01-04T01:17:49", "gha_language": "TypeScript", "gha_license_id": "MIT", "github_id": 194170093, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 264, "license": "MIT", "license_type": "permissive", "path": "/src/vector/calculateVectorArea.test.ts", "provenance": "stack-edu-0073.json.gz:979356", "repo_name": "jedster1111/simple-vectors", "revision_date": "2020-04-05T00:06:48", "revision_id": "b166cf17f02375f51806fa256ab3a17cf3fc84a3", "snapshot_id": "fcc138ff2e410023c6ba0b261e385e9737d5ae68", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/jedster1111/simple-vectors/b166cf17f02375f51806fa256ab3a17cf3fc84a3/src/vector/calculateVectorArea.test.ts", "visit_date": "2023-01-08T07:27:55.585037", "added": "2024-11-18T23:40:01.820121+00:00", "created": "2020-04-05T00:06:48", "int_score": 2, "score": 2.125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0091.json.gz" }
package com.herb2sy.lib.exception; public class EncryptionException extends Exception { public EncryptionException() { } public EncryptionException(String message) { super(message); } }
9622afcddb53bbf84de075aaadd41dab6f55ecaa
{ "blob_id": "9622afcddb53bbf84de075aaadd41dab6f55ecaa", "branch_name": "refs/heads/master", "committer_date": "2019-08-03T13:41:31", "content_id": "7505cf0158bdeb2d665d2c0ae9b102c867a3dc56", "detected_licenses": [ "Apache-2.0" ], "directory_id": "76c9b202168242712c4e412e17217e69dfe7482c", "extension": "java", "filename": "EncryptionException.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 192110217, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 212, "license": "Apache-2.0", "license_type": "permissive", "path": "/lib/src/main/java/com/herb2sy/lib/exception/EncryptionException.java", "provenance": "stack-edu-0020.json.gz:353355", "repo_name": "HerbLee/kotlin_android", "revision_date": "2019-08-03T13:41:31", "revision_id": "fb64658ddce19219236e2177e9d6da46fe6d65a3", "snapshot_id": "7b8ce852b27561b0b6103b202c63586d1d8971b2", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/HerbLee/kotlin_android/fb64658ddce19219236e2177e9d6da46fe6d65a3/lib/src/main/java/com/herb2sy/lib/exception/EncryptionException.java", "visit_date": "2020-06-04T17:06:13.328247", "added": "2024-11-18T22:43:43.019136+00:00", "created": "2019-08-03T13:41:31", "int_score": 2, "score": 2.0625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0038.json.gz" }
# Futu Algo: Algorithmic High-Frequency Trading Framework # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Written by Bill Chan <billpwchan@hotmail.com>, 2021 # Copyright (c) billpwchan - All Rights Reserved import pandas as pd from filters.Filters import Filters class TripleCross(Filters): def __init__(self, ma_period1: int = 5, ma_period2: int = 10, ma_period3: int = 20): self.MA_PERIOD1 = ma_period1 self.MA_PERIOD2 = ma_period2 self.MA_PERIOD3 = ma_period3 super().__init__() def validate(self, input_data: pd.DataFrame, info_data: dict) -> bool: """ :param input_data: Yahoo Finance Quantitative Data (Price, Volume, etc.) :param info_data: Yahoo Finance Fundamental Data (Company Description. PE Ratio, Etc.) :return: """ if input_data.empty or input_data.shape[0] < 20: return False input_data['MA_1'] = input_data['close'].rolling(window=self.MA_PERIOD1).mean() input_data['MA_2'] = input_data['close'].rolling(window=self.MA_PERIOD2).mean() input_data['MA_3'] = input_data['close'].rolling(window=self.MA_PERIOD3).mean() current_record = input_data.iloc[-1] previous_record = input_data.iloc[-2] criterion_1 = current_record['volume'] > input_data.iloc[-10:]['volume'].max() criterion_2 = max([current_record['MA_1'], current_record['MA_2'], current_record['MA_3']]) / \ min([current_record['MA_1'], current_record['MA_2'], current_record['MA_3']]) < 1.01 criterion_3 = current_record['close'] > current_record['MA_1'] and \ current_record['close'] > current_record['MA_2'] and \ current_record['close'] > current_record['MA_3'] criterion_4 = previous_record['close'] < previous_record['MA_1'] and \ previous_record['close'] < previous_record['MA_2'] and \ previous_record['close'] < previous_record['MA_3'] criteria = [criterion_1, criterion_2, criterion_3, criterion_4] return all(criterion for criterion in criteria)
28b2e5e7e6e50bd96a34c310f3013723968d43c1
{ "blob_id": "28b2e5e7e6e50bd96a34c310f3013723968d43c1", "branch_name": "refs/heads/master", "committer_date": "2021-10-21T18:34:22", "content_id": "8903f82ab198b62e4bf920122d13aa1dddda59bb", "detected_licenses": [ "Apache-2.0" ], "directory_id": "9d5e3599b633a79f32725c453677ef367ca8dbff", "extension": "py", "filename": "Triple_Cross.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2655, "license": "Apache-2.0", "license_type": "permissive", "path": "/filters/Triple_Cross.py", "provenance": "stack-edu-0060.json.gz:78659", "repo_name": "eaglepix/futu_algo", "revision_date": "2021-10-21T18:34:22", "revision_id": "bc4a8b9e56cff8ac1add9a2cd309ee568ca9b2dc", "snapshot_id": "bb8cac22d07626e5029df3aa623fb58da67f4ac0", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/eaglepix/futu_algo/bc4a8b9e56cff8ac1add9a2cd309ee568ca9b2dc/filters/Triple_Cross.py", "visit_date": "2023-08-31T06:33:05.534841", "added": "2024-11-18T21:52:09.023927+00:00", "created": "2021-10-21T18:34:22", "int_score": 3, "score": 2.703125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0078.json.gz" }
/* * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.wso2.carbon.identity.sts.passive.custom.handler; import org.apache.cxf.rt.security.claims.Claim; import org.apache.cxf.rt.security.claims.ClaimCollection; import org.apache.cxf.sts.claims.ClaimsHandler; import org.apache.cxf.sts.claims.ClaimsParameters; import org.apache.cxf.sts.claims.ProcessedClaim; import org.apache.cxf.sts.claims.ProcessedClaimCollection; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * A custom ClaimsHandler implementation to be used in the implementation. */ public class CustomClaimsHandler implements ClaimsHandler { private static List<String> knownURIs = new ArrayList<>(); private HashMap<String, String> requestedClaims = new HashMap<>(); /** * Create a processed claim collection using the claim values and params provided. * * @param claims The unprocessed claims. * @param parameters The claim parameters. * @return The processed claims. */ public ProcessedClaimCollection retrieveClaimValues( ClaimCollection claims, ClaimsParameters parameters) { if (claims != null && !claims.isEmpty()) { ProcessedClaimCollection claimCollection = new ProcessedClaimCollection(); for (Claim requestClaim : claims) { ProcessedClaim claim = new ProcessedClaim(); claim.setClaimType(requestClaim.getClaimType()); if (knownURIs.contains(requestClaim.getClaimType()) && requestedClaims.containsKey(requestClaim.getClaimType())) { claim.addValue(requestedClaims.get(requestClaim.getClaimType())); } claimCollection.add(claim); } return claimCollection; } return null; } /** * Get the list of supported claim URIs. * * @return List of supported claim URIs. */ public List<String> getSupportedClaimTypes() { return knownURIs; } /** * Set the list of supported claim URIs. * * @param knownURIs New list to be set as the known URIs. */ public static void setKnownURIs(List<String> knownURIs) { CustomClaimsHandler.knownURIs = knownURIs; } /** * Get claim URIs and values in the form of a HashMap. * * @return HashMap containing the claim URIs and values. */ public HashMap<String, String> getRequestedClaims() { return requestedClaims; } /** * Set claim key value pair(the URI and value). * * @param requestedClaims The new HashMap of claims key value pair. */ public void setRequestedClaims(HashMap<String, String> requestedClaims) { this.requestedClaims = requestedClaims; } }
686e44ae7d05d42682fa306de6ebc2dbd2928211
{ "blob_id": "686e44ae7d05d42682fa306de6ebc2dbd2928211", "branch_name": "refs/heads/master", "committer_date": "2023-08-22T06:29:06", "content_id": "86336ae88ea94806345d971e2eb80a0b84ef9cbc", "detected_licenses": [ "Apache-2.0" ], "directory_id": "fa604017fb71006cd00863fd05f8008fd01e9149", "extension": "java", "filename": "CustomClaimsHandler.java", "fork_events_count": 78, "gha_created_at": "2016-02-29T02:51:28", "gha_event_created_at": "2023-09-04T09:47:28", "gha_language": "Java", "gha_license_id": "Apache-2.0", "github_id": 52759259, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 3414, "license": "Apache-2.0", "license_type": "permissive", "path": "/components/org.wso2.carbon.identity.sts.passive/src/main/java/org/wso2/carbon/identity/sts/passive/custom/handler/CustomClaimsHandler.java", "provenance": "stack-edu-0024.json.gz:753920", "repo_name": "wso2-extensions/identity-inbound-auth-sts", "revision_date": "2023-08-22T06:29:06", "revision_id": "dd4c399d98319a3a712e18d22f2c87b183947127", "snapshot_id": "3d59e5a42598e70c9d20d88e6ff81c1cfb5e63ad", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/wso2-extensions/identity-inbound-auth-sts/dd4c399d98319a3a712e18d22f2c87b183947127/components/org.wso2.carbon.identity.sts.passive/src/main/java/org/wso2/carbon/identity/sts/passive/custom/handler/CustomClaimsHandler.java", "visit_date": "2023-08-30T22:10:13.376689", "added": "2024-11-19T00:12:52.342657+00:00", "created": "2023-08-22T06:29:06", "int_score": 2, "score": 2.078125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0042.json.gz" }
<?php namespace App\Http\Controllers; use App\Appointment; use App\Doctor; use App\Patient; use App\WorkingHour; use Carbon\Carbon; use http\Env\Response; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Http\Request; use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\DB; use Yajra\DataTables\DataTables; class AppointmentController extends Controller { public function newPatient() { // $doctors = Doctor::select('doctorId', 'firstName', 'lastName')->get(); $doctors = Doctor::select('doctorId', 'firstName', 'lastName')->get(); $patients = Patient::get(); return view('appointment.new_patient', compact('doctors', 'patients')); } public function oldPatient() { $patients = Patient::get(); $days = WorkingHour::get(); $doctors = WorkingHour::select('fkdoctorId', 'doctorId', 'firstName', 'lastName')->leftjoin('doctor', 'fkdoctorId', 'doctorId')->get(); return view('appointment.old_patient', compact('doctors', 'days', 'patients')); } public function insert(Request $r) { $rules = [ 'phone' => 'phone:BD', 'age' => 'digits_between:0,200', 'address' => 'regex:/^[a-zA-Z]+$/u|max:255|', 'email' => 'email', 'firstName' => 'regex:/^[a-zA-Z]+$/u|max:255|', 'lastName' => 'regex:/^[a-zA-Z]+$/u|max:255|', ]; $this->validate($r, $rules); $checkday = WorkingHour::where('fkdoctorId', $r->doctorId) ->where('day', date('l', strtotime($r->day))) ->where('start_time', '<=', date('H:i:p', strtotime($r->appointment_time))) ->where('end_time', '>=', date('H:i:p', strtotime($r->appointment_time)))->get(); // return Response()->json($start[4]); if (count($checkday) < 1) { Session::flash('message', 'Doctor is not available this day ot this time!'); Session::flash('message', 'Doctor is not available this day ot this time!!'); Session::flash('alert-class', 'alert-danger'); return back(); } else { $appointment = new Appointment(); $appointment->phone = $r->phone; $appointment->age = $r->age; $appointment->email = $r->email; $appointment->gender = $r->gender; $appointment->fkpatientId = $r->patientId; $appointment->fkdoctorId = $r->doctorId; $appointment->address = $r->address; $appointment->day = date('l', strtotime($r->day)); $appointment->appointment_time = date('H:i', strtotime($r->appointment_time)); $appointment->status = $r->status; // $appointment->phone = $r->phone; $appointment->save(); Session::flash('message', 'Appointment Created!'); Session::flash('alert-class', 'alert-success'); return redirect()->route('appointment'); } } public function showAppointment() { $appointmentInfo = Appointment::select(DB::raw("concat(`patient`.`firstName`, ' ' , `patient`.`lastName`) as patientname"), DB::raw("concat(`doctor`.`firstName`, ' ' , `doctor`.`lastName`) as doctorname"), DB::raw("CASE WHEN patient.gender = 1 THEN 'Male' WHEN patient.gender = 2 THEN 'Female' END AS gender"), DB::raw("DATE_FORMAT(`appointment_time`,'%h:%i %p') as appointment_time"), 'fkdoctorId', 'fkpatientId', 'patient.age', 'appointment.email', 'patient.phone', 'patient.address', 'appointment.day', DB::raw("CASE WHEN doctor.status = 0 THEN 'Deleted' WHEN doctor.status = 1 THEN 'Active' WHEN doctor.status = 2 THEN 'Inactive' END AS status")) ->leftjoin('doctor', 'fkdoctorId', 'doctorId') ->leftjoin('patient', 'fkpatientId', 'patientId')->get(); $datatables = Datatables::of($appointmentInfo); return $datatables->make(true); } public function index() { return view('appointment.index'); } public function add() { $doctors = Doctor::get(); $patients = Patient::get(); return view('appointment.add', compact('doctors', 'patients')); } public function checkoldpatient(Request $r) { $patient = Patient::where('phone', $r->phone)->first(); return $patient; // echo $patient; // var_dump($patient); // return view('appointment.add', compact('patient')); // $appointment = Patient::where('phone', $r->phone)->first(); // return $appointment; } public function checkpatient(Request $r) { $appointment = Patient::where('patient', $r->patient)->first(); return $appointment; } public function checkappointmenttime(Request $r) { $time = date('H:i ', strtotime($r->time)); $doctorId = $r->doctorId; $appointmenttime = Appointment:: leftJoin('working_hour', 'working_hour.fkdoctorId', 'appointment.fkdoctorId') ->where('working_hour.fkdoctorId', $doctorId) ->where('appointment.fkdoctorId', $doctorId) ->where('appointment_time', $time) ->where(function ($query) use ($time) { $query->where('start_time', '<=', $time) ->Where('end_time', '>=', $time); }) ->first(); return $appointmenttime; } public function deleteAppointment(Request $request) { $appointment = WorkingHour::findOrFail($request->id); $appointment->delete(); } }
dda3e187ff4b4c8007424b3623989234acba0f71
{ "blob_id": "dda3e187ff4b4c8007424b3623989234acba0f71", "branch_name": "refs/heads/master", "committer_date": "2019-11-11T13:19:37", "content_id": "57458a2b285aeff8fb1f795f260b8e42cfae406c", "detected_licenses": [ "MIT" ], "directory_id": "3540ce346ae75c5424b442b4295a5dbd298c4866", "extension": "php", "filename": "AppointmentController.php", "fork_events_count": 1, "gha_created_at": "2019-05-22T06:52:07", "gha_event_created_at": "2023-02-02T07:18:16", "gha_language": "HTML", "gha_license_id": null, "github_id": 187980020, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 5555, "license": "MIT", "license_type": "permissive", "path": "/app/Http/Controllers/AppointmentController.php", "provenance": "stack-edu-0048.json.gz:240890", "repo_name": "vedlct/Medico", "revision_date": "2019-11-11T13:19:37", "revision_id": "eb34e84d69dd944f9743a7925431c38789c0af23", "snapshot_id": "5ad868899907590bbbe9b897ed87eb3694a910be", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/vedlct/Medico/eb34e84d69dd944f9743a7925431c38789c0af23/app/Http/Controllers/AppointmentController.php", "visit_date": "2023-02-08T05:04:44.293738", "added": "2024-11-19T02:32:07.265582+00:00", "created": "2019-11-11T13:19:37", "int_score": 2, "score": 2.453125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0066.json.gz" }
package com.hcl.myhotel.exception; /** * @author Sridhar reddy * Genric class for all Resource not found like 404 */ public class ResourceNotFoundException extends RuntimeException { public ResourceNotFoundException() { super(); } public ResourceNotFoundException(String message, Throwable cause) { super(message, cause); } public ResourceNotFoundException(String message) { super(message); } public ResourceNotFoundException(Throwable cause) { super(cause); } }
a24ae688b9fb6ec7abc94da4050dfb2104065640
{ "blob_id": "a24ae688b9fb6ec7abc94da4050dfb2104065640", "branch_name": "refs/heads/master", "committer_date": "2018-07-26T10:30:37", "content_id": "01a6a8c96698e8a1e31f8886fb17efbaa4c5e4b0", "detected_licenses": [ "MIT" ], "directory_id": "477ba417ef71d123d1b43b8f01e573560c98c60f", "extension": "java", "filename": "ResourceNotFoundException.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 142419216, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 535, "license": "MIT", "license_type": "permissive", "path": "/HybridReservationSystem/src/main/java/com/hcl/myhotel/exception/ResourceNotFoundException.java", "provenance": "stack-edu-0022.json.gz:799730", "repo_name": "sridharreddych/Spring1", "revision_date": "2018-07-26T10:30:37", "revision_id": "ff171d05f907fa397222a097799109a9eeb29932", "snapshot_id": "89519de97719acd5d3a526b1643be07f556c6835", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/sridharreddych/Spring1/ff171d05f907fa397222a097799109a9eeb29932/HybridReservationSystem/src/main/java/com/hcl/myhotel/exception/ResourceNotFoundException.java", "visit_date": "2020-03-24T03:25:53.828701", "added": "2024-11-18T22:55:16.782202+00:00", "created": "2018-07-26T10:30:37", "int_score": 2, "score": 2.34375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0040.json.gz" }
package com.gsma.android.xoperatorapidemo.discovery; public class DiscoveryDeveloperOperatorSettings { // private static final DeveloperOperatorSetting atelDev=new DeveloperOperatorSetting("ATel Development", "https://integration-sb2.apiexchange.org/v1/discovery", // "dev2-test-app-test-key"); // // private static final DeveloperOperatorSetting attDev=new DeveloperOperatorSetting("AT&T Development", "https://integration-att.apiexchange.org/v1/discovery", // "att-dev1-payment-app-test-key"); // // private static final DeveloperOperatorSetting attProd=new DeveloperOperatorSetting("AT&T Production", "https://integration-att.apiexchange.org/v1/discovery", // "att-dev1-payment-app-prod-key"); // // private static final DeveloperOperatorSetting dtDev=new DeveloperOperatorSetting("DT Development", "https://integration-dt.apiexchange.org/v1/discovery", // "dt-dev1-payment-app-test-key"); // // private static final DeveloperOperatorSetting dtProd=new DeveloperOperatorSetting("DT Production", "https://integration-dt.apiexchange.org/v1/discovery", // "dt-dev1-payment-app-prod-key"); // // private static final DeveloperOperatorSetting vodDev=new DeveloperOperatorSetting("Vodafone Development", "https://integration-vod.apiexchange.org/v1/discovery", // "vod-dev1-payment-app-test-key"); // // private static final DeveloperOperatorSetting vodProd=new DeveloperOperatorSetting("Vodafone Production", "https://integration-vod.apiexchange.org/v1/discovery", // "vod-dev1-payment-app-prod-key"); // // private static final DeveloperOperatorSetting[] operators={atelDev, attDev, attProd, dtDev, dtProd, vodDev, vodProd}; // private static final DeveloperOperatorSetting testDev=new DeveloperOperatorSetting("MWC 2014 Demo", // "https://etelco-prod.apigee.net/v1/discovery", "DmaPIXFihqJhHhVQwpk9NHd7BzIzQxOe", "Doul7PiXVFCNI77g"); // private static final DeveloperOperatorSetting testDev=new DeveloperOperatorSetting("ETel Demo", // "https://etelco-prod.apigee.net/v1/discovery", "BJL7na81ZEaaFuoz1bbqT3CyS5x9CAFS", "Mt6HAx5Ujb39Sbs0", "https://etelco-prod.apigee.net/v1/logo"); private static final DeveloperOperatorSetting testDev=new DeveloperOperatorSetting("ETel Demo", "https://etelco-prod.apigee.net/v1/discovery", "BJL7na81ZEaaFuoz1bbqT3CyS5x9CAFS", "Mt6HAx5Ujb39Sbs0", "https://integration-dt.apiexchange.org/v1/logo"); private static String[] operatorNames=null; private static final DeveloperOperatorSetting[] operators={testDev}; static { operatorNames=new String[operators.length]; int index=0; for (DeveloperOperatorSetting operator:operators) { operatorNames[index++]=operator.getName(); } } public static String[] getOperatorNames() { return operatorNames; } public static DeveloperOperatorSetting getOperator(int index) { return operators[index]; } }
26ebb9d0db2cfd278da2c8b2f761e714487e53e1
{ "blob_id": "26ebb9d0db2cfd278da2c8b2f761e714487e53e1", "branch_name": "refs/heads/master", "committer_date": "2014-05-01T19:43:38", "content_id": "7ef95bb848410ff4a747a2d6bad6875ff1edf8f4", "detected_licenses": [ "MIT" ], "directory_id": "61fe9bdd2522d482f5b46f992083b12243d85232", "extension": "java", "filename": "DiscoveryDeveloperOperatorSettings.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 2858, "license": "MIT", "license_type": "permissive", "path": "/src/com/gsma/android/xoperatorapidemo/discovery/DiscoveryDeveloperOperatorSettings.java", "provenance": "stack-edu-0019.json.gz:230541", "repo_name": "biddyweb/CrossOperatorAPIDemo", "revision_date": "2014-05-01T19:43:38", "revision_id": "9f593875da727927404f3772d798cce554a765ae", "snapshot_id": "846234531c183db083adf15d5ca171db2714a19c", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/biddyweb/CrossOperatorAPIDemo/9f593875da727927404f3772d798cce554a765ae/src/com/gsma/android/xoperatorapidemo/discovery/DiscoveryDeveloperOperatorSettings.java", "visit_date": "2021-01-18T10:20:57.359173", "added": "2024-11-18T22:03:48.997957+00:00", "created": "2014-05-01T19:43:38", "int_score": 2, "score": 2.046875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0037.json.gz" }
define([ "locale" ],function(_){ var delete_column = { width:37, id:"crud:remove", header:"", template:"<span class='webix_icon fa-trash-o'></span>" }; var delete_handler = function(data){ return { "fa-trash-o":function(ev, id){ webix.confirm({ text:_("Crud.NoUndoMessage"), ok:_("OK"), cancel:_("Cancel"), callback:function(res){ if (res){ var target = typeof data === "string" ? webix.$$(data) : data; target.remove(id.row); } } }); } }; }; var empty_template = function(obj, common, value){ if (value === null) return ""; return value; }; var add_button = function(callback){ return { view:"button", maxWidth:200, value:_("Crud.AddNew"), click:callback }; }; function crud_collection(data, fields, name, params){ var id = webix.uid().toString(); if (data === null) data = id; var columns = [ delete_column ]; for (var i = 0; i < fields.length; i++){ var next = fields[i]; if (typeof next === "string") columns[i+1] = { id:next, editor:"text", sort:"string", fillspace:1, template: empty_template}; else columns[i+1] = next; } var table = { view:"datatable", columns:columns, id:id, scrollX:false, editable:true, onClick:delete_handler(data) }; if (params) for (var key in params) table[key] = params[key]; var toolbar = { view:"toolbar", elements:[ { view:"label", label:(name||"") }, add_button(function(){ var view = data; if (typeof view === "string") view = webix.$$(data); var nid = view.add({}); var grid = $$(id); grid.showItem(nid); var columns = grid.config.columns; for (var i = 0; i < columns.length; i++) { if (columns[i].editor && columns[i].editor != "inline-checkbox"){ grid.editCell(nid, grid.config.columns[i].id); return; } } }) ] }; return { $ui:{ type:"clean", rows:[ toolbar, table ] }, $oninit:function(){ if (data != id) $$(id).sync($$(data)); } }; } function crud_model(model, fields, name, params){ var ui = crud_collection(null, fields, name, params); var table = ui.$ui.rows[1]; table.url = model.find; table.save = model.save; return ui; } return { collection: crud_collection, model: crud_model, remove:{ column: delete_column, handler: delete_handler }, add:{ button: add_button } }; });
bc3b0973c9b5ebfb314608e206504f879df80a20
{ "blob_id": "bc3b0973c9b5ebfb314608e206504f879df80a20", "branch_name": "refs/heads/master", "committer_date": "2017-08-12T22:30:33", "content_id": "8d399652d53fce9e9ff4e5cf4e5fbc7b6f2046b5", "detected_licenses": [ "MIT" ], "directory_id": "660ee129876379762a5784423c38528a4f0fa527", "extension": "js", "filename": "crud.js", "fork_events_count": 0, "gha_created_at": "2017-08-12T19:45:19", "gha_event_created_at": "2017-08-12T19:45:19", "gha_language": null, "gha_license_id": null, "github_id": 100134340, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 2424, "license": "MIT", "license_type": "permissive", "path": "/helpers/crud.js", "provenance": "stack-edu-0031.json.gz:783331", "repo_name": "bituls/jet-core", "revision_date": "2017-08-12T22:30:33", "revision_id": "e98ae7edfde52c01215b9a5516e36b6434d67e79", "snapshot_id": "62407074ffe8c3df2a070bbb8fa264395dfdac79", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/bituls/jet-core/e98ae7edfde52c01215b9a5516e36b6434d67e79/helpers/crud.js", "visit_date": "2021-01-16T19:06:18.115130", "added": "2024-11-18T20:43:33.971044+00:00", "created": "2017-08-12T22:30:33", "int_score": 2, "score": 2.140625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0049.json.gz" }
package gov.va.escreening.serializer; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * Created by pouncilt on 7/13/14. */ public class JsonDateDeserializer extends JsonDeserializer<Date> { private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); @Override public Date deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { if (jsonParser.getText() != null && !jsonParser.getText().trim().equals("")) { String date = jsonParser.getText().substring(0, jsonParser.getText().length() -1); try { return dateFormat.parse(date); } catch (ParseException e) { throw new RuntimeException(e); } } else { return null; } } }
bc66eea74ebcd64d7540e769a632385996cee55c
{ "blob_id": "bc66eea74ebcd64d7540e769a632385996cee55c", "branch_name": "refs/heads/master", "committer_date": "2017-09-27T19:13:53", "content_id": "fa0615c7c1fadfea748b09697cfa4ff6c0b5d9d8", "detected_licenses": [ "Apache-2.0" ], "directory_id": "087ad3481ae046b538104674e43e79100b206672", "extension": "java", "filename": "JsonDateDeserializer.java", "fork_events_count": 0, "gha_created_at": "2018-03-22T18:49:50", "gha_event_created_at": "2018-03-22T18:49:52", "gha_language": null, "gha_license_id": "Apache-2.0", "github_id": 126381247, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 1154, "license": "Apache-2.0", "license_type": "permissive", "path": "/escreening/src/main/java/gov/va/escreening/serializer/JsonDateDeserializer.java", "provenance": "stack-edu-0029.json.gz:362374", "repo_name": "majia2968/Mental-Health-eScreening", "revision_date": "2017-09-27T19:13:53", "revision_id": "46538020c1bd71f12f352d4a82d7174bcbaa7b2a", "snapshot_id": "eba4676812a8b3ab79b8b379b4d9276bf6445ed9", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/majia2968/Mental-Health-eScreening/46538020c1bd71f12f352d4a82d7174bcbaa7b2a/escreening/src/main/java/gov/va/escreening/serializer/JsonDateDeserializer.java", "visit_date": "2021-04-18T19:41:40.325138", "added": "2024-11-18T22:26:09.586785+00:00", "created": "2017-09-27T19:13:53", "int_score": 3, "score": 2.578125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0047.json.gz" }
# 重启后生效 # 开启 chkconfig iptables on # 关闭 chkconfig iptables off # 即时生效,重启后失效 # 开启 service iptables start # 关闭 service iptables stop # 需要说明的是对于Linux下的其它服务都可以用以上命令执行开启和关闭操作。 # 在开启了防火墙时,做如下设置,开启相关端口 vim /etc/sysconfig/iptables # 添加以下内容 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
505dad572fdf4d35ddd0e328d91b1c12e3b5474d
{ "blob_id": "505dad572fdf4d35ddd0e328d91b1c12e3b5474d", "branch_name": "refs/heads/master", "committer_date": "2016-12-07T13:02:45", "content_id": "ae8dc53c73ea1a468ebbf65a49e54dc33bf003a7", "detected_licenses": [ "Apache-2.0" ], "directory_id": "203e602370f4673f65f3c3022355ff6634c268ac", "extension": "sh", "filename": "iptables.sh", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 75520188, "is_generated": false, "is_vendor": false, "language": "Shell", "length_bytes": 563, "license": "Apache-2.0", "license_type": "permissive", "path": "/shell/sys/iptables.sh", "provenance": "stack-edu-0068.json.gz:564822", "repo_name": "WeAreChampion/notes", "revision_date": "2016-12-07T13:02:45", "revision_id": "6c0f726d1003e5083d9cf1b75ac6905dc1c19c07", "snapshot_id": "4942fbd5c238559eb318787adc27be72f848de44", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/WeAreChampion/notes/6c0f726d1003e5083d9cf1b75ac6905dc1c19c07/shell/sys/iptables.sh", "visit_date": "2020-06-14T03:54:00.587873", "added": "2024-11-18T20:03:29.583164+00:00", "created": "2016-12-07T13:02:45", "int_score": 3, "score": 2.53125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0086.json.gz" }
from unittest import TestCase from mock import mock from pictures.dedupe import dedupe from tests import helpers def create_mock_cmp(equal_files): return lambda f1, f2: f1 in equal_files and f2 in equal_files class TestDedupe(TestCase): EQUAL_FILES = ['filename1', 'filename2', 'filename3'] NON_EQUAL_FILES = ['filename4', 'filename5'] FILES = EQUAL_FILES + NON_EQUAL_FILES @mock.patch('os.remove') @mock.patch('filecmp.cmp', side_effect=create_mock_cmp(EQUAL_FILES)) def test_dedupe_prefer_shorter(self, mock_cmp, mock_remove): dedupe(self.FILES) self.assertEquals(mock_cmp.mock_calls, helpers.calls_from([ ('filename1', 'filename2'), ('filename1', 'filename3'), ('filename1', 'filename4'), ('filename1', 'filename5'), ('filename4', 'filename5') ])) self.assertEquals(mock_remove.mock_calls, helpers.calls_from([ ('filename2',), ('filename3',) ])) @mock.patch('os.remove') @mock.patch('filecmp.cmp', side_effect=create_mock_cmp(EQUAL_FILES)) def test_dedupe_prefer_longer(self, mock_cmp, mock_remove): dedupe(self.FILES, prefer_shorter=False) self.assertEquals(mock_cmp.mock_calls, helpers.calls_from([ ('filename1', 'filename2'), ('filename2', 'filename3'), ('filename3', 'filename4'), ('filename3', 'filename5'), ('filename4', 'filename5') ])) self.assertEquals(mock_remove.mock_calls, helpers.calls_from([ ('filename1',), ('filename2',) ]))
86dabe3f5fd337ccdbead103c72fadfa55a18984
{ "blob_id": "86dabe3f5fd337ccdbead103c72fadfa55a18984", "branch_name": "refs/heads/master", "committer_date": "2017-01-16T10:28:16", "content_id": "d5469ec5195f32963b8935309beeddc13e7cb210", "detected_licenses": [ "MIT" ], "directory_id": "afb1a8008dde1663408e2c6a4359b7764e1c7562", "extension": "py", "filename": "test_dedupe.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 78937676, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1640, "license": "MIT", "license_type": "permissive", "path": "/tests/test_dedupe.py", "provenance": "stack-edu-0056.json.gz:409013", "repo_name": "mina-asham/pictures-dedupe-and-rename", "revision_date": "2017-01-16T10:28:16", "revision_id": "7abc60282b5df6f2d4bf058a82af6d7adcdeca63", "snapshot_id": "0b6727aacaeea235ffaae569853afd1dec3c4d4e", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/mina-asham/pictures-dedupe-and-rename/7abc60282b5df6f2d4bf058a82af6d7adcdeca63/tests/test_dedupe.py", "visit_date": "2021-01-13T15:12:33.450302", "added": "2024-11-19T02:42:23.419003+00:00", "created": "2017-01-16T10:28:16", "int_score": 3, "score": 2.6875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0074.json.gz" }
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\Mail; use App\Jobs\SendOrderEmail; use App\Mail\OrderShipped; use App\Order; use Log; class MailController extends Controller { public function index() { // $order = Order::findOrFail( rand(1,50) ); $order = Order::findOrFail( rand(1, 1) ); $recipient = 'steven@example.com'; Mail::to($recipient)->send(new OrderShipped($order)); return 'Sent order ' . $order->id; } public function testQueue() { // $order = Order::findOrFail( rand(1,50) ); $order = Order::findOrFail( rand(1, 1) ); SendOrderEmail::dispatch($order); Log::info('Dispatched order ' . $order->id); return 'Dispatched order ' . $order->id; } }
212a8c8296d6b489dbe804b5068f9814f7e941b1
{ "blob_id": "212a8c8296d6b489dbe804b5068f9814f7e941b1", "branch_name": "refs/heads/master", "committer_date": "2019-11-26T06:05:45", "content_id": "afd26d3eadc85c9ac1aad66ab2fa5712a37ac28b", "detected_licenses": [ "MIT" ], "directory_id": "7a868ba3237fad3a75982c6748d6761a0f3363ca", "extension": "php", "filename": "MailController.php", "fork_events_count": 0, "gha_created_at": "2019-11-09T04:02:50", "gha_event_created_at": "2023-02-02T08:38:39", "gha_language": "PHP", "gha_license_id": "MIT", "github_id": 220589042, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 813, "license": "MIT", "license_type": "permissive", "path": "/example-project/app/Http/Controllers/MailController.php", "provenance": "stack-edu-0054.json.gz:294485", "repo_name": "trung85/k8s_laravel", "revision_date": "2019-11-26T06:05:45", "revision_id": "51613d935c2b668591e9cd323550ba6d427c7a05", "snapshot_id": "3a046083e212fa8afbd57cf11550148748ddf572", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/trung85/k8s_laravel/51613d935c2b668591e9cd323550ba6d427c7a05/example-project/app/Http/Controllers/MailController.php", "visit_date": "2023-02-09T22:32:12.825055", "added": "2024-11-19T00:32:32.770884+00:00", "created": "2019-11-26T06:05:45", "int_score": 2, "score": 2.390625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0072.json.gz" }
package main import "github.com/gin-gonic/gin" /** 参数作为请求URL - rest */ func main() { r := gin.Default() r.GET(":name/:id", func(context *gin.Context) { context.JSON(200, gin.H{ "name": context.Param("name"), "id": context.Param("id"), }) }) r.Run("0.0.0.0:8082") }
c8303fdd22c0faca6f8dbcbcbe3b9ed97980f51f
{ "blob_id": "c8303fdd22c0faca6f8dbcbcbe3b9ed97980f51f", "branch_name": "refs/heads/master", "committer_date": "2023-07-08T15:23:22", "content_id": "94d497f40de4c7efbb7aa750771c67716e74f3f2", "detected_licenses": [ "Apache-2.0" ], "directory_id": "71b9e781af3a7c4c55e69f96f555cf6388113e5f", "extension": "go", "filename": "main.go", "fork_events_count": 12, "gha_created_at": "2019-05-10T10:58:58", "gha_event_created_at": "2023-06-19T15:18:03", "gha_language": "Java", "gha_license_id": "Apache-2.0", "github_id": 185972999, "is_generated": false, "is_vendor": false, "language": "Go", "length_bytes": 298, "license": "Apache-2.0", "license_type": "permissive", "path": "/golang/imooc-gin-study/router_url/main.go", "provenance": "stack-edu-0019.json.gz:105874", "repo_name": "imyzt/learning-technology-code", "revision_date": "2023-07-08T15:23:22", "revision_id": "8c01f8b6aa15ca78c1c86015e49e9ffbe10e29c3", "snapshot_id": "67231e38a33798552c00507a87082970451a729b", "src_encoding": "UTF-8", "star_events_count": 7, "url": "https://raw.githubusercontent.com/imyzt/learning-technology-code/8c01f8b6aa15ca78c1c86015e49e9ffbe10e29c3/golang/imooc-gin-study/router_url/main.go", "visit_date": "2023-07-24T22:22:45.799759", "added": "2024-11-19T03:16:16.094978+00:00", "created": "2023-07-08T15:23:22", "int_score": 2, "score": 2.03125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0037.json.gz" }
# Copyright 2020 The Weakly-Supervised Control Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Opening a door with a Sawyer arm. To test: python -m weakly_supervised_control.envs.sawyer_door """ from typing import Dict import os from gym import spaces import numpy as np from multiworld.envs.mujoco.sawyer_xyz.sawyer_door_hook import SawyerDoorHookEnv class SawyerDoorGoalEnv(SawyerDoorHookEnv): def __init__(self, **sawyer_xyz_kwargs): from multiworld.envs import env_util old_asset_dir = env_util.ENV_ASSET_DIR env_util.ENV_ASSET_DIR = os.path.join( os.path.dirname(__file__), 'assets') super().__init__(**sawyer_xyz_kwargs) env_util.ENV_ASSET_DIR = old_asset_dir self._door_start_id = self.model.site_name2id('door_start') self._door_end_id = self.model.site_name2id('door_end') @property def factor_names(self): return ['hand_x', 'hand_y', 'hand_z', 'door_angle'] @property def door_endpoints(self): door_start = self.data.get_site_xpos('door_start') door_end = self.data.get_site_xpos('door_end') return [door_start, door_end] def set_to_goal_angle(self, angle): self.data.set_joint_qpos('doorjoint', angle) self.data.set_joint_qvel('doorjoint', angle) self.sim.forward() def set_to_goal_pos(self, xyz, error_tol: float = 1e-2, max_iters: int = 1000): self.data.set_mocap_pos('mocap', np.array(xyz)) self.data.set_mocap_quat('mocap', np.array([1, 0, 1, 0])) u = self.data.ctrl.copy() u[:-1] = 0 # Step the simulation until the hand is close enough to the desired pos. error = 0 for sim_iter in range(max_iters // self.frame_skip): self.do_simulation(u, self.frame_skip) cur_hand_pos = self.get_endeff_pos() error = np.linalg.norm(xyz - cur_hand_pos) if error < error_tol: break # print(f'Took {sim_iter * self.frame_skip} (error={error}) to converge') def set_to_goal(self, goal: Dict[str, np.ndarray]): """ This function can fail due to mocap imprecision or impossible object positions. """ state_goal = goal['state_desired_goal'] assert state_goal.shape == (4,), state_goal.shape self.set_to_goal_pos(state_goal[:3]) self.set_to_goal_angle(state_goal[-1]) def sample_goals(self, batch_size, close_threshold: float = 0.05): goals = np.random.uniform( self.goal_space.low, self.goal_space.high, size=(batch_size, self.goal_space.low.size), ) # This only works for 2D control # goals[:, 2] = self.fixed_hand_z for goal in goals: hand_pos = goal[:3] door_angle = goal[3] self.set_to_goal_angle(door_angle) door_start, door_end = self.door_endpoints door_vec = door_end - door_start door_vec /= np.linalg.norm(door_vec) door_to_hand = hand_pos - door_start door_to_hand[2] = 0 proj = np.dot(door_vec, door_to_hand) * door_vec normal_vec = door_to_hand - proj length = np.linalg.norm(normal_vec) # If the arm is inside the door, move it outside. if normal_vec[1] > 0: hand_pos = hand_pos - 2 * normal_vec normal_vec *= -1 if length < close_threshold: perturb = normal_vec * 2 * close_threshold / length hand_pos += perturb goal[:3] = hand_pos return { 'desired_goal': goals, 'state_desired_goal': goals, } def _set_debug_pos(self, pos, i): marker_id = self.model.geom_name2id(f'marker{i}') self.model.geom_pos[marker_id, :] = pos self.sim.forward() if __name__ == '__main__': import gym from weakly_supervised_control.envs import register_all_envs from weakly_supervised_control.envs.env_wrapper import MujocoSceneWrapper from weakly_supervised_control.envs.multiworld.envs.mujoco import cameras register_all_envs() env = gym.make('SawyerDoorGoalEnv-v1') env = MujocoSceneWrapper(env) for e in range(20): env.reset() env.initialize_camera(cameras.sawyer_pick_and_place_camera) goal = env.sample_goals(1) goal = {k: v[0] for k, v in goal.items()} env.set_to_goal(goal) for _ in range(100): env.render()
d0efac8f26f7f846d6055ddd1e3b8402919ac971
{ "blob_id": "d0efac8f26f7f846d6055ddd1e3b8402919ac971", "branch_name": "refs/heads/master", "committer_date": "2020-10-02T22:37:05", "content_id": "39dfeef74b3812be24be2e08792ab365d5071759", "detected_licenses": [ "Apache-2.0" ], "directory_id": "2bb263fe87061291e91193c8b8ae4eeecc53e479", "extension": "py", "filename": "sawyer_door.py", "fork_events_count": 4, "gha_created_at": "2020-10-02T22:19:17", "gha_event_created_at": "2020-10-03T05:54:48", "gha_language": "Python", "gha_license_id": "Apache-2.0", "github_id": 300748294, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 5075, "license": "Apache-2.0", "license_type": "permissive", "path": "/weakly_supervised_control/envs/sawyer_door.py", "provenance": "stack-edu-0062.json.gz:210841", "repo_name": "google-research/weakly_supervised_control", "revision_date": "2020-10-02T22:37:05", "revision_id": "998034581710d148f7576a720383633e39b84a09", "snapshot_id": "6e7b5902a54cdbfcb4dcc6d5fcf5bce8405c9630", "src_encoding": "UTF-8", "star_events_count": 7, "url": "https://raw.githubusercontent.com/google-research/weakly_supervised_control/998034581710d148f7576a720383633e39b84a09/weakly_supervised_control/envs/sawyer_door.py", "visit_date": "2022-12-23T00:01:27.168266", "added": "2024-11-18T23:11:07.371407+00:00", "created": "2020-10-02T22:37:05", "int_score": 2, "score": 2.296875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0080.json.gz" }
《 **Eye of the Tiger** 》是电影《洛奇3》(Rocky III)主题曲。由Survivor演唱。 西尔维斯特·史泰龙再任导演拍摄《洛奇》第三集,竟然为这个传奇性的英雄角色开拓了新的戏剧空间,主题亦有新的突破,成绩相当亮眼。在本片中,洛基已连任数届拳王,名成利就之下安于逸乐生活而丧失斗志。黑人拳师T先生在大庭广众下公开向洛基叫阵,并且真的在擂台上打败了洛基,老教练因而病发去世。在洛基陷入低潮时,昔日死对头阿波罗毛遂自荐担任洛基的教练,重新激发他的斗志,终于在重赛时赢回了拳王宝座。在探讨名人高处不胜寒的心境方面,效果出奇的深刻和富于自省,故事的发展也跌宕有致。T先生原为重量级拳王阿里的保镖,造型和演出均具有爆炸性。 Survivor所演唱的《洛基第三集(Rocky III)》血脉喷张电影主题曲Eye of the Tiger,此作蝉联了全美单曲榜6周冠军,并一举拿下了Grammy最佳摇滚团体演唱奖,1992年奥斯卡最佳电影歌曲奖,将Survivor 的全球声势推向了高峰! 歌词下方是 _Eye of the Tiger钢琴谱_ ,欢迎大家使用。 ### Eye of the Tiger歌词: Risin' up back on the street did my time took my chances went the distance now i'm back on my feet just a man and and his will to survive so many times it happens too fast you trade your passion for glory don't lose your grip on the dreams of the past you must fight just to keep them alive Chorus It's the eye of the tiger It's the eye of the tiger It's the eye of the tiger it's the thrill of the fight it's the thrill of the fight it's the thrill of the fight risin' up to the challenge of our rival risin' up to the challenge of our rival risin' up to the challenge of our rival and the last known survivor stalks his prey in the night and the last known survivor stalks his prey in the night and the last known survivor stalks his prey in the night and he's watchin us all with the eye and he's watchin us all with the eye and he's watchin us all with the eye of the tiger of the tiger of the tiger Face to face out in the heat hangin' tough stayin' hungry they stack the odds still we take to the street for the kill with the will to survive Risin' up straight to the top had the guts got the glory went the distance now i'm not gonna stop just a man and his will to survive
a71621b5587fd3d4dfdc5ac723176ef3b89adab1
{ "blob_id": "a71621b5587fd3d4dfdc5ac723176ef3b89adab1", "branch_name": "refs/heads/main", "committer_date": "2021-08-14T14:43:39", "content_id": "6d362dac7b517c03d0f7b5bbb4965df92e43a911", "detected_licenses": [ "MIT" ], "directory_id": "fa64bbf8af245c26daaba1fe0c2b05c90b65092b", "extension": "md", "filename": "README.md", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 2551, "license": "MIT", "license_type": "permissive", "path": "/流行/Eye of the Tiger-洛奇3主題歌/README.md", "provenance": "stack-edu-markdown-0017.json.gz:42049", "repo_name": "Emptyspirit/everyonepiano-music-database", "revision_date": "2021-08-14T14:43:39", "revision_id": "fb8ba03dd9474f049b18d9822c40a395229b7aca", "snapshot_id": "e44a184efc15830289dee957c3410de169e5a212", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Emptyspirit/everyonepiano-music-database/fb8ba03dd9474f049b18d9822c40a395229b7aca/流行/Eye of the Tiger-洛奇3主題歌/README.md", "visit_date": "2023-07-16T15:02:39.001936", "added": "2024-11-19T00:14:49.092435+00:00", "created": "2021-08-14T14:43:39", "int_score": 2, "score": 2.171875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0017.json.gz" }
//@@parrot-mock class MockExampleDataFetcherWithOtherParameter: ExampleDataFetcherWithOtherParameter { final class Stub { var fetchCallCount = 0 var fetchCalledWith = [(options: Bool, completion: () -> ())]() } var stub = Stub() func parrotResetMock() { stub = Stub() } func fetch(options: Bool, completion: @escaping () -> ()) { stub.fetchCallCount += 1 stub.fetchCalledWith.append((options, completion)) } }
ca69dc71033ec5e99b0dfe126d1c9033f9a2c638
{ "blob_id": "ca69dc71033ec5e99b0dfe126d1c9033f9a2c638", "branch_name": "refs/heads/master", "committer_date": "2019-08-09T17:42:32", "content_id": "8ed1a0d4fa7aa74634c8a898e039bd46173d4d1e", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "434d9285927defb17cc213b34377eac3c6bd2b29", "extension": "swift", "filename": "MockExampleDataFetcherWithOtherParameter.swift", "fork_events_count": 2, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 142589444, "is_generated": false, "is_vendor": false, "language": "Swift", "length_bytes": 435, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/ParrotTests/RunExamples/Tests/MockExampleDataFetcherWithOtherParameter.swift", "provenance": "stack-edu-0072.json.gz:86791", "repo_name": "Bayer-Group/Parrot", "revision_date": "2019-08-09T17:42:32", "revision_id": "b0db2ed5965d53a6084511cc406b3f9cf66ab846", "snapshot_id": "ed4be519aaa61db712dc87cbc958c720bb0dd7f4", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/Bayer-Group/Parrot/b0db2ed5965d53a6084511cc406b3f9cf66ab846/ParrotTests/RunExamples/Tests/MockExampleDataFetcherWithOtherParameter.swift", "visit_date": "2022-02-08T14:04:04.802451", "added": "2024-11-19T00:26:38.644105+00:00", "created": "2019-08-09T17:42:32", "int_score": 2, "score": 2.28125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0090.json.gz" }
import { Component, Output, EventEmitter, OnInit } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { SessionStorageService, PessoaService, AuthenticationService } from 'src/app/shared/_services'; import { LocalUser } from 'src/app/shared/_models'; @Component({ selector: 'app-sidebar', templateUrl: './sidebar.component.html', styleUrls: ['./sidebar.component.scss'] }) export class SidebarComponent implements OnInit { isActive: boolean; collapsed: boolean; showMenu: string; pushRightClass: string; localUser: LocalUser; permissao: string; @Output() collapsedEvent = new EventEmitter<boolean>(); constructor( private router: Router, private authenticationService: AuthenticationService, private sessionStorageService: SessionStorageService, private pessoaService: PessoaService ) { this.router.events.subscribe(val => { if ( val instanceof NavigationEnd && window.innerWidth <= 992 && this.isToggled() ) { this.toggleSidebar(); } }); } ngOnInit() { this.isActive = false; this.collapsed = false; this.showMenu = ''; this.pushRightClass = 'push-right'; this.localUser = this.sessionStorageService.getValue(); this.permissao = this.localUser.pessoa.pesPermissao } resetarSenha() { let retorno: boolean; this.pessoaService.resetarSenha(this.localUser.pessoa).subscribe(ret => { retorno = ret.data; }, err => { console.log(err) alert("Erro ao Resetar Senha!") }, () => { alert("Senha Resetada com Sucesso!") }); /* if (retorno) { alert("Senha Resetada com Sucesso!") } else { alert("Erro ao Resetar Senha!") }*/ } eventCalled() { this.isActive = !this.isActive; } addExpandClass(element: any) { if (element === this.showMenu) { this.showMenu = '0'; } else { this.showMenu = element; } } togglecollapsed() { this.collapsed = !this.collapsed; this.collapsedEvent.emit(this.collapsed); } isToggled(): boolean { const dom: Element = document.querySelector('body'); return dom.classList.contains(this.pushRightClass); } toggleSidebar() { const dom: any = document.querySelector('body'); dom.classList.toggle(this.pushRightClass); } rltAndLtr() { const dom: any = document.querySelector('body'); dom.classList.toggle('rtl'); } deslogar() { this.authenticationService.deslogar(); } }
385391d902478ad2b81623ce7a4bd43fd52be65d
{ "blob_id": "385391d902478ad2b81623ce7a4bd43fd52be65d", "branch_name": "refs/heads/master", "committer_date": "2020-03-16T01:36:07", "content_id": "f58187a212f8073127cf4a9dca0938950c4f3466", "detected_licenses": [ "Apache-2.0" ], "directory_id": "bbfa3e1c5bbb8813213e6eb17274e7e382aa0809", "extension": "ts", "filename": "sidebar.component.ts", "fork_events_count": 0, "gha_created_at": "2020-02-26T23:12:23", "gha_event_created_at": "2020-03-16T01:36:08", "gha_language": "TypeScript", "gha_license_id": "NOASSERTION", "github_id": 243385492, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 2836, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/app/layout/components/sidebar/sidebar.component.ts", "provenance": "stack-edu-0074.json.gz:441027", "repo_name": "OrganizeRooms/NEW-FrontEnd-OrganizeRooms", "revision_date": "2020-03-16T01:36:07", "revision_id": "8ffc00b2a358c82e5245510dd08649b9dd9d2200", "snapshot_id": "44803c3ba485dd95d5baffc5f9f889583ad5881e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/OrganizeRooms/NEW-FrontEnd-OrganizeRooms/8ffc00b2a358c82e5245510dd08649b9dd9d2200/src/app/layout/components/sidebar/sidebar.component.ts", "visit_date": "2021-01-26T08:34:06.818236", "added": "2024-11-18T22:31:23.487849+00:00", "created": "2020-03-16T01:36:07", "int_score": 2, "score": 2.15625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0092.json.gz" }
//http://brownbuffalo.sourceforge.net/RoundOfGolfClues.html package main import "fmt" import l "gologic" type Dude struct { First, Last, Job, Score interface{} } type Round struct { D1,D2,D3,D4 interface{} } func v () l.V { return l.Fresh() } func betweeno(p interface{}, low, high int) l.Goal { if low > high { return l.Fail() } else { return l.Or( l.Unify(low,p), l.Call(betweeno,p,low+1,high)) } } func scoreo (q interface{}) l.Goal { a,b,c,d := l.Fresh4() return l.And( l.Unify(Round{Dude{v(),v(),v(),a}, Dude{v(),v(),v(),b}, Dude{v(),v(),v(),c}, Dude{v(),v(),v(),d}},q), betweeno(a,70,85), betweeno(b,70,85), betweeno(c,70,85), betweeno(d,70,85)) } func golfo (q l.V) l.Goal { membero := l.StructMemberoConstructor4(func (a,b,c,d interface{}) interface{} {return Round{a,b,c,d}}) bills_job := v() bills_score := v() mr_clubb_first_name := v() mr_clubbs_score := v() pro_shop_clerk_score := v() frank_score := v() caddy_score := v() sands_score := v() score1,score2,score3,score4 := l.Fresh4() mr_carters_first_name := v() return l.And( l.Unify(Round{Dude{"Bill",v(),v(),score1},Dude{"Jack",v(),v(),score2},Dude{"Frank",v(),v(),score3},Dude{"Paul",v(),v(),score4}},q), l.Neq(score1,score2), l.Neq(score1,score3), l.Neq(score1,score4), l.Neq(score2,score3), l.Neq(score2,score4), l.Neq(score3,score4), membero(Dude{"Jack", v(), v(), v()}, q), membero(Dude{v(), "Green", v(), v()}, q), membero(Dude{v(), v(), "short-order cook", v()}, q), // // 1 membero(Dude{"Bill", v(), bills_job, bills_score}, q), l.Neq(bills_job,"maintenance man"), membero(Dude{v(), v(), "maintenance man", v()}, q), l.Increasing(bills_score,score2), l.Increasing(bills_score,score3), l.Increasing(bills_score,score4), // // 2 membero(Dude{mr_clubb_first_name, "Clubb", v(), mr_clubbs_score}, q), l.Neq(mr_clubb_first_name, "Paul"), membero(Dude{v(), v(), "pro-shop clerk", pro_shop_clerk_score}, q), l.Difference(mr_clubbs_score,10,pro_shop_clerk_score), // //3 membero(Dude{"Frank", v(), v(), frank_score}, q), membero(Dude{v(), v(), "caddy", caddy_score}, q), membero(Dude{v(), "Sands", v(), sands_score}, q), l.Or(l.And(l.Difference(frank_score, 7, sands_score), l.Difference(caddy_score, 4, sands_score)), l.And(l.Difference(frank_score, 4, sands_score), l.Difference(caddy_score, 7, sands_score))), // // // 4 membero(Dude{mr_carters_first_name, "Carter", v(), 78}, q), l.Increasing(frank_score, 78), l.Neq(mr_carters_first_name,"Frank"), // // // 5 l.Neq(score1,81), l.Neq(score2,81), l.Neq(score3,81), l.Neq(score4,81), scoreo(q), ) } func main() { q := l.Fresh() c := l.Run(q,golfo(q)) for n := 0 ; n < 10 ; n++ { i := <- c if i != nil { fmt.Println(i) } else { break } } }
3bb30b2d6c6559f1c427111cf61be7e4801fae90
{ "blob_id": "3bb30b2d6c6559f1c427111cf61be7e4801fae90", "branch_name": "refs/heads/master", "committer_date": "2013-10-26T08:35:38", "content_id": "02940b7bb837c564aa085f37cd29be626ad15d87", "detected_licenses": [ "MIT" ], "directory_id": "bc059e43ad4647bb467c5534c93e5a4ce6a10186", "extension": "go", "filename": "golf.go", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "Go", "length_bytes": 3780, "license": "MIT", "license_type": "permissive", "path": "/examples/golf.go", "provenance": "stack-edu-0018.json.gz:302369", "repo_name": "sarvex/gologic", "revision_date": "2013-10-26T08:35:38", "revision_id": "65feb61c6b9733af7e63dfec8877d2ad667d974c", "snapshot_id": "9549e59f569ca94f27198cf60837ac493c22ce11", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/sarvex/gologic/65feb61c6b9733af7e63dfec8877d2ad667d974c/examples/golf.go", "visit_date": "2021-01-17T08:13:39.210130", "added": "2024-11-18T19:51:02.281643+00:00", "created": "2013-10-26T08:35:38", "int_score": 3, "score": 3, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0036.json.gz" }
import { simbolo } from "./simbolo" export class entorno{ public anterior: entorno public tabla: {[id:string] : simbolo} public consola: string constructor(anterior){ this.anterior = anterior this.tabla = {} this.consola = "" } agregar(id:string,simbolo:simbolo){ this.tabla[id.toLocaleLowerCase()] = simbolo } existeActual(id:string){ let existe = this.tabla[id.toLocaleLowerCase()] if (existe != null){ return true } return false } existe(id:string){ let ts:entorno = this while (ts != null){ let existe = ts.tabla[id.toLocaleLowerCase()] if (existe != null){ return true } ts = ts.anterior } return false } getSimbol(id:string){ let ts: entorno = this while (ts != null){ let existe = ts.tabla[id.toLocaleLowerCase()] if (existe != null){ return existe } ts = ts.anterior } return null } appEnd(cadena: string){ return this.consola+= cadena + "\n" } }
3956d49d9e9f4355cc6e69c9d1432ae2a98836d1
{ "blob_id": "3956d49d9e9f4355cc6e69c9d1432ae2a98836d1", "branch_name": "refs/heads/main", "committer_date": "2021-07-07T02:55:16", "content_id": "9a6f791de44db6c5f96c6ca002dfbd9bf6f1dd7d", "detected_licenses": [ "MIT" ], "directory_id": "4dd1aef620dfa836a877733be203472cc0fe51d0", "extension": "ts", "filename": "entorno.ts", "fork_events_count": 1, "gha_created_at": "2021-06-12T07:16:02", "gha_event_created_at": "2021-07-07T02:42:04", "gha_language": "JavaScript", "gha_license_id": "MIT", "github_id": 376227052, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 1191, "license": "MIT", "license_type": "permissive", "path": "/20211SVAC/G29/codigo fuente/clases/ast/entorno.ts", "provenance": "stack-edu-0074.json.gz:914404", "repo_name": "Jacks128/tytusx", "revision_date": "2021-07-07T02:55:16", "revision_id": "028100c10321948a1d2e07bce3cb96731e161cde", "snapshot_id": "a762b0b9d4ddfaeb2cfa8f5603c3ddfa20dae378", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Jacks128/tytusx/028100c10321948a1d2e07bce3cb96731e161cde/20211SVAC/G29/codigo fuente/clases/ast/entorno.ts", "visit_date": "2023-06-12T20:50:07.041654", "added": "2024-11-18T23:37:48.683320+00:00", "created": "2021-07-07T02:55:16", "int_score": 3, "score": 2.9375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0092.json.gz" }
import { html } from "lit-html" import { conditions, Conditions } from "../conditions" import { dateTime, DateTime } from "../dateTime" import { temperature, Temperature } from "../temperature" export const app = { initialState: () => Object.assign({}, dateTime.initialState(), conditions.initialState(), { air: temperature.initialState("Air") }, { water: temperature.initialState("Air") } ), actions: update => Object.assign({}, dateTime.actions(update), conditions.actions(update), temperature.actions(update) ) } export const App = (state, actions) => html` <div class="row"> <div class="col-md-4"> ${DateTime(state, actions)} </div> <div class="col-md-4"> ${Conditions(state, actions)} ${Temperature(state, "air", actions)} ${Temperature(state, "water", actions)} </div> </div> `
9bf66eb38718a00ee2dfe0591aaad8b7e993fd3d
{ "blob_id": "9bf66eb38718a00ee2dfe0591aaad8b7e993fd3d", "branch_name": "refs/heads/master", "committer_date": "2019-01-20T02:38:12", "content_id": "9d32af65a39dd928c7f0dcdf534e138695d34297", "detected_licenses": [ "MIT" ], "directory_id": "f6e8cae40fad6a3d1d6b4ea7b323a0bd758362ba", "extension": "js", "filename": "index.js", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": null, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 867, "license": "MIT", "license_type": "permissive", "path": "/examples/setup/lit-html/src/app/index.js", "provenance": "stack-edu-0033.json.gz:709025", "repo_name": "disciplezero/meiosis-examples", "revision_date": "2019-01-20T02:38:12", "revision_id": "6649aab1567fd776c4f29183511179e21e3557c8", "snapshot_id": "9d2b09bc68822d83dcc976d19ca5221131dee10e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/disciplezero/meiosis-examples/6649aab1567fd776c4f29183511179e21e3557c8/examples/setup/lit-html/src/app/index.js", "visit_date": "2020-04-30T01:55:07.955717", "added": "2024-11-18T21:22:07.543958+00:00", "created": "2019-01-20T02:38:12", "int_score": 2, "score": 2.421875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0051.json.gz" }
#!/bin/bash REMOTES_COUNT=$(git remote | wc -l) if [ $REMOTES_COUNT -eq 0 ]; then echo "No remotes" > /dev/stderr exit 1 elif [ $REMOTES_COUNT -eq 1 ]; then exec git remote else CURRENT_REMOTE=$(git config branch.$(git name-rev --name-only HEAD).remote) if [ ! -z "$CURRENT_REMOTE" ]; then echo $CURRENT_REMOTE else if git remote | grep -E '^origin$'; then exit 0 else echo "Can't pick a remote" > /dev/stderr exit 1 fi fi fi
296fed924a017651b4ae3ba7a96ad044fb6d7c20
{ "blob_id": "296fed924a017651b4ae3ba7a96ad044fb6d7c20", "branch_name": "refs/heads/master", "committer_date": "2023-08-23T15:45:36", "content_id": "1c02e3332ce58d4c519a0edf753145f262ae018b", "detected_licenses": [ "MIT" ], "directory_id": "497c58bbe24bc3eae889b4290e941b0ab56197ff", "extension": "", "filename": "get-remote", "fork_events_count": 15, "gha_created_at": "2020-11-16T15:17:07", "gha_event_created_at": "2023-09-14T14:12:21", "gha_language": "Python", "gha_license_id": "MIT", "github_id": 313342327, "is_generated": false, "is_vendor": false, "language": "Shell", "length_bytes": 475, "license": "MIT", "license_type": "permissive", "path": "/.orchestra/ci/get-remote", "provenance": "stack-edu-0070.json.gz:201193", "repo_name": "revng/orchestra", "revision_date": "2023-07-25T14:24:21", "revision_id": "5e5595a4961210e06a5697610e53ecec4c8a9270", "snapshot_id": "d813c2f1adf63bc5b71219b23f44c1f426187a96", "src_encoding": "UTF-8", "star_events_count": 25, "url": "https://raw.githubusercontent.com/revng/orchestra/5e5595a4961210e06a5697610e53ecec4c8a9270/.orchestra/ci/get-remote", "visit_date": "2023-08-30T22:51:33.369098", "added": "2024-11-19T00:42:42.740017+00:00", "created": "2023-07-25T14:24:21", "int_score": 4, "score": 3.703125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0088.json.gz" }
# elasticsearch-curator [![Cookbook Version](http://img.shields.io/cookbook/v/elasticsearch-curator.svg)](https://community.opscode.com/cookbooks/elasticsearch-curator) [![Build Status](https://travis-ci.org/cyberflow/chef-elasticsearch-curator.svg?branch=master)](https://travis-ci.org/cyberflow/chef-elasticsearch-curator) Chef cookbook to install and configure [elasticsearch-curator](https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html) from version 4. ## Tested Platforms * ubuntu 16.04 * centos 7 ## Usage This cookbook can be used by including `elasticsearch-curator::default` in your run list and settings attributes as needed. Alternatively, you can use the custom resources directly. If you are using elasticsearch-curator < 5 you might want to use the cookbook version v0.2.8. ### Attributes | Key | Type | Description | Default | |--------------------------------------|--------|-------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------| | node['elasticsearch-curator']['version'] | String | Version of elasticsearch-curator to install, nil = latest | nil | | node['elasticsearch-curator']['repository_url'] | String | URL of elasticsearch-curator package repository | 'http://packages.elastic.co/curator/4/debian' | | node['elasticsearch-curator']['repository_key'] | String | elasticsearch-curator repository key | 'https://packages.elastic.co/GPG-KEY-elasticsearch' | | node['elasticsearch-curator']['bin_path'] | String | bin path for elasticsearch-curator | '/usr/bin' | |node['elasticsearch-curator']['username']|String|user for running curator|'curator'| |node['elasticsearch-curator']['config_file_path']|String|path to direct curator config file|"/home/#{node['elasticsearch-curator']['username']}/.curator"| |node['elasticsearch-curator']['action_file_path']|String|path to direct action config file|"/home/#{node['elasticsearch-curator']['username']}/.curator"| |node['elasticsearch-curator']['cron_minute']|String|Minute to run the curator cron job|'0'| |node['elasticsearch-curator']['cron_hour']|String|Hour to run the curator cron job|'*'| |node['elasticsearch-curator']['config']|Hash|config elasticsearch-curator| {<br>&nbsp;&nbsp;'client' => {<br>&nbsp;&nbsp;&nbsp;&nbsp;'hosts' => ['<IP_ADDRESS>'],<br>&nbsp;&nbsp;&nbsp;&nbsp;'port' => 9200,<br>&nbsp;&nbsp;&nbsp;&nbsp;'use_ssl' => false,<br>&nbsp;&nbsp;&nbsp;&nbsp;'ssl_no_validate' => false,<br>&nbsp;&nbsp;&nbsp;&nbsp;'timeout' => 30,<br>&nbsp;&nbsp;&nbsp;&nbsp;'master_only' => false<br>&nbsp;&nbsp;},<br>&nbsp;&nbsp;'logging' => {<br>&nbsp;&nbsp;&nbsp;&nbsp;'loglevel' => 'INFO',<br>&nbsp;&nbsp;&nbsp;&nbsp;'logformat' => 'default'<br>&nbsp;&nbsp;}<br>}| This cookbook ships with custom resources for install elasticsearch-curator and managing the configuration file: ### Custom Resources #### elasticsearch_curator_install Installs elasticsearch-curator. Optionally specifies a version, otherwise the latest available is installed ```ruby elasticsearch_curator_install 'curator' do install_method node['elasticsearch-curator']['install_method'] action :install end ``` #### elasticsearch_curator_config Writes out the elasticsearch-curator configuration file. ```ruby elasticsearch_curator_config 'default' do config node['elasticsearch-curator']['config'] action :configure end ``` This method also supports a http_auth property to allow passing a string with this format : "username:password". This allows retrieving the credentials from the wrapper cookbook (for example using chef-vault) and not store this sensitive information in the attributes. #### elasticsearch_curator_action This will setup a cron job and create action.yaml file for elasticsearch-curator. ```ruby elasticsearch_curator_action 'action' do config node['elasticsearch-curator']['action_config'] minute '0' hour '*' action :create end ``` ## Tests To run tests, install all dependencies with [bundler](http://bundler.io/): bundle install bundle exec cookstyle bundle exec foodcritic .
36dbb0e296922a34d4cd215c8eae2513fc3ffc06
{ "blob_id": "36dbb0e296922a34d4cd215c8eae2513fc3ffc06", "branch_name": "refs/heads/master", "committer_date": "2019-07-25T08:00:54", "content_id": "3a25f2f276296802422f267ab729709b0cfa4356", "detected_licenses": [ "MIT" ], "directory_id": "a2edf11ac47fb53118ba7da6cc2743756deb56ab", "extension": "md", "filename": "README.md", "fork_events_count": 27, "gha_created_at": "2016-07-07T13:28:27", "gha_event_created_at": "2019-07-25T08:00:58", "gha_language": "Ruby", "gha_license_id": "MIT", "github_id": 62808851, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 4441, "license": "MIT", "license_type": "permissive", "path": "/README.md", "provenance": "stack-edu-markdown-0014.json.gz:208386", "repo_name": "cyberflow/chef-elasticsearch-curator", "revision_date": "2019-07-25T08:00:54", "revision_id": "3296bf1d509990a9c784f691a4166fb1e9f96fac", "snapshot_id": "4c400845467a2e4a551013af3e83c9d7c529073b", "src_encoding": "UTF-8", "star_events_count": 6, "url": "https://raw.githubusercontent.com/cyberflow/chef-elasticsearch-curator/3296bf1d509990a9c784f691a4166fb1e9f96fac/README.md", "visit_date": "2021-01-17T19:16:38.128657", "added": "2024-11-18T23:21:53.200826+00:00", "created": "2019-07-25T08:00:54", "int_score": 4, "score": 3.75, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0014.json.gz" }
import React from 'react'; import { connect } from 'react-redux'; import {api} from '../../actions/_request'; import { Modal, ModalHeader, ModalBody, ModalFooter, Button, Label, Input, Row, Col } from 'reactstrap'; import Moment from 'moment'; import swal2 from 'sweetalert2'; export default class ModalPrestamo extends React.Component { constructor(props) { super(props); this.state = { insumo : { id : '', insumo : '', desc_insumo : '', }, action : 'save', }; this.handleInputChange = this.handleInputChange.bind(this); this.resetModal= this.resetModal.bind(this); } componentDidMount() { let id = this.props.id; let self = this; if(id != null ) { api().get(`/producto_id/${id}`) .then(function(response) { self.setState({ insumo: response.data, action: 'update', }); }); } else { self.resetModal(); } } resetModal(){ this.setState({ prestamo : { id : '', insumo : '', descripcion : '', }, action : 'save', }); } handleInputChange(event){ let {insumo} = this.state; const target = event.target; const value = target.type === 'checkbox' ? target.checked : target.value; const name = target.name; if(target.type == 'number'){ if(value.length <= event.target.getAttribute('maxlengh')){ insumo[name] = value; } }else{ insumo[name] = value; } this.setState({ insumo : insumo }); } handleSubmit = (evt) =>{ evt.preventDefault(); let {action, insumo} = this.state; let url = ''; let _self = this; if(action == 'save'){ url = '/prod'; }else{ url = '/edit_prod'; } api().post(url, insumo) .then((res)=>{ if(!res.data){ _self.props.toggle(); _self.props.refresh(); }else{ swal2( 'Error!', 'Insumo duplicado', 'error' ) } }) .catch((err)=>{console.log(err)}) } render() { let {insumo , action} = this.state; return( <Modal isOpen={this.props.open} toggle={this.props.toggle} className="default modal-lg "> <form onSubmit={this.handleSubmit}> <ModalHeader toggle={this.props.toggle}>{this.props.title}</ModalHeader> <ModalBody> <Row> <Col xs="12" sm="12"> <div className="form-group"> <label className="">Insumo:</label> <Input name="insumo" type="number" onChange={this.handleInputChange} value={insumo.insumo} maxlengh={6} /> </div> </Col> <Col xs="12" sm="12"> <div className="form-group"> <label className="">Descripcion:</label> <Input placeholder="" type="textarea" name="desc_insumo" value={insumo.desc_insumo} onChange={this.handleInputChange} required cols={4} /> </div> </Col> </Row> </ModalBody> <ModalFooter> { <div> <Button color="success" type="submit"> Guardar </Button> <Button color="secondary" onClick={this.props.toggle}> Cerrar </Button> </div> } </ModalFooter> </form> </Modal> ); } }
2f94613cc0446f86f4851297433bcb463e672be0
{ "blob_id": "2f94613cc0446f86f4851297433bcb463e672be0", "branch_name": "refs/heads/master", "committer_date": "2020-01-24T00:46:25", "content_id": "1d9f029dfeb1cf87bc91de4566e103e0027bcb16", "detected_licenses": [ "MIT" ], "directory_id": "db1b95c9832b01c899b74b826426aff9ac2ba801", "extension": "js", "filename": "insumoModal.js", "fork_events_count": 0, "gha_created_at": "2018-09-22T19:31:08", "gha_event_created_at": "2023-01-04T13:21:04", "gha_language": "CSS", "gha_license_id": "MIT", "github_id": 149910330, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 4794, "license": "MIT", "license_type": "permissive", "path": "/src/views/Insumos/insumoModal.js", "provenance": "stack-edu-0035.json.gz:684518", "repo_name": "Rodrigocoronel/todoappreact", "revision_date": "2020-01-24T00:46:25", "revision_id": "4b279c12ffe7782111bb7422761e567ae8dee416", "snapshot_id": "a449c854fa656319b4aeaf6a74e24f4f6efb9309", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Rodrigocoronel/todoappreact/4b279c12ffe7782111bb7422761e567ae8dee416/src/views/Insumos/insumoModal.js", "visit_date": "2023-01-11T08:36:45.019792", "added": "2024-11-19T01:32:29.606914+00:00", "created": "2020-01-24T00:46:25", "int_score": 2, "score": 2.34375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0053.json.gz" }
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
7