text
stringlengths
20
812k
id
stringlengths
40
40
metadata
dict
<?php /** * Lombardia Informatica S.p.A. * OPEN 2.0 * * @see http://example.com Developers'community * @license GPLv3 * @license https://opensource.org/licenses/gpl-3.0.html GNU General Public License version 3 * * @package lispa\amos\basic\template * @category CategoryName * @author Lombardia Informatica S.p.A. */ namespace frontend\models; use Yii; use yii\base\Model; use common\models\User; use yii\helpers\Html; /** * Signup form */ class SignupForm extends Model { public $username; public $surname; public $email; public $password; const INTERNAL_ID_SOLT = '2f38c4a57c4487bb96d8faabbe936b14'; public $reCaptcha; /** * @inheritdoc */ public function rules() { return [ ['username', 'trim'], ['username', 'required'], ['username', 'string', 'min' => 2, 'max' => 255], ['surname', 'trim'], ['surname', 'string', 'min' => 2, 'max' => 255], ['email', 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'string', 'max' => 255], ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address is already registered, access the '.Html::a('login page to sign in',['site/login'], ['style'=>'font-weight:bold'])], ['password', 'required'], ['password', 'string', 'min' => 6], [['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'message' => 'Please confirm that you are not a bot.'] ]; } public function attributeLabels() { return [ 'username' => 'Name', 'surname' => 'Surname', ]; } /** * Signs user up. * * @return User|null the saved model or null if saving fails */ public function signup() { if (!$this->validate()) { return null; } $user = new User(); $user->username = $this->username; $user->surname = $this->surname; $user->email = $this->email; $user->setPassword($this->password); $user->generateAuthKey(); if($user->save()){ $user->internal_user_id = md5($user->id.$user->password_hash.$user->auth_key.$this::INTERNAL_ID_SOLT); $user->save(); return $user; } return null; } }
af987a10e031af61b49542197f29f9eb77dd91f9
{ "blob_id": "af987a10e031af61b49542197f29f9eb77dd91f9", "branch_name": "refs/heads/master", "committer_date": "2017-11-15T08:46:19", "content_id": "0beacde8385bf272c34218d8613ffa75cf568957", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "9cb6c1a65517d3a81eaa657668f694d8956f394f", "extension": "php", "filename": "SignupForm.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 101665991, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 2496, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/frontend/models/SignupForm.php", "provenance": "stack-edu-0053.json.gz:161586", "repo_name": "maxym16/ConnectingTalents", "revision_date": "2017-11-15T08:46:19", "revision_id": "ba81cba2a3ac2511309621e0c666257b90b8b3e0", "snapshot_id": "5a486f5c499a3ff5e7ba6ff00b12d941191d7844", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/maxym16/ConnectingTalents/ba81cba2a3ac2511309621e0c666257b90b8b3e0/frontend/models/SignupForm.php", "visit_date": "2021-01-20T11:10:34.721090", "added": "2024-11-18T22:48:44.320517+00:00", "created": "2017-11-15T08:46:19", "int_score": 3, "score": 2.578125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0071.json.gz" }
package org.chenile.stm.ognl; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.chenile.stm.action.ScriptingStrategyBase; import ognl.Ognl; import ognl.OgnlRuntime; /** * * @author raja * Ognl wrapper for using OGNL in scripting. * <p>initializes Ognl accessors */ public class OgnlScriptingStrategy extends ScriptingStrategyBase { static { // allow access to the http servlet request attributes from OGNL. OgnlRuntime.setPropertyAccessor(HttpServletRequest.class, new HttpServletRequestAccessor()); OgnlRuntime.setPropertyAccessor(Map.class, new MapAccessor()); } @Override protected Object getValue(Object parsedScript, Object context) throws Exception { return Ognl.getValue(parsedScript, context); } @Override protected Object parseExpression(String code) throws Exception { // return code; return Ognl.parseExpression(code); } }
4a8c7cc12f933106363409069aecb37e3acbbccb
{ "blob_id": "4a8c7cc12f933106363409069aecb37e3acbbccb", "branch_name": "refs/heads/master", "committer_date": "2019-11-27T02:38:47", "content_id": "cd625053e1cebe1da90131fe2affe552338e9d8e", "detected_licenses": [ "MIT" ], "directory_id": "3d05618ae85fd3aa9d1df2dfe7d36f33cfbc4494", "extension": "java", "filename": "OgnlScriptingStrategy.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": 949, "license": "MIT", "license_type": "permissive", "path": "/stm/src/main/java/org/chenile/stm/ognl/OgnlScriptingStrategy.java", "provenance": "stack-edu-0029.json.gz:853166", "repo_name": "dewesh/chenile", "revision_date": "2019-11-27T02:38:47", "revision_id": "88b0634d295a13b23c59c6a835bc517cb0e15399", "snapshot_id": "fc375dc481b799c5f37eac17f78ad0f22a6e240e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/dewesh/chenile/88b0634d295a13b23c59c6a835bc517cb0e15399/stm/src/main/java/org/chenile/stm/ognl/OgnlScriptingStrategy.java", "visit_date": "2022-12-28T18:42:07.198407", "added": "2024-11-19T01:52:45.890560+00:00", "created": "2019-11-27T02:38:47", "int_score": 2, "score": 2.1875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0047.json.gz" }
package com.huawei.hms.audiokitdemotest; import android.app.Activity; import android.os.Environment; import android.util.Log; import com.huawei.hms.api.bean.HwAudioPlayItem; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class HwAudioPlayItemBeta extends HwAudioPlayItem{ private static final String TAG = "Ringtone"; public static enum Ext { MP3(".mp3"), M4A(".m4a"), AAC(".aac"), AMR(".amr"), IMY(".imy"), WAV(".wav"), OGG(".ogg"), RTTTL(".rtttl"); private String ext; private Ext(String ext) { this.ext = ext; } @Override public String toString(){ return ext; } } private String resourcePath; public void setResourcePath(Activity activity, int resource,Ext ext){ //get the path of a cache folder /storage/emulated/0/.[PACKAGE_NAME] String dir=Environment.getExternalStorageDirectory()+File.separator+"."+activity.getPackageName(); //get the path where to save the file /storage/emulated/0/.[PACKAGE_NAME]/[RESOURCE_ID].[EXT] this.resourcePath=dir+File.separator+resource+ext.toString(); //read the audio from resource folder and put it in the external storage try { File directory = new File(dir); if (directory.mkdirs() || directory.isDirectory()) { InputStream in = activity.getResources().openRawResource(resource); FileOutputStream out = new FileOutputStream(this.resourcePath); byte[] buff = new byte[1024]; int read = 0; try { while ((read = in.read(buff)) > 0) { out.write(buff, 0, read); } } finally { in.close(); out.close(); } //set the file from this.setFilePath(this.resourcePath); } }catch (IOException e) { e.printStackTrace(); Log.i(TAG, "setResourcePath (IOException): "+e.getMessage()); } } public void setResourcePath(Activity activity, int resource){ setResourcePath(activity,resource,Ext.MP3); } public String getResourcePath() { return this.resourcePath; } }
7df03676bb2bab5085bfaaa9befe4686c04eb939
{ "blob_id": "7df03676bb2bab5085bfaaa9befe4686c04eb939", "branch_name": "refs/heads/main", "committer_date": "2020-12-12T22:50:32", "content_id": "5400a81c773f9cd6d6ab3503143d6369927cbf74", "detected_licenses": [ "Apache-2.0" ], "directory_id": "73fce3578a54c60a9d1b44a64e3dbb5b01befbd1", "extension": "java", "filename": "HwAudioPlayItemBeta.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 314449876, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 2328, "license": "Apache-2.0", "license_type": "permissive", "path": "/app/src/main/java/com/huawei/hms/audiokitdemotest/HwAudioPlayItemBeta.java", "provenance": "stack-edu-0029.json.gz:34787", "repo_name": "ikamaru/android-hms-audio-kit", "revision_date": "2020-12-12T22:50:32", "revision_id": "0b6d6deff7917dec9fb856b39946a0c6f595fb31", "snapshot_id": "29153fdfd098015118c6c7554b5178680c28a6ae", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/ikamaru/android-hms-audio-kit/0b6d6deff7917dec9fb856b39946a0c6f595fb31/app/src/main/java/com/huawei/hms/audiokitdemotest/HwAudioPlayItemBeta.java", "visit_date": "2023-02-02T08:08:55.050742", "added": "2024-11-18T23:35:47.574835+00:00", "created": "2020-12-12T22:50:32", "int_score": 2, "score": 2.5, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0047.json.gz" }
/* * Copyright 2017 LunaMC.io * * 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 io.lunamc.protocol.packet.data; import io.netty.buffer.ByteBuf; import java.util.Objects; class BaseChunkMeta implements ChunkMeta { private int chunkX; private int chunkZ; private int primaryBitMask; BaseChunkMeta() { } @Override public int getChunkX() { return chunkX; } @Override public void setChunkX(int chunkX) { this.chunkX = chunkX; } @Override public int getChunkZ() { return chunkZ; } @Override public void setChunkZ(int chunkZ) { this.chunkZ = chunkZ; } @Override public int getPrimaryBitMask() { return primaryBitMask; } @Override public void setPrimaryBitMask(int primaryBitMask) { this.primaryBitMask = primaryBitMask; } @Override public void write(ByteBuf output) { output.writeInt(getChunkX()); output.writeInt(getChunkZ()); output.writeShort(getPrimaryBitMask()); } @Override public void read(ByteBuf input) { setChunkX(input.readInt()); setChunkZ(input.readInt()); setPrimaryBitMask(input.readUnsignedShort()); } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof ChunkMeta)) return false; ChunkMeta that = (ChunkMeta) o; return getChunkX() == that.getChunkX() && getChunkZ() == that.getChunkZ() && getPrimaryBitMask() == that.getPrimaryBitMask(); } @Override public int hashCode() { return Objects.hash(getChunkX(), getChunkZ(), getPrimaryBitMask()); } @Override public String toString() { return getClass().getName() + "{chunkX=" + getChunkX() + ", chunkZ=" + getChunkZ() + ", primaryBitMask=" + getPrimaryBitMask() + '}'; } }
47c957ede5f1b0f4cea76604cd2a48973fff14f4
{ "blob_id": "47c957ede5f1b0f4cea76604cd2a48973fff14f4", "branch_name": "refs/heads/master", "committer_date": "2017-05-10T14:01:46", "content_id": "ebfa97ff1ef276884a6a5873dec55b512ad23232", "detected_licenses": [ "Apache-2.0" ], "directory_id": "8afc2ab1ade3a591538ee864716a920eb6a67759", "extension": "java", "filename": "BaseChunkMeta.java", "fork_events_count": 2, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 81938265, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 2533, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/main/java/io/lunamc/protocol/packet/data/BaseChunkMeta.java", "provenance": "stack-edu-0027.json.gz:149269", "repo_name": "LunaMC/protocol", "revision_date": "2017-05-10T14:01:46", "revision_id": "645c50a6c73a32cf4240bb8e7365ed9c323e8807", "snapshot_id": "a3c07b0d3390e99c7b228f7dfe8f075c3901e3bb", "src_encoding": "UTF-8", "star_events_count": 8, "url": "https://raw.githubusercontent.com/LunaMC/protocol/645c50a6c73a32cf4240bb8e7365ed9c323e8807/src/main/java/io/lunamc/protocol/packet/data/BaseChunkMeta.java", "visit_date": "2021-01-22T09:10:37.075554", "added": "2024-11-19T01:59:42.272430+00:00", "created": "2017-05-10T14:01:46", "int_score": 2, "score": 2.203125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0045.json.gz" }
# -*- coding: utf-8 -*- class AllFunction: def __init__(self): print("热更新成功") self.version = "0.2.1" # self.first() def first(self): print("加载 第一个 功能成功") return "加载 第一个 功能成功,修改部分内容" def second(self, x, y): print("加载 第二个 功能成功") return x * y def third(self): print("加载 第三个 功能成功")
3d70113cd9f0c2ec20fa0d350e43317e94d81f68
{ "blob_id": "3d70113cd9f0c2ec20fa0d350e43317e94d81f68", "branch_name": "refs/heads/master", "committer_date": "2019-10-08T06:59:54", "content_id": "ff48b89b4285017d734b4e8b9265c2393150ad44", "detected_licenses": [ "MIT" ], "directory_id": "a5630d4ef1189ca210af52f5d1b654b6e0e08136", "extension": "py", "filename": "myfunction.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 206762347, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 472, "license": "MIT", "license_type": "permissive", "path": "/HotUpdate/myfunction.py", "provenance": "stack-edu-0058.json.gz:291997", "repo_name": "cyndi088/SoftwareUpdateServer", "revision_date": "2019-10-08T06:59:54", "revision_id": "397c7d89e905504896be223816c021215c2f5776", "snapshot_id": "7b19e5c3b6c79b6193e9411b4f959e080559fa72", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/cyndi088/SoftwareUpdateServer/397c7d89e905504896be223816c021215c2f5776/HotUpdate/myfunction.py", "visit_date": "2020-07-21T05:29:56.957391", "added": "2024-11-19T02:41:58.077906+00:00", "created": "2019-10-08T06:59:54", "int_score": 3, "score": 2.515625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0076.json.gz" }
package edu.uic.cs.purposeful.mpg.target.binary; import java.util.BitSet; import java.util.LinkedHashSet; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.math3.util.MathUtils; import edu.uic.cs.purposeful.common.assertion.Assert; import edu.uic.cs.purposeful.mpg.common.Misc; import edu.uic.cs.purposeful.mpg.target.OptimizationTarget; import no.uib.cipr.matrix.DenseMatrix; import no.uib.cipr.matrix.DenseVector; import no.uib.cipr.matrix.Vector; import no.uib.cipr.matrix.sparse.LinkedSparseMatrix; public abstract class AbstractBinaryOptimizationTarget implements OptimizationTarget<BitSet, Pair<double[], LinkedSparseMatrix>> { public static final double BINARY_VALUE_ONE = 1.0; public static final double BINARY_VALUE_ZERO = 0.0; // we consider the whole training data as one instance, each y_i is one bit protected int totalNumOfBits; protected int totalNumOfFeatures; protected double[] goldenTagValues; private BitSet goldenPermutation; protected LinkedSparseMatrix featureMatrix; private Vector goldenFeatureValues; @Override public void initialize(Pair<double[], LinkedSparseMatrix> trainingData, boolean duringTraining) { this.goldenTagValues = trainingData.getLeft(); this.featureMatrix = trainingData.getRight(); this.totalNumOfBits = featureMatrix.numRows(); this.totalNumOfFeatures = featureMatrix.numColumns(); this.goldenPermutation = buildPermutationFromTagValues(goldenTagValues); if (duringTraining) { this.goldenFeatureValues = computeGoldenFeatureValues(); } } private Vector computeGoldenFeatureValues() { // 1 * #bits DenseMatrix goldTagValueVector = new DenseMatrix(1, totalNumOfBits, goldenTagValues, false); // 1 * #features double[] goldFeatureValues = new double[totalNumOfFeatures]; // (1 * #bits) * (#bits * #features) = (1 * #features) goldTagValueVector.mult(featureMatrix, new DenseMatrix(1, totalNumOfFeatures, goldFeatureValues, false)); return new DenseVector(goldFeatureValues, false); } @Override public double aggregateLagrangePotentials(BitSet minimizerAction, double[] lagrangePotentials) { double sum = 0.0; for (int index = minimizerAction.nextSetBit(0); index >= 0 && index < lagrangePotentials.length; index = minimizerAction.nextSetBit(index + 1)) { sum += lagrangePotentials[index]; } return sum; } @Override public double[] computeLagrangePotentials(double[] thetas) { double[] lagrangePotentials = new double[totalNumOfBits]; featureMatrix.mult(new DenseVector(thetas, false), new DenseVector(lagrangePotentials, false)); return lagrangePotentials; } @Override public BitSet getGoldenPermutation() { return goldenPermutation; } @Override public Vector getGoldenFeatureValues() { return goldenFeatureValues; } @Override public Vector computeExpectedFeatureValues(double[] probabilities, LinkedHashSet<BitSet> permutations) { double[] bitMarginalProbabilities = new double[totalNumOfBits]; int permutationIndex = 0; for (BitSet permutation : permutations) { double probability = probabilities[permutationIndex++]; if (Misc.roughlyEquals(probability, 0)) { continue; // permutation has no contribution, skip } for (int bitIndex = permutation.nextSetBit(0); bitIndex >= 0 && bitIndex < totalNumOfBits; bitIndex = permutation.nextSetBit(bitIndex + 1)) { bitMarginalProbabilities[bitIndex] += probability; } } double[] featureValueExpectations = new double[totalNumOfFeatures]; new DenseMatrix(1, totalNumOfBits, bitMarginalProbabilities, false).mult(featureMatrix, new DenseMatrix(1, totalNumOfFeatures, featureValueExpectations, false)); return new DenseVector(featureValueExpectations, false); } protected BitSet buildPermutationFromTagValues(double[] tagValues) { BitSet permutation = new BitSet(tagValues.length); for (int bitIndex = 0; bitIndex < tagValues.length; bitIndex++) { double goldTagValue = tagValues[bitIndex]; if (MathUtils.equals(goldTagValue, BINARY_VALUE_ONE)) { permutation.set(bitIndex); } else { Assert.isTrue(MathUtils.equals(goldTagValue, BINARY_VALUE_ZERO)); } } return permutation; } }
9ee44e9969e99dd1c83b8c1ac68d3b71069236d2
{ "blob_id": "9ee44e9969e99dd1c83b8c1ac68d3b71069236d2", "branch_name": "refs/heads/master", "committer_date": "2016-10-29T03:37:25", "content_id": "e72cd34463eb02b64d10a50d8b4c62a9bc6803dc", "detected_licenses": [ "Apache-2.0" ], "directory_id": "9c4b4990c4b783cb42b42522f4856b1f0ed97be0", "extension": "java", "filename": "AbstractBinaryOptimizationTarget.java", "fork_events_count": 1, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 64039259, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 4458, "license": "Apache-2.0", "license_type": "permissive", "path": "/mpg_java/src/main/java/edu/uic/cs/purposeful/mpg/target/binary/AbstractBinaryOptimizationTarget.java", "provenance": "stack-edu-0021.json.gz:530450", "repo_name": "hwang207/mpg_java", "revision_date": "2016-10-29T03:37:25", "revision_id": "4d2a2d481191860e14e11cc35ef3e02d342897c5", "snapshot_id": "2c6662603059c4715cad31370ee1e2f2ab27ccd1", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/hwang207/mpg_java/4d2a2d481191860e14e11cc35ef3e02d342897c5/mpg_java/src/main/java/edu/uic/cs/purposeful/mpg/target/binary/AbstractBinaryOptimizationTarget.java", "visit_date": "2021-01-09T20:23:08.237212", "added": "2024-11-18T21:37:01.195580+00:00", "created": "2016-10-29T03:37:25", "int_score": 2, "score": 2.265625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0039.json.gz" }
<?php namespace App\Services; use App\Contracts\EmailServiceInterface; use App\Models\EmailService; use Lib\Interspire\InterspireEMApi; use Illuminate\Contracts\Auth\Guard; use Exception; class InterspireService implements EmailServiceInterface { /** * Create a new service instance. * * @return void */ public function __construct( Guard $auth , EmailService $emailService ) { $this->auth = $auth; $this->emailService = $emailService; } /** * Get service name * * @var string * @access private */ private $serviceName = 'Interspire'; /** * Connect(save) API Key */ public function set_service_option($service, $value) { //$services = new EmailService; $this->emailService->user_id = $this->auth->id(); $this->emailService->service = $service; $this->emailService->value = json_encode($value); $this->emailService->active = 1; $this->emailService->save(); } /** * Get service options */ public function get_service_options( $user_id , $service_name) { return $this->emailService->where('service', $service_name)->where('user_id', $user_id )->lists('value'); } /** * Connect to email service. * * @param array $inputs * @return boolean */ public function connect( $inputs ) { try { $apiUsername = $inputs['intr_username'];//'demo'; $apiUsertoken = $inputs['intr_usertoken'];//'32c51279e0d7788d242ba7e8735af27c7bbe5e7c'; $apiPath = $inputs['intr_api_path'];//'http://emailmarketer.interspire-demo.com/xml.php'; //dd($apiPath); $api = new InterspireEMApi($apiPath, $apiUsername, $apiUsertoken); $response = $api->authentication->xmlApiTest(); if( $response->isError() ) { return ['status' => 'warning', 'message' => 'Access denied: Invalid credentials' ]; } $this->set_service_option($this->serviceName, ['intr_username' => $apiUsername, 'intr_usertoken' =>$apiUsertoken, 'intr_api_path' => $apiPath ] ); return ['status' => 'success', 'message' => 'You has been successfully connected.']; } catch (Exception $e) { return ['status' => 'warning', 'message' => 'Access denied: Invalid credentials' ]; } } /** * Get interspire Lists. * * @return array */ public function getList() { try { //require_once(app_path().'/lib/Interspire/InterspireEMApi.php'); $conf = self::get_service_options( \Auth::id() , $this->serviceName); $conf = json_decode($conf[0]); $api = new InterspireEMApi( $conf->intr_api_path, $conf->intr_username, $conf->intr_usertoken ); $lists_data = $api->lists->getLists(); $lists = []; foreach ($lists_data->item as $item) { $lists[$item->listid] = $item->name; } return $lists; } catch (Exception $e) { return $e->getMessage() ; } } /** * Add contact * * @return array */ public function add_contact( $user_id , $list_id, $contact_data ) { try { //require_once(app_path().'/lib/Interspire/InterspireEMApi.php'); $conf = self::get_service_options( $user_id , $this->serviceName); $conf = json_decode($conf[0]); $api = new InterspireEMApi( $conf->intr_api_path, $conf->intr_username, $conf->intr_usertoken ); $result = $api->subscribers->addSubscriberToList( $contact_data['email'], $list_id, $format = 'text', $confirmed = FALSE, ['1' => $contact_data['name']] ); if($result->isError()){ return ['status' => 'warning', 'message' => $result->getErrorMessage()]; } return ['status' => 'success', 'message' => 'You are successfully subscribed!!!']; } catch (Exception $e) { return ['status' => 'error', 'message' => $e->getMessage()]; } } }
60e910f75c99aa9e9565f33a753a164fae9ddd7a
{ "blob_id": "60e910f75c99aa9e9565f33a753a164fae9ddd7a", "branch_name": "refs/heads/master", "committer_date": "2020-04-25T08:32:44", "content_id": "7d77dc8eb91cc382dac29476c0a534343481e199", "detected_licenses": [ "MIT" ], "directory_id": "1d9d51efafe288557912b526ba3f1305114c6557", "extension": "php", "filename": "InterspireService.php", "fork_events_count": 1, "gha_created_at": "2020-04-24T11:03:48", "gha_event_created_at": "2023-04-19T18:27:10", "gha_language": "JavaScript", "gha_license_id": null, "github_id": 258488046, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 3865, "license": "MIT", "license_type": "permissive", "path": "/app/Services/InterspireService.php", "provenance": "stack-edu-0048.json.gz:894054", "repo_name": "zonvoirraghvendra/voicestak", "revision_date": "2020-04-25T08:32:44", "revision_id": "31160ef3ea5914f7d3a5bd24eb1b12c976119bd2", "snapshot_id": "5afbb86ca40d80ea8b953ba8e8f7b3bb46881293", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/zonvoirraghvendra/voicestak/31160ef3ea5914f7d3a5bd24eb1b12c976119bd2/app/Services/InterspireService.php", "visit_date": "2023-04-29T18:31:43.655273", "added": "2024-11-18T20:41:59.093414+00:00", "created": "2020-04-25T08:32:44", "int_score": 3, "score": 2.734375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0066.json.gz" }
<?php $__env->startSection('content'); ?> <span class="card-title">User</span> <hr> <table width="100%"> <tr> <td>Name: <?php echo e($user->full_name); ?></td> <td>Postal Code: <?php echo e($user->postal_code); ?></td> </tr> <tr> <td>Email: <?php echo e($user->email); ?></td> <td><address><span style="font-size: medium" id="reverse_geocoding"><?php echo e($address); ?></span></address></td> </tr> <tr> <td>Phone: <?php echo e($user->phone); ?></td> </tr> </table><br><br> <span class="card-title">Order </span><hr> <span style="font-size: medium">Status: <?php echo e($status); ?></span><br> <span> Note: <?php echo e($order->note); ?></span> <br><br><br> <div class="container"> <div class="card"> <?php $sum = 0; ?> <span class="card-title">Products</span><hr> <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> <?php $sum += $product->price * $product->quantity; ?> <span>Title: <?php echo e($product->title); ?></span><br> <span>Code: <?php echo e($product->code); ?></span><br> <span>Barcode: <?php echo e($product->barcode); ?></span><br> <span><?php echo e($product->quantity); ?> x <?php echo e($product->price); ?>&euro;</span> <hr> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?> <h3 class='right'>Total: <?php echo $sum; ?> </h3> </div> </div> <?php $__env->stopSection(); ?> <?php echo $__env->make('layouts.report', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?> <?php /* C:\Users\tajda\Desktop\software-project\resources\views/admin/report/order.blade.php */ ?>
a212a1499a386846be4718648c91220d173e7b14
{ "blob_id": "a212a1499a386846be4718648c91220d173e7b14", "branch_name": "refs/heads/master", "committer_date": "2019-06-11T04:51:07", "content_id": "d355e079cf9e764bef1fcd3e84fc3e17991c0610", "detected_licenses": [ "MIT" ], "directory_id": "3a25f5b965364a503ab6631618012f2209e5393d", "extension": "php", "filename": "ba944b9d4199e1297c74cca6d10dc8fa5ec4362d.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": 2132, "license": "MIT", "license_type": "permissive", "path": "/code/storage/framework/views/ba944b9d4199e1297c74cca6d10dc8fa5ec4362d.php", "provenance": "stack-edu-0050.json.gz:853908", "repo_name": "iotspace/B3Albania_OSMS", "revision_date": "2019-06-11T04:51:07", "revision_id": "c2c1d1bbe575b4379805278344f544484276d2ea", "snapshot_id": "1502d2d88e4836909839d57ca6d10fe408126b3f", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/iotspace/B3Albania_OSMS/c2c1d1bbe575b4379805278344f544484276d2ea/code/storage/framework/views/ba944b9d4199e1297c74cca6d10dc8fa5ec4362d.php", "visit_date": "2022-03-21T03:07:02.891940", "added": "2024-11-18T23:02:30.053397+00:00", "created": "2019-06-11T04:51:07", "int_score": 2, "score": 2.203125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0068.json.gz" }
class Outer { private void foo() {} class Inner extends Outer { { this.<error descr="'foo()' has private access in 'Outer'">foo</error>(); foo(); } } }
0204f1432bc7aa642922a5f8eaf026d49b7e0dd0
{ "blob_id": "0204f1432bc7aa642922a5f8eaf026d49b7e0dd0", "branch_name": "refs/heads/master", "committer_date": "2023-09-03T12:12:27", "content_id": "f50fb8a1e1c531905651abd248248f181329a919", "detected_licenses": [ "Apache-2.0" ], "directory_id": "eb9f655206c43c12b497c667ba56a0d358b6bc3a", "extension": "java", "filename": "ThisAsAccessObject.java", "fork_events_count": 6635, "gha_created_at": "2011-09-30T13:33:05", "gha_event_created_at": "2023-09-12T07:41:58", "gha_language": null, "gha_license_id": "Apache-2.0", "github_id": 2489216, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 201, "license": "Apache-2.0", "license_type": "permissive", "path": "/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ThisAsAccessObject.java", "provenance": "stack-edu-0021.json.gz:336260", "repo_name": "JetBrains/intellij-community", "revision_date": "2023-09-03T11:51:00", "revision_id": "05dbd4575d01a213f3f4d69aa4968473f2536142", "snapshot_id": "2ed226e200ecc17c037dcddd4a006de56cd43941", "src_encoding": "UTF-8", "star_events_count": 16288, "url": "https://raw.githubusercontent.com/JetBrains/intellij-community/05dbd4575d01a213f3f4d69aa4968473f2536142/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/ThisAsAccessObject.java", "visit_date": "2023-09-03T17:06:37.560889", "added": "2024-11-19T01:44:58.487360+00:00", "created": "2023-09-03T11:51:00", "int_score": 3, "score": 2.6875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0039.json.gz" }
#include <iostream> #include "cmath" #include "iomanip" using namespace std; int main() { double width, distance, costUnderWater, costOverLand, mostUnderWater, totalCost, lineUnderWater = 0.0, lineOverLand = 0.0, minCost=300000; const double CONVERSION=5280; cout<<"PLease Enter the Width of the River"<<endl; cin>>width; cout<<"width "<<width<<endl; cout<<"Please Enter the Distance of the factory plant downstream from the power plant"<<endl; cin>>distance; cout<<"distance "<<distance<<endl; cout<<"Please Enter the cost to run power line over land"<<endl; cin>>costOverLand; costOverLand= costOverLand*CONVERSION; cout<<"Cost per Mile Over Land "<<costOverLand<<endl; cout<<"Please Enter the cost to run power line under water "<<endl; cin>>costUnderWater; costUnderWater=costUnderWater*CONVERSION; cout<<"Cost per mile Under Water "<<costUnderWater<<endl; mostUnderWater=sqrt(width*width+distance*distance); cout<<"Most Line that can be placed under Water "<<mostUnderWater<<endl; double i, j ; for (j=width; j<=mostUnderWater; j=j+0.1) { for (i=distance; i>=0; i=i-0.1) { totalCost=(i*costOverLand+j*costUnderWater); if (totalCost< minCost && (i+j)>=mostUnderWater) { minCost=totalCost; lineUnderWater=j; lineOverLand=i; } } } cout<<"Most Line needed under Water "<< lineUnderWater<<endl; cout<<"Most Line needed over land "<<lineOverLand<<endl; cout<<"total minimum Cost "<<minCost<<endl; return 0; }
d23945b6fda974c7353dbc8cc2d43d267622751b
{ "blob_id": "d23945b6fda974c7353dbc8cc2d43d267622751b", "branch_name": "refs/heads/master", "committer_date": "2017-10-23T18:45:49", "content_id": "e0eb665c7f677f34d2d3f55c2d4b91c27f482842", "detected_licenses": [ "MIT" ], "directory_id": "9169ccb734eaa735e2d7991cd387e73dde335213", "extension": "cpp", "filename": "main.cpp", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 108023394, "is_generated": false, "is_vendor": false, "language": "C++", "length_bytes": 1657, "license": "MIT", "license_type": "permissive", "path": "/Feras Programming/ch 5 p 28 2/ch 5 p 28 2/main.cpp", "provenance": "stack-edu-0003.json.gz:56809", "repo_name": "Feras-Ahmed/class_projects", "revision_date": "2017-10-23T18:45:49", "revision_id": "3cc5bce47ddc94344774458b306d89aac65bf1b6", "snapshot_id": "735974579f4b44ba4994f7fdcd2b8fefa269fd27", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Feras-Ahmed/class_projects/3cc5bce47ddc94344774458b306d89aac65bf1b6/Feras Programming/ch 5 p 28 2/ch 5 p 28 2/main.cpp", "visit_date": "2021-05-15T09:13:57.808417", "added": "2024-11-18T22:38:30.903391+00:00", "created": "2017-10-23T18:45:49", "int_score": 3, "score": 3.125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0021.json.gz" }
package jp.co.tis.s2n.javaConverter.convert.statistics; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import jp.co.tis.s2n.converterCommon.statistics.StatisticsBase; /** * 統計情報を蓄積するツール。<br> * * このクラスはシングレトンである、 * スレッドセーフではないので単一スレッドからの利用を想定する。 * <br> * @author Fumihiko Yamamoto * */ public class S2JDBCStatistics { //シングレトン化 private static S2JDBCStatistics instance; private S2JDBCStatistics() { } /** * インスタンスを取得する。 * @return 唯一のインスタンスを返す */ public static S2JDBCStatistics getInstance() { if (instance == null) { instance = new S2JDBCStatistics(); } return instance; } /** * ログファイルのレコード定義(1行分)。 */ public class S2JDBCResultData { public String fileName; public String moduleName; public String result; public String line; public String nonSupportStatement; } private List<S2JDBCResultData> convdata = new ArrayList<S2JDBCResultData>(); /** S2JDBCResultData.resultのパラメータ*/ public static String RESULT_SUCCESS = "SUCCESS"; /** S2JDBCResultData.resultのパラメータ*/ public static String RESULT_NOTSUPPORTED = "NOTSUPPORTED"; /** S2JDBCResultData.resultのパラメータ*/ public static String RESULT_IGNORE = "IGNORE"; /** S2JDBCResultData.resultのパラメータ*/ public static String RESULT_ERROR = "ERROR"; /** * Annotationの処理結果。 * @param fileName 変換対象ファイル名 * @param moduleName 変換処理を行うモジュール * @param result 変換結果のパラメータ * @param line 該当行の文字列 * @param nonSupportStatement */ public void convertedAnnotation(String fileName, String moduleName, String result, String line, String nonSupportStatement) { S2JDBCResultData td = new S2JDBCResultData(); td.fileName = fileName; td.moduleName = moduleName; td.result = result; td.line = line; td.nonSupportStatement = (nonSupportStatement == null) ? "" : nonSupportStatement; convdata.add(td); } /** * CSVファイルに書き出す。 * @throws IOException 例外 * @throws IllegalAccessException 例外 */ public void exportData() throws IOException, IllegalAccessException { File file = new File("logs/s2jdbcConvertResult.csv"); StatisticsBase.exportCollection2Csv(file, convdata); } }
6848f6c8355d9c1307c91014e019754c63e4bd3e
{ "blob_id": "6848f6c8355d9c1307c91014e019754c63e4bd3e", "branch_name": "refs/heads/master", "committer_date": "2021-03-30T10:32:25", "content_id": "93b4d1bb16406dda2401959004cb2085f12981dd", "detected_licenses": [ "Apache-2.0" ], "directory_id": "89d0ba81bb48b6d9bc868decd902965345435348", "extension": "java", "filename": "S2JDBCStatistics.java", "fork_events_count": 0, "gha_created_at": "2020-08-31T07:10:12", "gha_event_created_at": "2021-03-30T10:32:25", "gha_language": "Java", "gha_license_id": "Apache-2.0", "github_id": 291641914, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 2866, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/main/java/jp/co/tis/s2n/javaConverter/convert/statistics/S2JDBCStatistics.java", "provenance": "stack-edu-0028.json.gz:370114", "repo_name": "oscana/oscana-s2n-javaconverter", "revision_date": "2021-03-30T10:32:25", "revision_id": "7aa672cbfb4fefa973632dabca1d43d011bc60ab", "snapshot_id": "75cd6ad8c4e2eec9c9bd59259789dcf357a7df64", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/oscana/oscana-s2n-javaconverter/7aa672cbfb4fefa973632dabca1d43d011bc60ab/src/main/java/jp/co/tis/s2n/javaConverter/convert/statistics/S2JDBCStatistics.java", "visit_date": "2023-03-31T15:37:00.802181", "added": "2024-11-18T22:04:33.623600+00:00", "created": "2021-03-30T10:32:25", "int_score": 3, "score": 2.546875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0046.json.gz" }
require "./app/snakePoint.rb" class SnakePoints<Array def initialize() self.addSnakePoint(SnakePoint.new(25,4)) self.addSnakePoint(SnakePoint.new(40,12)) self.addSnakePoint(SnakePoint.new(58,35)) self.addSnakePoint(SnakePoint.new(88,55)) self.addSnakePoint(SnakePoint.new(95,44)) end def addSnakePoint(snakePoint) self << snakePoint end def findSnakeEndPoint(point) self.each do |snakePoint| return snakePoint.endPoint if snakePoint.startPoint == point end return 0 end end
3da44f283b0d9635fe1f2eac6c29b97b60229d23
{ "blob_id": "3da44f283b0d9635fe1f2eac6c29b97b60229d23", "branch_name": "refs/heads/master", "committer_date": "2013-09-04T06:12:50", "content_id": "5c736568bdd4f2270500dff0c01f2c76d5ec0247", "detected_licenses": [ "Apache-2.0" ], "directory_id": "8e261641b3db9d4dafd3158334fadb19e0c840f7", "extension": "rb", "filename": "snakePoints.rb", "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": "Ruby", "length_bytes": 538, "license": "Apache-2.0", "license_type": "permissive", "path": "/SnakeAndLadder/app/snakePoints.rb", "provenance": "stack-edu-0066.json.gz:252361", "repo_name": "safad-tw/Projects", "revision_date": "2013-09-04T06:12:50", "revision_id": "9b50015f3fe65ea45aa5bad5ca2364b5d07e69d3", "snapshot_id": "347a49a0f8465084ae2139dc1f34db9af4971162", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/safad-tw/Projects/9b50015f3fe65ea45aa5bad5ca2364b5d07e69d3/SnakeAndLadder/app/snakePoints.rb", "visit_date": "2016-09-06T20:17:28.620511", "added": "2024-11-19T03:35:28.721755+00:00", "created": "2013-09-04T06:12:50", "int_score": 3, "score": 2.640625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0084.json.gz" }
import { addPrototype } from "../../utils"; import method from "./method"; declare global { interface Array<T> { intersect(array: any[]): T[]; } } /** * Returns a list of elements that exist in both arrays * @memberof Array.prototype * @function intersect * @param {Array} array * @returns {Array} * @example * [1, 2, 3].intersect([4, 3, 2]); // [2,3] */ addPrototype(Array, "intersect", method);
98048c1a5a9b0e9501aef801d5a1bced8f8d7f8e
{ "blob_id": "98048c1a5a9b0e9501aef801d5a1bced8f8d7f8e", "branch_name": "refs/heads/master", "committer_date": "2019-06-05T20:38:12", "content_id": "3cac9fca798fbd177d1d31f0e60bb1e42ac7ac74", "detected_licenses": [ "MIT" ], "directory_id": "855add33aa598a1d3387163f22a900441b8d11b7", "extension": "ts", "filename": "index.ts", "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": "TypeScript", "length_bytes": 415, "license": "MIT", "license_type": "permissive", "path": "/src/array/intersect/index.ts", "provenance": "stack-edu-0075.json.gz:282358", "repo_name": "Matrixbirds/prototyped.js", "revision_date": "2019-06-05T20:38:12", "revision_id": "bdd34f617ad436bbeffe19e1b0fe8795cbaedd78", "snapshot_id": "dcb64799a1f38b7402b832df27c9080c9345350a", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Matrixbirds/prototyped.js/bdd34f617ad436bbeffe19e1b0fe8795cbaedd78/src/array/intersect/index.ts", "visit_date": "2020-06-17T16:59:08.497969", "added": "2024-11-18T23:47:05.800592+00:00", "created": "2019-06-05T20:38:12", "int_score": 4, "score": 3.5, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0093.json.gz" }
<?php namespace App\Services; use App\Models\OpenLesson; use App\Models\OpenLessonImage; use App\Http\AmazonApi; class OpenLessonService { /** * Create a new center service instance. */ public function __construct(OpenLesson $openLesson, OpenLessonImage $openLessonImage, AmazonApi $amazonApi) { $this->openLesson = $openLesson; $this->openLessonImage = $openLessonImage; $this->amazonApi = $amazonApi; } public function getAllLessons() { return $this->openLesson->get(); } public function getLessonById($id) { return $this->openLesson->find( $id ); } public function getLastSix() { return $this->openLesson->take(6)->get(); } public function update($id, $inputs) { return $this->openLesson->find($id)->update($inputs); } public function create($inputs) { if($inputs['images'][0] !== null){ $files = []; foreach ($inputs['images'] as $image) { $destinationPath = 'tmp'; $extension = $image->getClientOriginalExtension(); $fileName = rand(11111,99999).'.'.$extension; $files[] = $fileName; $image->move($destinationPath, $fileName); $this->amazonApi->store('open-lessons/'.$fileName, $destinationPath.'/'.$fileName); \File::delete($destinationPath.'/'.$fileName); } if(null!== $openLesson = $this->openLesson->create($inputs)){ foreach($files as $file){ $this->openLessonImage->create(['open_lesson_id' => $openLesson->id, 'image_url' => '/open-lessons/'.$file]); } } }else{ $openLesson = $this->openLesson->create($inputs); } return $openLesson; } public function delete($id) { $openLesson = $this->openLesson->find($id); if( $openLesson->images()->count() > 0 ){ $openLesson->images()->delete(); } return $openLesson->delete(); } }
52bc3ad7c5d85e0b7045c71af4b831283c872944
{ "blob_id": "52bc3ad7c5d85e0b7045c71af4b831283c872944", "branch_name": "refs/heads/master", "committer_date": "2016-03-27T23:42:36", "content_id": "7a2a65d95bb08be519ec0e869c8d2e30c10ee3a1", "detected_licenses": [ "MIT" ], "directory_id": "458ef6d2444e4ec52f0f684b3efcc69f4bc279e7", "extension": "php", "filename": "OpenLessonService.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 53623374, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 1845, "license": "MIT", "license_type": "permissive", "path": "/app/Services/OpenLessonService.php", "provenance": "stack-edu-0050.json.gz:140811", "repo_name": "vahag95/arinj", "revision_date": "2016-03-27T23:42:36", "revision_id": "1cc9277f8a23b870c566270109b4530884782bf3", "snapshot_id": "20ade4ecc9c6e68b96eec3e4c46e4e19cf5acc69", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/vahag95/arinj/1cc9277f8a23b870c566270109b4530884782bf3/app/Services/OpenLessonService.php", "visit_date": "2021-01-10T02:08:00.197723", "added": "2024-11-18T22:44:22.340307+00:00", "created": "2016-03-27T23:42:36", "int_score": 3, "score": 2.640625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0068.json.gz" }
LINE Pay API Tools ================== <img src="https://raw.githubusercontent.com/yidas/line-pay-sdk-php/master/img/sample-index-desktop.png" height="500" /><img src="https://raw.githubusercontent.com/yidas/line-pay-sdk-php/master/img/sample-index-mobile.png" height="500" /> FEATURES -------- *1. **No database** required.* *2. **Saving config with authentication** by session for payment processes and next order.* *3. **View Logs, Merchants Setting** feature.* *4. **Offline OTK pay, Pre-Approved, Transaction Search** functions* --- INSTALLATION ------------ Download repository and run Composer install in your Web directory: ``` git clone https://github.com/yidas/line-pay-sdk-php.git; cd line-pay-sdk-php; composer install; ``` Then you can access the sample site from `https://{yourweb-dir}/line-pay-sdk-php/tool`. --- FLOW ---- Payment flow: [Request](https://github.com/yidas/line-pay-sdk-php/tree/v3#request-api) -> [Confirm](https://github.com/yidas/line-pay-sdk-php/tree/v3#confirm-api) / [Details](https://github.com/yidas/line-pay-sdk-php/tree/v3#payment-details-api) -> [Refund](https://github.com/yidas/line-pay-sdk-php/tree/v3#refund-api) --- MERCHANTS SETTING ----------------- You can save your favorite or test LINE Pay merchant account for display and selection on the sample page. To enable the setting, create `tool/_merchants.php` file (Under `tool` folder) using the following PHP array format: ```php <?php return [ [ "title" => "First Merchant", "channelId" => "{your channelId}", "channelSecret" => "{your channelSecret}", ], [ "title" => "Second Merchant", "channelId" => "{your channelId}", "channelSecret" => "{your channelSecret}", ], ]; ``` > Warning: Saved merchants will be operated by the tool through the API with the merchant credentials, please add the sandbox merchant account only.
47fab36ac245e5d9fe0b149e90a5269d83a22b69
{ "blob_id": "47fab36ac245e5d9fe0b149e90a5269d83a22b69", "branch_name": "refs/heads/master", "committer_date": "2023-08-07T06:34:40", "content_id": "813fb59986b46a236e9ea3baf2ad9fedd244a8f2", "detected_licenses": [ "MIT" ], "directory_id": "5bf54026b0b393cd99f4e7e6164f59d82b2ce051", "extension": "md", "filename": "README.md", "fork_events_count": 35, "gha_created_at": "2019-05-16T15:25:42", "gha_event_created_at": "2022-06-08T08:23:30", "gha_language": "PHP", "gha_license_id": "MIT", "github_id": 187054117, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 1915, "license": "MIT", "license_type": "permissive", "path": "/tool/README.md", "provenance": "stack-edu-markdown-0004.json.gz:31652", "repo_name": "yidas/line-pay-sdk-php", "revision_date": "2023-08-07T06:34:40", "revision_id": "22e41c710c4d565aba201ff2cdebe0a7d8fd8a74", "snapshot_id": "0df4589791bd477148317cf72486751f906823fb", "src_encoding": "UTF-8", "star_events_count": 76, "url": "https://raw.githubusercontent.com/yidas/line-pay-sdk-php/22e41c710c4d565aba201ff2cdebe0a7d8fd8a74/tool/README.md", "visit_date": "2023-08-17T09:49:34.622299", "added": "2024-11-18T23:41:59.610880+00:00", "created": "2023-08-07T06:34:40", "int_score": 3, "score": 3.265625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0004.json.gz" }
// Copyright (c) Six Labors. // Licensed under the Apache License, Version 2.0. namespace SixLabors.ImageSharp.Formats.Webp { /// <summary> /// Image decoder options for generating an image out of a webp stream. /// </summary> internal interface IWebpDecoderOptions { /// <summary> /// Gets a value indicating whether the metadata should be ignored when the image is being decoded. /// </summary> bool IgnoreMetadata { get; } } }
d4e64ee8cd2a1633b4986e60ec60647a59a42e26
{ "blob_id": "d4e64ee8cd2a1633b4986e60ec60647a59a42e26", "branch_name": "refs/heads/master", "committer_date": "2021-11-11T13:15:41", "content_id": "7bd78da3da662c10d7eab41e75fa12910348adba", "detected_licenses": [ "Apache-2.0" ], "directory_id": "86e4011b5e9db7edfc11761031f9a7bc779d0e3e", "extension": "cs", "filename": "IWebpDecoderOptions.cs", "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": "C#", "length_bytes": 487, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/ImageSharp/Formats/Webp/IWebpDecoderOptions.cs", "provenance": "stack-edu-0013.json.gz:519645", "repo_name": "ewdlop/ImageSharp", "revision_date": "2021-11-11T13:15:41", "revision_id": "21d95a70b0e935a231a830f4ada2a1ee29f0db86", "snapshot_id": "300f7b3720b8564f9a1b488301af32c53db5e801", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/ewdlop/ImageSharp/21d95a70b0e935a231a830f4ada2a1ee29f0db86/src/ImageSharp/Formats/Webp/IWebpDecoderOptions.cs", "visit_date": "2023-09-05T15:24:06.925581", "added": "2024-11-19T00:59:11.028533+00:00", "created": "2021-11-11T13:15:41", "int_score": 2, "score": 2, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0031.json.gz" }
package net.ttddyy.dsproxy.listener; import net.ttddyy.dsproxy.ExecutionInfo; import net.ttddyy.dsproxy.QueryInfo; import net.ttddyy.dsproxy.StatementType; import java.util.*; /** * @author Tadaya Tsuyukubo * @since 1.3 */ public class DefaultQueryLogEntryCreator implements QueryLogEntryCreator { protected static final Map<Character, String> JSON_SPECIAL_CHARS = new HashMap<Character, String>(); static { JSON_SPECIAL_CHARS.put('"', "\\\""); // quotation mark JSON_SPECIAL_CHARS.put('\\', "\\\\"); // reverse solidus JSON_SPECIAL_CHARS.put('/', "\\/"); // solidus JSON_SPECIAL_CHARS.put('\b', "\\b"); // backspace JSON_SPECIAL_CHARS.put('\f', "\\f"); // formfeed JSON_SPECIAL_CHARS.put('\n', "\\n"); // newline JSON_SPECIAL_CHARS.put('\r', "\\r"); // carriage return JSON_SPECIAL_CHARS.put('\t', "\\t"); // horizontal tab } @Override public String getLogEntry(ExecutionInfo execInfo, List<QueryInfo> queryInfoList, boolean writeDataSourceName) { final StringBuilder sb = new StringBuilder(); if (writeDataSourceName) { String name = execInfo.getDataSourceName(); sb.append("Name:"); sb.append(name == null ? "" : name); sb.append(", "); } sb.append("Time:"); sb.append(execInfo.getElapsedTime()); sb.append(", "); sb.append("Success:"); sb.append(execInfo.isSuccess() ? "True" : "False"); sb.append(", "); sb.append("Type:"); sb.append(getStatementType(execInfo.getStatementType())); sb.append(", "); sb.append("Batch:"); sb.append(execInfo.isBatch() ? "True" : "False"); sb.append(", "); sb.append("QuerySize:"); sb.append(queryInfoList.size()); sb.append(", "); sb.append("BatchSize:"); sb.append(execInfo.getBatchSize()); sb.append(", "); sb.append("Query:["); for (QueryInfo queryInfo : queryInfoList) { sb.append("\""); sb.append(queryInfo.getQuery()); sb.append("\","); } chompIfEndWith(sb, ','); sb.append("], "); sb.append("Params:["); for (QueryInfo queryInfo : queryInfoList) { for (Map<String, Object> paramMap : queryInfo.getQueryArgsList()) { // sort SortedMap<String, Object> sortedParamMap = new TreeMap<String, Object>(new StringAsIntegerComparator()); sortedParamMap.putAll(paramMap); sb.append("("); for (Map.Entry<String, Object> paramEntry : sortedParamMap.entrySet()) { sb.append(paramEntry.getKey()); sb.append("="); sb.append(paramEntry.getValue()); sb.append(","); } chompIfEndWith(sb, ','); sb.append("),"); } } chompIfEndWith(sb, ','); sb.append("]"); return sb.toString(); } @Override public String getLogEntryAsJson(ExecutionInfo execInfo, List<QueryInfo> queryInfoList, boolean writeDataSourceName) { StringBuilder sb = new StringBuilder(); sb.append("{"); if (writeDataSourceName) { String name = execInfo.getDataSourceName(); sb.append("\"name\":\""); sb.append(name == null ? "" : escapeSpecialCharacterForJson(name)); sb.append("\", "); } sb.append("\"time\":"); sb.append(execInfo.getElapsedTime()); sb.append(", "); sb.append("\"success\":"); sb.append(execInfo.isSuccess() ? "true" : "false"); sb.append(", "); sb.append("\"type\":\""); sb.append(getStatementType(execInfo.getStatementType())); sb.append("\", "); sb.append("\"batch\":"); sb.append(execInfo.isBatch() ? "true" : "false"); sb.append(", "); sb.append("\"querySize\":"); sb.append(queryInfoList.size()); sb.append(", "); sb.append("\"batchSize\":"); sb.append(execInfo.getBatchSize()); sb.append(", "); sb.append("\"query\":["); for (QueryInfo queryInfo : queryInfoList) { sb.append("\""); sb.append(escapeSpecialCharacterForJson(queryInfo.getQuery())); sb.append("\","); } chompIfEndWith(sb, ','); sb.append("], "); sb.append("\"params\":["); for (QueryInfo queryInfo : queryInfoList) { for (Map<String, Object> paramMap : queryInfo.getQueryArgsList()) { // sort SortedMap<String, Object> sortedParamMap = new TreeMap<String, Object>(new StringAsIntegerComparator()); sortedParamMap.putAll(paramMap); sb.append("{"); for (Map.Entry<String, Object> paramEntry : sortedParamMap.entrySet()) { String key = paramEntry.getKey(); Object value = paramEntry.getValue(); sb.append("\""); sb.append(escapeSpecialCharacterForJson(key)); sb.append("\":"); if (value == null) { sb.append("null"); } else { sb.append("\""); sb.append(escapeSpecialCharacterForJson(value.toString())); sb.append("\""); } sb.append(","); } chompIfEndWith(sb, ','); sb.append("},"); } } chompIfEndWith(sb, ','); sb.append("]"); sb.append("}"); return sb.toString(); } protected String getStatementType(StatementType statementType) { if (StatementType.STATEMENT.equals(statementType)) { return "Statement"; } else if (StatementType.PREPARED.equals(statementType)) { return "Prepared"; } else if (StatementType.CALLABLE.equals(statementType)) { return "Callable"; } return "Unknown"; } protected void chompIfEndWith(StringBuilder sb, char c) { final int lastCharIndex = sb.length() - 1; if (sb.charAt(lastCharIndex) == c) { sb.deleteCharAt(lastCharIndex); } } protected String escapeSpecialCharacterForJson(String input) { if (input == null) { return "null"; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); String value = JSON_SPECIAL_CHARS.get(c); sb.append(value != null ? value : c); } return sb.toString(); } /** * Comparator considering string as integer. * * When it has null, put it as first element(smaller). * If string cannot be parsed to integer, it compared as string. */ private static class StringAsIntegerComparator implements Comparator<String> { @Override public int compare(String left, String right) { // make null first if (left == null && right == null) { return 0; } if (left == null) { return -1; // right is greater } if (right == null) { return 1; // left is greater; } try { return Integer.compare(Integer.parseInt(left), Integer.parseInt(right)); } catch (NumberFormatException e) { return left.compareTo(right); // use String comparison } } } }
ab28d7c18bd9085241f9ec693063435765a54f3e
{ "blob_id": "ab28d7c18bd9085241f9ec693063435765a54f3e", "branch_name": "refs/heads/master", "committer_date": "2015-07-21T17:00:06", "content_id": "1b5bf58d164ad084e45181e29bbd7257a18236dc", "detected_licenses": [ "MIT" ], "directory_id": "059e150b43f7ebab90f76c5cc2b1d6b7b830026c", "extension": "java", "filename": "DefaultQueryLogEntryCreator.java", "fork_events_count": 0, "gha_created_at": "2015-07-20T17:21:04", "gha_event_created_at": "2015-07-20T17:21:04", "gha_language": null, "gha_license_id": null, "github_id": 39397826, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 7809, "license": "MIT", "license_type": "permissive", "path": "/src/main/java/net/ttddyy/dsproxy/listener/DefaultQueryLogEntryCreator.java", "provenance": "stack-edu-0022.json.gz:584291", "repo_name": "arthurdandrea/datasource-proxy", "revision_date": "2015-07-21T17:00:06", "revision_id": "d227cbe2f16cfb05b587c953dd79697aef481eb6", "snapshot_id": "e5b7a6a4c8b779f15e4fa80c58e013aee6d9d886", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/arthurdandrea/datasource-proxy/d227cbe2f16cfb05b587c953dd79697aef481eb6/src/main/java/net/ttddyy/dsproxy/listener/DefaultQueryLogEntryCreator.java", "visit_date": "2020-12-28T20:09:40.946977", "added": "2024-11-19T01:59:17.136508+00:00", "created": "2015-07-21T17:00:06", "int_score": 3, "score": 2.578125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0040.json.gz" }
package scraper import ( "io" "net/url" "strings" "github.com/PuerkitoBio/goquery" "go.uber.org/zap" ) func (s *Scraper) fixFileReferences(url *url.URL, buf io.Reader) (string, error) { g, err := goquery.NewDocumentFromReader(buf) if err != nil { return "", err } relativeToRoot := s.urlRelativeToRoot(url) g.Find("a").Each(func(_ int, selection *goquery.Selection) { s.fixQuerySelection(url, "href", selection, true, relativeToRoot) }) g.Find("link").Each(func(_ int, selection *goquery.Selection) { s.fixQuerySelection(url, "href", selection, false, relativeToRoot) }) g.Find("img").Each(func(_ int, selection *goquery.Selection) { s.fixQuerySelection(url, "src", selection, false, relativeToRoot) }) g.Find("script").Each(func(_ int, selection *goquery.Selection) { s.fixQuerySelection(url, "src", selection, false, relativeToRoot) }) return g.Html() } func (s *Scraper) fixQuerySelection(url *url.URL, attribute string, selection *goquery.Selection, linkIsAPage bool, relativeToRoot string) { src, ok := selection.Attr(attribute) if !ok { return } if strings.HasPrefix(src, "data:") { return } if strings.HasPrefix(src, "mailto:") { return } resolved := s.resolveURL(url, src, linkIsAPage, relativeToRoot) if src == resolved { // nothing changed return } s.log.Debug("HTML Element relinked", zap.String("URL", src), zap.String("Fixed", resolved)) selection.SetAttr(attribute, resolved) }
8f961e4c2257154b5c321b1bd48a38f342e1851e
{ "blob_id": "8f961e4c2257154b5c321b1bd48a38f342e1851e", "branch_name": "refs/heads/master", "committer_date": "2022-06-02T23:48:48", "content_id": "4ad1513b068bf2264c212975be009ceb8131859f", "detected_licenses": [ "MIT" ], "directory_id": "669bd11d907ef993fb1cf3e7eda4c43a7345a179", "extension": "go", "filename": "html.go", "fork_events_count": 0, "gha_created_at": "2019-12-22T08:37:41", "gha_event_created_at": "2019-12-22T08:37:41", "gha_language": null, "gha_license_id": "MIT", "github_id": 229539979, "is_generated": false, "is_vendor": false, "language": "Go", "length_bytes": 1454, "license": "MIT", "license_type": "permissive", "path": "/scraper/html.go", "provenance": "stack-edu-0015.json.gz:439951", "repo_name": "motorox/goscrape", "revision_date": "2022-06-02T23:48:48", "revision_id": "492d965c874bb56b5cd92ab20224babe130d9716", "snapshot_id": "19a7796d131ff5772f92a05a4ccff05ffab427be", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/motorox/goscrape/492d965c874bb56b5cd92ab20224babe130d9716/scraper/html.go", "visit_date": "2022-09-16T10:45:02.685824", "added": "2024-11-18T23:56:35.735424+00:00", "created": "2022-06-02T23:48:48", "int_score": 3, "score": 2.65625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0033.json.gz" }
package com.zhenghao.admin.server.annotation; import com.zhenghao.admin.common.enums.LogTypeEnum; import java.lang.annotation.*; /** * 系统日志注解 * * @SysLog("里面写内容,必须赋值到value属性中") author:zhaozhenghao * Email :736720794@qq.com * date :2017年11月20日 * SysLog.java */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface SysLog { String value() default ""; LogTypeEnum type() default LogTypeEnum.OPERATION; } /** * @Target说明了Annotation所修饰的对象范围: Annotation可被用于 packages、types(类、接口、枚举、Annotation类型) * 、类型成员(方法、构造方法、成员变量、枚举值)、方法参数和本地变量(如循环变量、catch参数)。 * 在Annotation类型的声明中使用了target可更加明晰其修饰的目标。 * 作用:用于描述注解的使用范围(即:被描述的注解可以用在什么地方) * 取值(ElementType)有: * <p> *     1.CONSTRUCTOR:用于描述构造器 *     2.FIELD:用于描述域 *     3.LOCAL_VARIABLE:用于描述局部变量 *     4.METHOD:用于描述方法 *     5.PACKAGE:用于描述包 *     6.PARAMETER:用于描述参数 *     7.TYPE:用于描述类、接口(包括注解类型) 或enum声明 * @Retention定义了该Annotation被保留的时间长短:某些Annotation仅出现在源代码中, 而被编译器丢弃;而另一些却被编译在class文件中;编译在class文件中的Annotation可能会被虚拟机忽略, * 而另一些在class被装载时将被读取(请注意并不影响class的执行,因为Annotation与class在使用上是被分离的)。 * 使用这个meta-Annotation可以对 Annotation的“生命周期”限制。 * <p> * 作用:表示需要在什么级别保存该注释信息,用于描述注解的生命周期(即:被描述的注解在什么范围内有效) *  取值(RetentionPoicy)有: * <p> *     1.SOURCE:在源文件中有效(即源文件保留) *     2.CLASS:在class文件中有效(即class保留) *     3.RUNTIME:在运行时有效(即运行时保留) * <p> * <p> *  @Documented用于描述其它类型的annotation应该被作为被标注的程序成员的公共API, * 因此可以被例如javadoc此类的工具文档化。Documented是一个标记注解,没有成员。 */
86f490f973ffd947fae89bd56ddf8dcaac2de9fd
{ "blob_id": "86f490f973ffd947fae89bd56ddf8dcaac2de9fd", "branch_name": "refs/heads/master", "committer_date": "2021-10-25T14:26:23", "content_id": "96a1b544130745c2c7452cdc8fb65a495960d499", "detected_licenses": [ "MIT" ], "directory_id": "4351f8ce86d64ede4dd11f5a6161bcd283195cf7", "extension": "java", "filename": "SysLog.java", "fork_events_count": 3, "gha_created_at": "2018-12-13T15:01:27", "gha_event_created_at": "2021-08-23T21:06:34", "gha_language": "Java", "gha_license_id": "MIT", "github_id": 161654760, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 2490, "license": "MIT", "license_type": "permissive", "path": "/zh-admin-server/src/main/java/com/zhenghao/admin/server/annotation/SysLog.java", "provenance": "stack-edu-0027.json.gz:817848", "repo_name": "zhaozhenghao1993/zh-admin", "revision_date": "2021-10-25T14:26:23", "revision_id": "3b49857cd70a01e173eae836f23db2f8d61fa5d4", "snapshot_id": "8239e7b861c1b091147418a2212d7cc0659e5695", "src_encoding": "UTF-8", "star_events_count": 7, "url": "https://raw.githubusercontent.com/zhaozhenghao1993/zh-admin/3b49857cd70a01e173eae836f23db2f8d61fa5d4/zh-admin-server/src/main/java/com/zhenghao/admin/server/annotation/SysLog.java", "visit_date": "2021-11-06T15:29:36.663547", "added": "2024-11-18T23:36:31.902198+00:00", "created": "2021-10-25T14:26:23", "int_score": 3, "score": 2.890625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0045.json.gz" }
import styled from 'styled-components'; export const InputContainer = styled.div` /* width: 100vh; */ position: relative; /* margin-top: 1.4rem; */ label { font-size: 1.4rem; } input { width: 100%; height: 3.5rem; border-radius: 0.8rem; background: ${props => props.theme.colors.buttonText}; border: 1px solid #ddd; outline: 0; padding: 0 1.6rem; font: 1.6rem Archivo; /* &:focus-within::after { background: ${props => props.theme.colors.secondary}; } */ &:focus-within::after { width: calc(100% - 3.2rem); height: 2px; content: ''; background: ${props => props.theme.colors.secondary}; position: absolute; left: 1.6rem; right: 1.6rem; bottom: 0; } } .inputWithIcon { width: 100%; display: flex; align-items: center; border: 1px solid #ddd; border-radius: 0.8rem; i { cursor: pointer; margin-right: 1rem; .inputIcon { font-size: 1.5rem; color: #ddd; vertical-align: middle; transition: color 0.2s; &:hover { color: ${props => props.theme.colors.primary}; } } } input { //border: none; flex: 1; } } `;
dfa97c996e5393cda10a1c6e279366b21e9fea3b
{ "blob_id": "dfa97c996e5393cda10a1c6e279366b21e9fea3b", "branch_name": "refs/heads/main", "committer_date": "2021-06-29T20:47:11", "content_id": "27202ab04dafb7a94b65e79481b2dd1b80d450d4", "detected_licenses": [ "curl", "MIT" ], "directory_id": "8b36d1323d3700369f58ff42cee323afbad929e9", "extension": "ts", "filename": "InputContainer.ts", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 372712640, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 1273, "license": "curl,MIT", "license_type": "permissive", "path": "/exams/src/components/Input/InputContainer.ts", "provenance": "stack-edu-0075.json.gz:124022", "repo_name": "BravoNatalie/Exam_App", "revision_date": "2021-06-29T20:47:11", "revision_id": "f5038e16d080241a1bd4deb9b4f90c8be3114816", "snapshot_id": "24c7b68804467dee768a23625e45e8a01d38c313", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/BravoNatalie/Exam_App/f5038e16d080241a1bd4deb9b4f90c8be3114816/exams/src/components/Input/InputContainer.ts", "visit_date": "2023-06-12T22:14:40.136492", "added": "2024-11-19T00:35:07.798948+00:00", "created": "2021-06-29T20:47:11", "int_score": 2, "score": 2, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0093.json.gz" }
import { Injectable } from '@angular/core'; import { Blog } from '../models/blog'; import { User } from '../models/user'; import { AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database'; @Injectable() export class UserService { users: FirebaseListObservable<any[]>; currentUser: User; isLoggedIn: boolean = false; constructor(private database: AngularFireDatabase) { this.users = database.list('users'); } getUsers() { return this.users; } //to return an array of users that are contacts of the given user. getContacts(userKey: number){ var contacts = []; var users = []; contacts.push(this.users[userKey]) for(let i = 0; i <= 1; i ++){ if(contacts[i] === this.users[i]){ users.push(this.users) } } return users; } getCurrentUser() { return this.currentUser; } addUser(username: string,password: string) { let blogs = this.database.list('blogs'); var newBlog = new Blog(); newBlog.addPost('test description'); let blogKey = blogs.push(newBlog).key; let newUser = new User(username,password,[],[],blogKey); this.users.push(newUser); } }
0216f66cd3680b23a8c0f4241d49339de2ab56f0
{ "blob_id": "0216f66cd3680b23a8c0f4241d49339de2ab56f0", "branch_name": "refs/heads/master", "committer_date": "2018-09-18T22:49:06", "content_id": "2e861df952a440206ecb7753ae2a892b6da77fc3", "detected_licenses": [ "MIT" ], "directory_id": "e075254c5dc4d131fa10d5c17318ee1eabce13f2", "extension": "ts", "filename": "user.service.ts", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 146814184, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 1177, "license": "MIT", "license_type": "permissive", "path": "/src/app/services/user.service.ts", "provenance": "stack-edu-0076.json.gz:410530", "repo_name": "sonekase/OurChat", "revision_date": "2018-09-18T22:49:06", "revision_id": "8e0dec91a08b2f945f49efd75ef64aba426d18ef", "snapshot_id": "26d26bd67032d21e8b9b7529fcbb7435fe73f918", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/sonekase/OurChat/8e0dec91a08b2f945f49efd75ef64aba426d18ef/src/app/services/user.service.ts", "visit_date": "2020-03-27T16:54:08.688714", "added": "2024-11-18T22:11:08.250587+00:00", "created": "2018-09-18T22:49:06", "int_score": 3, "score": 2.59375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0094.json.gz" }
import React, { useEffect, useState } from 'react'; import ReactStars from 'react-rating-stars-component'; import StoreService from '../../services/store'; import { RightBar, Head, Body, Footer, EstablishmentItem, Title, Paragraph, } from './styles'; const NearestCoffees = (props) => { const [stores, setStores] = useState([]); useEffect(() => { loadNearstStores(); }, [props.latitude]); async function loadNearstStores() { const response = await StoreService.index(props.latitude, props.longitude); setStores(response.data); } return ( <RightBar> <Head> <h3>Find My Coffee</h3> </Head> ​ <Body> <strong>Mais amados na região</strong> <hr /> {stores.map((store) => { return ( <EstablishmentItem key={store.name}> <Title>{store.name}</Title>​<Paragraph>{store.address}</Paragraph> ​{store.ratings_count || 0} Opiniões <ReactStars edit={false} value={store.ratings_average || 0} /> <hr /> </EstablishmentItem> ); })} </Body> ​ <Footer> <h2>OneBitCode.com</h2> <Paragraph> Projeto Open Source desenvolvido na Semana Super Full Stack da escola online de programação </Paragraph> </Footer> </RightBar> ); }; export default NearestCoffees;
11fd1cec541a59d14a0372121904815f6db5e00c
{ "blob_id": "11fd1cec541a59d14a0372121904815f6db5e00c", "branch_name": "refs/heads/main", "committer_date": "2020-10-24T15:49:29", "content_id": "1d43d1ecd6e5705578f6eabdfbe1fe64c5c1bcad", "detected_licenses": [ "MIT" ], "directory_id": "1771eb4e762609bec7b51c916a3d1e0bbd33e715", "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": 305477061, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 1433, "license": "MIT", "license_type": "permissive", "path": "/find_my_coffee_web/src/components/NearestCoffees/index.js", "provenance": "stack-edu-0042.json.gz:8267", "repo_name": "lmaoclost/Find-My-Coffee", "revision_date": "2020-10-24T15:49:29", "revision_id": "258d5ffafd4e9ab5f05afc27627bf3169fdb3a42", "snapshot_id": "d0559357846dcd290ff06eec7a6f22dfae432b7f", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/lmaoclost/Find-My-Coffee/258d5ffafd4e9ab5f05afc27627bf3169fdb3a42/find_my_coffee_web/src/components/NearestCoffees/index.js", "visit_date": "2023-01-02T23:50:36.409551", "added": "2024-11-18T22:17:17.650999+00:00", "created": "2020-10-24T15:49:29", "int_score": 2, "score": 2.296875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0060.json.gz" }
# Reply Later This is a tool (still prototype) for buffering replies to tweets. To run this do the following ## Docker Instructions ## Install Docker For dev I run my docker containers inside a Vagrant box that exposes port 80 on the guest via port 8888 on the host. So if I want to go to localhost running inside the docker container while developing, I use localhost:8888. If this matches your setting: Run `docker pull spartakode/reply-later:dev` You can modify the port later by going into the docker container, going to /etc/nginx/sites-available and modifying the content If you are running on the standard port 80, Run `docker pull spartakode/reply-later:production` Run `docker tag spartakode/replaylater:<tag-you-pulled> replylater:app` Run `docker run -it -v /path/to/repo:/replylater -w /replylater --name replylater -p 80:80 replylater:app /bin/bash` Then `sudo service nginx start` ## Non docker instructions ## For this you'll need to install python3.5 (it should work on python3+ but I haven't tested so no guarantees) Then run `pip3.5 install requirements.txt` ## Common instructions ## Run the command `cron` Copy src/sampleconfig.ini to src/config.ini and src/sampletweetconfig.ini to src/tweetconfig.ini Create a Twitter app using https://apps.twitter.com/ and get your access tokens as well. Fill in tweetconfig.ini with the relevant values. Run python3.5 and use ``` import os os.geturandom(30) ``` We are using the value between the single quotes as a secret key. Open config.ini and replace the secret key value with the one you got from os.geturandom(30) Finally, `python3.5 -m serverstart.py` Visit your browser at localhost:<port-of-your-choice>/replylater/app And you should be up and running
2661aefcf909a5075ed96fac76f0828005e34b09
{ "blob_id": "2661aefcf909a5075ed96fac76f0828005e34b09", "branch_name": "refs/heads/master", "committer_date": "2016-06-13T03:11:46", "content_id": "e9327839e9bbf425bfdb3b3ec0eb291534d3b8f2", "detected_licenses": [ "MIT" ], "directory_id": "0f6afdb2e9f3c9b09471d59397d70ee52ecdce4d", "extension": "md", "filename": "README.md", "fork_events_count": 0, "gha_created_at": "2015-10-11T10:08:47", "gha_event_created_at": "2016-06-13T03:07:56", "gha_language": "Python", "gha_license_id": null, "github_id": 44047380, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 1744, "license": "MIT", "license_type": "permissive", "path": "/README.md", "provenance": "stack-edu-markdown-0008.json.gz:82236", "repo_name": "kiriappeee/reply-later", "revision_date": "2016-06-13T03:11:46", "revision_id": "127612345f64c8a75b38361156108e8383a634cb", "snapshot_id": "a6bb51d36d4bb5875ae28a2090a7da08aaa14ef3", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/kiriappeee/reply-later/127612345f64c8a75b38361156108e8383a634cb/README.md", "visit_date": "2021-01-21T04:47:06.873854", "added": "2024-11-19T00:21:29.166665+00:00", "created": "2016-06-13T03:11:46", "int_score": 3, "score": 3.359375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0008.json.gz" }
/* * Chaos * * Copyright 2015 Operating Systems Laboratory EPFL * * 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. */ #ifndef _BP_GRAPHCHI_NEW_ #define _BP_GRAPHCHI_NEW_ #include<sys/time.h> #include<sys/resource.h> #include<math.h> #include "../../core/x-lib.hpp" // Belief propagation using the technique of // Kung et. al. // Same implementation as that used by Kyrola et al. in their OSDI 2012 paper namespace algorithm { namespace belief_prop { namespace graphchi_new { struct bpchi_pcpu:public per_processor_data { unsigned long processor_id; // Stats unsigned long update_bytes_out; unsigned long update_bytes_in; unsigned long edge_bytes_streamed; unsigned long partitions_processed; // /* begin work specs. */ static unsigned long bsp_phase; static unsigned long current_step; /* end work specs. */ bool reduce(per_processor_data **per_cpu_array, unsigned long processors) { return false; } } __attribute__((__aligned__(64))); struct __attribute__((__packed__)) belief_propagation_graphchi_vertex { double logProdM0; double logProdM1; double belief0; // Avoid recomputing for every edge double belief1; // Avoid recomputing for every edge }; struct __attribute__((__packed__)) belief_propagation_graphchi_edge { vertex_t src; vertex_t dst; float msg; }; template<typename F> class belief_propagation_graphchi { const static unsigned long step_gen_edge_potential = 0; const static unsigned long step_init = 1; const static unsigned long step_absorb = 2; const static unsigned long step_rescale = 3; const static unsigned long step_emit = 4; const static unsigned long step_terminate = 5; unsigned long niters; static bpchi_pcpu ** pcpu_array; bool heartbeat; x_lib::streamIO<belief_propagation_graphchi> *graph_storage; unsigned long vertex_stream; unsigned long updates0_stream; unsigned long updates1_stream; unsigned long init_stream; rtc_clock wall_clock; rtc_clock setup_time; rtc_clock edge_potential_generation_time; unsigned long PHASE; unsigned long iters; static bool is_seed(unsigned long vid) { return (((17+vid)*3428971)%100 <= 1); } static bool is_good(unsigned long vid) { return (((17+vid)*3428971)%100 == 0); } static bool is_bad(unsigned long vid) { return (((17+vid)*3428971)%100 == 1); } static bool isnan(float x) { return !(x<0 || x>=0); } static double computePriorP0(unsigned long vid) { double priorP0 = 0.5; // Hack before we do actual seed selection if (is_bad(vid)) priorP0 = 0.95; // BAD else if (is_good(vid)) priorP0 = 0.05; // GOOD return priorP0; } public: belief_propagation_graphchi(); static void partition_pre_callback(unsigned long super_partition, unsigned long partition, per_processor_data* cpu_state); static void generate_initial_belief (unsigned char *edge, struct belief_propagation_graphchi_edge* be_fwd, struct belief_propagation_graphchi_edge* be_rev); static void partition_callback(x_lib::stream_callback_state *state); static void partition_post_callback(unsigned long super_partition, unsigned long partition, per_processor_data *cpu_state); static bool need_data_barrier() { return false; } class db_sync { public: void prep_db_data(per_processor_data **pcpu_array, unsigned long me, unsigned long processors) {} void finalize_db_data(per_processor_data **pcpu_array, unsigned long me, unsigned long processors) {} unsigned char *db_buffer() {return NULL;} unsigned long db_size() { return 0;} void db_generate() {} void db_merge() {} void db_absorb() {} }; static db_sync * get_db_sync() {return NULL;} static void vertex_apply(unsigned char *v, unsigned char *copy, unsigned long copy_machine, per_processor_data *per_cpu_data) { belief_propagation_graphchi_vertex *vtx = (belief_propagation_graphchi_vertex *)v; belief_propagation_graphchi_vertex *vtx_cpy = (belief_propagation_graphchi_vertex *)copy; vtx->logProdM0 += vtx_cpy->logProdM0; vtx->logProdM1 += vtx_cpy->logProdM1; } void operator() (); static unsigned long max_streams() { return 5; // vertices, edges, init_edges, updates0, updates1 } static unsigned long max_buffers() { return 4; } static unsigned long vertex_state_bytes() { return sizeof(struct belief_propagation_graphchi_vertex); } static unsigned long vertex_stream_buffer_bytes() { return sizeof(belief_propagation_graphchi_vertex) + sizeof(belief_propagation_graphchi_edge); } static void state_iter_callback(unsigned long superp, unsigned long partition, unsigned long index, unsigned char *vertex, per_processor_data *cpu_state) { belief_propagation_graphchi_vertex *v = (struct belief_propagation_graphchi_vertex *)vertex; if(bpchi_pcpu::current_step == step_init) { v->logProdM0 = 0.0; v->logProdM1 = 0.0; if(bpchi_pcpu::bsp_phase == 0) { v->belief0 = computePriorP0 (x_lib::configuration::map_inverse(superp, partition, index)); v->belief1 = 1.0 - v->belief0; } } else if(bpchi_pcpu::current_step == step_rescale) { // Rescale for numerical reasons (the larger one becomes zero) double maxM = std::max(v->logProdM0, v->logProdM1); v->logProdM0 -= maxM; v->logProdM1 -= maxM; // Compute beliefs double priorP0, priorP1; unsigned long vid = x_lib::configuration::map_inverse(superp, partition, index); if (!is_seed(vid)) { priorP0 = computePriorP0(vid); priorP1 = 1.0 - priorP0; v->belief0 = priorP0 * exp(v->logProdM0); v->belief1 = priorP1 * exp(v->logProdM1); if (v->belief0<1e-4) v->belief0 = 1e-4; // Do not let factors go to zero (for numerical reasons) if (v->belief1<1e-4) v->belief1 = 1e-4; // Do not let factors go to zero (for numerical reasons) // Normalize double norm = 1.0/(v->belief0+v->belief1); v->belief0 *= norm; v->belief1 *= norm; } BOOST_ASSERT_MSG(!isnan(v->belief0), "Belief0 went to NAN!"); } else { BOOST_LOG_TRIVIAL(fatal)<< "Unkown step in state iteration !"; exit(-1); } } static per_processor_data * create_per_processor_data(unsigned long processor_id) { return pcpu_array[processor_id]; } static void do_cpu_callback(per_processor_data *cpu_state) { bpchi_pcpu *cpu = static_cast<bpchi_pcpu *>(cpu_state); if(bpchi_pcpu::current_step == step_terminate) { BOOST_LOG_TRIVIAL(info)<< "CORE::PARTITIONS_PROCESSED " << cpu->partitions_processed; BOOST_LOG_TRIVIAL(info)<< "CORE::BYTES::EDGES_STREAMED " << cpu->edge_bytes_streamed; BOOST_LOG_TRIVIAL(info)<< "CORE::BYTES::UPDATES_OUT " << cpu->update_bytes_out; BOOST_LOG_TRIVIAL(info)<< "CORE::BYTES::UPDATES_IN " << cpu->update_bytes_in; } } static unsigned long checkpoint_size() { return 3*sizeof(unsigned long); } void take_checkpoint(unsigned char *buffer) { memcpy(buffer, &PHASE, sizeof(unsigned long)); buffer += sizeof(unsigned long); memcpy(buffer, &iters, sizeof(unsigned long)); buffer += sizeof(unsigned long); memcpy(buffer, &bpchi_pcpu::bsp_phase, sizeof(unsigned long)); } void restore_checkpoint(unsigned char *buffer) { memcpy(&PHASE, buffer, sizeof(unsigned long)); buffer += sizeof(unsigned long); memcpy(&iters, buffer, sizeof(unsigned long)); buffer += sizeof(unsigned long); memcpy(&bpchi_pcpu::bsp_phase, buffer, sizeof(unsigned long)); } }; template<typename F> belief_propagation_graphchi<F>::belief_propagation_graphchi() { wall_clock.start(); setup_time.start(); heartbeat = (vm.count("heartbeat") > 0); niters = vm["belief_propagation::niters"].as<unsigned long>(); unsigned long num_processors = vm["processors"].as<unsigned long>(); pcpu_array = new bpchi_pcpu *[num_processors]; for(unsigned long i=0;i<num_processors;i++) { pcpu_array[i] = new bpchi_pcpu(); pcpu_array[i]->processor_id = i; pcpu_array[i]->update_bytes_in = 0; pcpu_array[i]->update_bytes_out = 0; pcpu_array[i]->edge_bytes_streamed = 0; } graph_storage = new x_lib::streamIO<belief_propagation_graphchi>(); bpchi_pcpu::bsp_phase = 0; vertex_stream = slipstore::STREAM_VERTEX_STATE; std::string efile = pt.get<std::string>("graph.name"); init_stream = slipstore::STREAM_INPUT; updates0_stream = graph_storage->open_stream(); updates1_stream = graph_storage->open_stream(); setup_time.stop(); } template<typename F> struct init_edge_wrapper { static unsigned long item_size() { return F::split_size_bytes(); } static unsigned long key(unsigned char *buffer) { return F::split_key(buffer, 0); } }; struct belief_edge_wrapper { static unsigned long item_size() { return sizeof(struct belief_propagation_graphchi_edge); } static unsigned long key(unsigned char *buffer) { return ((struct belief_propagation_graphchi_edge *)buffer)->dst; } }; template<typename F> void belief_propagation_graphchi<F>::operator() () { bool restored = x_lib::load_checkpoint<belief_propagation_graphchi<F> > (graph_storage, this); // Generate edge potentials if(!restored) { edge_potential_generation_time.start(); bpchi_pcpu::current_step = step_gen_edge_potential; x_lib::do_init_stream< belief_propagation_graphchi<F>, init_edge_wrapper<F>, belief_edge_wrapper > (graph_storage, init_stream, updates0_stream); edge_potential_generation_time.stop(); // Supersteps PHASE = 0; iters = 0; graph_storage->rewind_stream(updates0_stream); if(vm.count("destroy_init") > 0) { graph_storage->reset_stream(init_stream, 0); } } while(restored || (iters < niters)) { if(!restored) { iters++; } unsigned long updates_in_stream; unsigned long updates_out_stream; if(!restored) { x_lib::take_checkpoint<belief_propagation_graphchi<F> > (graph_storage, this); } else { restored = false; } updates_in_stream = (PHASE == 0 ? updates1_stream:updates0_stream); updates_out_stream = (PHASE == 0 ? updates0_stream:updates1_stream); bpchi_pcpu::current_step = step_init; x_lib::do_state_iter<belief_propagation_graphchi<F> > (graph_storage); // Old interface // for(unsigned long i=0;i<graph_storage->get_config()->super_partitions;i++) { // graph_storage->state_load(i); // bpchi_pcpu::current_step = step_absorb; // x_lib::do_stream<belief_propagation_graphchi<F>, // belief_edge_wrapper, // belief_edge_wrapper > // (graph_storage, i, updates_in_stream, ULONG_MAX, NULL, true); // bpchi_pcpu::current_step = step_rescale; // x_lib::do_state_iter<belief_propagation_graphchi<F> > (graph_storage, i); // // need to replay the stream to determine updates // graph_storage->rewind_stream(updates_in_stream); // bpchi_pcpu::current_step = step_emit; // x_lib::do_stream<belief_propagation_graphchi<F>, // belief_edge_wrapper, // belief_edge_wrapper > // (graph_storage, i, updates_in_stream, updates_out_stream, NULL, false); // graph_storage->reset_stream(updates_in_stream, i); // graph_storage->state_store(i); // } bpchi_pcpu::current_step = step_absorb; x_lib::do_stream_skip<belief_propagation_graphchi<F>, belief_edge_wrapper, belief_edge_wrapper > (graph_storage, updates_in_stream, ULONG_MAX, NULL, true, false); bpchi_pcpu::current_step = step_rescale; x_lib::do_state_iter<belief_propagation_graphchi<F> > (graph_storage); bpchi_pcpu::current_step = step_emit; x_lib::do_stream_skip<belief_propagation_graphchi<F>, belief_edge_wrapper, belief_edge_wrapper > (graph_storage, updates_in_stream, updates_out_stream, NULL, false, true); graph_storage->rewind_stream(updates_out_stream); PHASE = 1 - PHASE; bpchi_pcpu::bsp_phase++; if(heartbeat) { BOOST_LOG_TRIVIAL(info) << clock::timestamp() << " Completed phase " << bpchi_pcpu::bsp_phase; } } bpchi_pcpu::current_step = step_terminate; x_lib::do_cpu<belief_propagation_graphchi<F> >(graph_storage, ULONG_MAX); setup_time.start(); graph_storage->terminate(); setup_time.stop(); wall_clock.stop(); BOOST_LOG_TRIVIAL(info) << "CORE::PHASES " << bpchi_pcpu::bsp_phase; setup_time.print("CORE::TIME::SETUP"); edge_potential_generation_time.print("CORE::TIME::EDGE_POT_GEN"); wall_clock.print("CORE::TIME::WALL"); } template<typename F> void belief_propagation_graphchi<F>::partition_pre_callback(unsigned long superp, unsigned long partition, per_processor_data *pcpu) { // Nothing } template<typename F> void belief_propagation_graphchi<F>::generate_initial_belief (unsigned char *edge, struct belief_propagation_graphchi_edge* be_fwd, struct belief_propagation_graphchi_edge *be_rev) { vertex_t src, dst; weight_t weight; F::read_edge(edge, src, dst, weight); be_fwd->src = src; be_fwd->dst = dst; be_fwd->msg = computePriorP0(src); be_rev->src = dst; be_rev->dst = src; be_rev->msg = computePriorP0(dst); } template<typename F> void belief_propagation_graphchi<F>::partition_callback (x_lib::stream_callback_state *callback) { const double EPSILON = 0.05; double PHI[2][2] = { {1-EPSILON, EPSILON}, {0.5, 0.5} }; bpchi_pcpu *pcpu = static_cast<bpchi_pcpu *>(callback->cpu_state); switch(bpchi_pcpu::current_step) { case step_gen_edge_potential: { unsigned long tmp = callback->bytes_in; while(callback->bytes_in) { if((callback->bytes_out + 2*sizeof(struct belief_propagation_graphchi_edge)) > callback->bytes_out_max) { break; } belief_propagation_graphchi_edge *e_fwd = (belief_propagation_graphchi_edge *) (callback->bufout + callback->bytes_out); belief_propagation_graphchi_edge *e_rev = (belief_propagation_graphchi_edge *) (callback->bufout + callback->bytes_out + sizeof(struct belief_propagation_graphchi_edge)); generate_initial_belief(callback->bufin, e_fwd, e_rev); callback->bytes_out += 2*sizeof(struct belief_propagation_graphchi_edge); callback->bufin += F::split_size_bytes(); callback->bytes_in -= F::split_size_bytes(); } pcpu->edge_bytes_streamed += (tmp - callback->bytes_in); break; } case step_absorb: { pcpu->update_bytes_in += callback->bytes_in; while(callback->bytes_in) { belief_propagation_graphchi_edge *u = (belief_propagation_graphchi_edge *)(callback->bufin); belief_propagation_graphchi_vertex *v = ((belief_propagation_graphchi_vertex *)(callback->state)) + x_lib::configuration::map_offset(u->dst); v->logProdM0 += log(u->msg); v->logProdM1 += log(1.0 - u->msg); callback->bufin += sizeof(struct belief_propagation_graphchi_edge); callback->bytes_in -= sizeof(struct belief_propagation_graphchi_edge); } break; } case step_emit: { while(callback->bytes_in) { if((callback->bytes_out + sizeof(belief_propagation_graphchi_edge)) > callback->bytes_out_max) { break; } BOOST_ASSERT_MSG(callback->bytes_out < callback->bytes_out_max, "Update buffer overflow !!!"); belief_propagation_graphchi_edge *ein = (belief_propagation_graphchi_edge *)(callback->bufin); belief_propagation_graphchi_edge *eout = (belief_propagation_graphchi_edge *)(callback->bufout); belief_propagation_graphchi_vertex *v = ((belief_propagation_graphchi_vertex *)(callback->state)) + x_lib::configuration::map_offset(ein->dst); eout->src = ein->dst; eout->dst = ein->src; double messageFrom0 = ein->msg; double message0 = v->belief0 * PHI[0][0] / messageFrom0 + v->belief1 * PHI[1][0]/(1-messageFrom0); double message1 = v->belief0 * PHI[0][1] / messageFrom0 + v->belief1 * PHI[1][1]/(1-messageFrom0); // Rescale message0 /= (message0+message1); // Normalization if (message0 < 1e-4) message0 = 1e-4; else if (message0 > 0.9999) message0 = 0.9999; eout->msg = message0; callback->bufin += sizeof(struct belief_propagation_graphchi_edge); callback->bufout += sizeof(struct belief_propagation_graphchi_edge); callback->bytes_in -= sizeof(struct belief_propagation_graphchi_edge); callback->bytes_out += sizeof(struct belief_propagation_graphchi_edge); } pcpu->update_bytes_out += callback->bytes_out; break; } default: BOOST_LOG_TRIVIAL(fatal) << "Unknown operation in stream callback !"; exit(-1); } } template<typename F> void belief_propagation_graphchi<F>::partition_post_callback(unsigned long superp, unsigned long partition, per_processor_data *pcpu) { bpchi_pcpu *pcpu_actual = static_cast<bpchi_pcpu *>(pcpu); pcpu_actual->partitions_processed++; } template<typename F> bpchi_pcpu ** belief_propagation_graphchi<F>::pcpu_array = NULL; unsigned long bpchi_pcpu::bsp_phase = 0; unsigned long bpchi_pcpu::current_step; } } } #endif
3df7f5084fa41b5f402bc37e471a314cc17dbdb9
{ "blob_id": "3df7f5084fa41b5f402bc37e471a314cc17dbdb9", "branch_name": "refs/heads/master", "committer_date": "2015-10-28T17:02:37", "content_id": "d0e49e6dc77a5a8c5833443876c0faac57e3cd16", "detected_licenses": [ "Apache-2.0" ], "directory_id": "6d95263ab7f825d8a5078a6345506abb8fc13f0a", "extension": "hpp", "filename": "bp_graphchi_new.hpp", "fork_events_count": 0, "gha_created_at": "2015-12-25T08:15:51", "gha_event_created_at": "2015-12-25T08:15:51", "gha_language": null, "gha_license_id": null, "github_id": 48572813, "is_generated": false, "is_vendor": false, "language": "C++", "length_bytes": 18047, "license": "Apache-2.0", "license_type": "permissive", "path": "/algorithms/belief_propagation/bp_graphchi_new.hpp", "provenance": "stack-edu-0004.json.gz:598257", "repo_name": "hmlv/chaos", "revision_date": "2015-10-28T17:01:27", "revision_id": "45c8de55192c651e25e068af7965562b9ff9df9e", "snapshot_id": "f689f79f609d3ef4ece2ee3ab4557a332dedf250", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/hmlv/chaos/45c8de55192c651e25e068af7965562b9ff9df9e/algorithms/belief_propagation/bp_graphchi_new.hpp", "visit_date": "2021-01-18T14:18:16.692058", "added": "2024-11-18T22:03:57.043600+00:00", "created": "2015-10-28T17:01:27", "int_score": 2, "score": 2.234375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0022.json.gz" }
package us.feras.mdv.demo; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class MainActivity extends Activity { /** Called when the activity is first created. */ Context context; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); context = this; Button mdDataButton = (Button) findViewById(R.id.locale_text_button); mdDataButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { context.startActivity(new Intent(context, MarkdownDataActivity.class)); } }); Button onlineMdButton = (Button) findViewById(R.id.online_md_button); onlineMdButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { context.startActivity(new Intent(context, OnlineMarkdownActivity.class)); } }); Button localeMdButton = (Button) findViewById(R.id.locale_md_button); localeMdButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { context.startActivity(new Intent(context, LocaleMarkdownActivity.class)); } }); } }
68a688006152e6efeec933ada820dd4791b0f9b6
{ "blob_id": "68a688006152e6efeec933ada820dd4791b0f9b6", "branch_name": "refs/heads/master", "committer_date": "2011-12-25T20:09:34", "content_id": "ef1d54ade9615d25354487c228ccf7f8ed2fc425", "detected_licenses": [ "Apache-2.0" ], "directory_id": "192014d672bdd01bf00ac7f66379214359511f7c", "extension": "java", "filename": "MainActivity.java", "fork_events_count": 2, "gha_created_at": "2011-12-29T22:14:31", "gha_event_created_at": "2012-10-06T16:26:41", "gha_language": null, "gha_license_id": null, "github_id": 3071398, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 1321, "license": "Apache-2.0", "license_type": "permissive", "path": "/MarkdownViewDemo/src/us/feras/mdv/demo/MainActivity.java", "provenance": "stack-edu-0029.json.gz:367308", "repo_name": "Gunio/MarkdownView", "revision_date": "2011-12-25T20:09:34", "revision_id": "6477ea7fb81e8fea9472a9bc2ee79f62789084c3", "snapshot_id": "f4cb8ba39dff439f055df8fbbd3493d62a14a295", "src_encoding": "UTF-8", "star_events_count": 15, "url": "https://raw.githubusercontent.com/Gunio/MarkdownView/6477ea7fb81e8fea9472a9bc2ee79f62789084c3/MarkdownViewDemo/src/us/feras/mdv/demo/MainActivity.java", "visit_date": "2020-12-25T13:07:27.229252", "added": "2024-11-18T23:09:55.152465+00:00", "created": "2011-12-25T20:09:34", "int_score": 2, "score": 2.109375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0047.json.gz" }
# SigningServer A simple server for code-signing binaries for internal infrastructure usage. If you work in a company with many teams it's sometimes hard to maintain code signing. Every team needs to sign their binaries as part of their build process and therefore need the certificate installed on their build servers. This software solves this issue by providing the code-signing as a service. You setup on a central signing server this software as a windows service and using the shipped client any other client can ask the central server to sign the files.
8252730e261320484096ac59cb59a4695e9186a1
{ "blob_id": "8252730e261320484096ac59cb59a4695e9186a1", "branch_name": "refs/heads/master", "committer_date": "2020-11-23T13:33:44", "content_id": "f4b2e2dfc6d4da4257eae7427b7b29d44c8e4b31", "detected_licenses": [ "MIT" ], "directory_id": "7d69b5565197591c9d91f5f2a0dd762b0ca1549a", "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": 565, "license": "MIT", "license_type": "permissive", "path": "/README.md", "provenance": "stack-edu-markdown-0000.json.gz:234896", "repo_name": "Crawping/SigningServer", "revision_date": "2020-11-23T12:00:12", "revision_id": "a26bee67acdb50289ee09ca418f657049ff54f22", "snapshot_id": "600a936b14ee537916e457431029df1c7f291867", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Crawping/SigningServer/a26bee67acdb50289ee09ca418f657049ff54f22/README.md", "visit_date": "2023-01-24T14:32:14.490457", "added": "2024-11-19T00:00:53.293152+00:00", "created": "2020-11-23T12:00:12", "int_score": 2, "score": 2.109375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0000.json.gz" }
#!/bin/bash # Purpose: Cleans up the MSSQL backups # Part of the LinuxMSSQL-Toolbox - https://github.com/Matticusau/LinuxMSSQL-Toolbox # Author: Matticusau / MLavery # Date: 19/06/2018 # Version: 0.1.0 # # Version When Who What # 0.1.0 20/06/2018 MLavery Initial version # # make sure you have execute rights # chmod +rwx backup_cleanup.sh # # schedule with a cron job # run "sudo crontab -u root -e" while logged in as the user with execute permissions on the script # use vi to add this line to schedule every 15 mins # 0 23 * * * /backup/backup_cleanup.sh > /dev/null 2>&1 # # settings FULL_BKP_DIR=/backup/full DIFF_BKP_DIR=/backup/diff TLOG_BKP_DIR=/backup/log FULL_BKP_RETENTION=14; DIFF_BKP_RETENTION=14; TLOG_BKP_RETENTION=1; # current time NOW=$(date +%Y_%m_%d_%H_%M_%S) echo -e "Clean up starting $(date +%Y_%m_%d_%H_%M_%S)"; # clean up full backups echo -e "Start cleanup process >> $NOW" >> $FULL_BKP_DIR/cleanup.log; CMD="find $FULL_BKP_DIR/*.bak -type f -mtime +$FULL_BKP_RETENTION" COUNT=$($CMD -printf '.' 2>/dev/null | wc -c); echo -e ">>> $COUNT Diff backups"; $($CMD -exec ls -lrt {} \; 2>/dev/null) >> $FULL_BKP_DIR/cleanup.log sudo $CMD -exec rm -f {} \; # clean up differential backups echo -e "Start cleanup process >> $NOW" >> $DIFF_BKP_DIR/cleanup.log; CMD="find $DIFF_BKP_DIR/*.bak -type f -mtime +$DIFF_BKP_RETENTION" COUNT=$($CMD -printf '.' 2>/dev/null | wc -c); echo -e ">>> $COUNT Diff backups"; $($CMD -exec ls -lrt {} \; 2>/dev/null) >> $DIFF_BKP_DIR/cleanup.log sudo $CMD -exec rm -f {} \; # clean up transaction log backups echo -e "Start cleanup process >> $NOW" >> $TLOG_BKP_DIR/cleanup.log; CMD="find $TLOG_BKP_DIR/*.trn -type f -mtime +$TLOG_BKP_RETENTION" COUNT=$($CMD -printf '.' 2>/dev/null | wc -c); echo -e ">>> $COUNT Transaction Log backups"; $($CMD -exec ls -lrt {} \; 2>/dev/null) >> $TLOG_BKP_DIR/cleanup.log sudo $CMD -exec rm -f {} \; echo -e "Clean up finished $(date +%Y_%m_%d_%H_%M_%S)";
41635fd12953e456bbc71e4f79924ba7d20c9d41
{ "blob_id": "41635fd12953e456bbc71e4f79924ba7d20c9d41", "branch_name": "refs/heads/master", "committer_date": "2018-11-19T06:10:42", "content_id": "c96fca2ed4e6b9edd0beace887d5af4dad8dcc08", "detected_licenses": [ "MIT" ], "directory_id": "eb5e65f071ec1eca6454db90bdb4f2680dbd189a", "extension": "sh", "filename": "backup_cleanup.sh", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 138246556, "is_generated": false, "is_vendor": false, "language": "Shell", "length_bytes": 1994, "license": "MIT", "license_type": "permissive", "path": "/Scripts/backup_cleanup.sh", "provenance": "stack-edu-0070.json.gz:161738", "repo_name": "Matticusau/LinuxMSSQL-Toolbox", "revision_date": "2018-11-19T06:10:42", "revision_id": "983ea9d8072b8e63c16247abb3c439f356ab4d77", "snapshot_id": "5dfd7f976df83dea2a4d9103e7946f76d3730b06", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/Matticusau/LinuxMSSQL-Toolbox/983ea9d8072b8e63c16247abb3c439f356ab4d77/Scripts/backup_cleanup.sh", "visit_date": "2020-03-21T06:52:34.584453", "added": "2024-11-19T00:32:31.353816+00:00", "created": "2018-11-19T06:10:42", "int_score": 4, "score": 3.71875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0088.json.gz" }
package com.kmecpp.jspark.compiler.tokenizer; public class LiteralToken extends Token { private Object value; public LiteralToken(int index, double decimal) { this(index, TokenType.DECIMAL_LITERAL, decimal); } public LiteralToken(int index, int integer) { this(index, TokenType.INTEGER_LITERAL, integer); } public LiteralToken(int index, boolean bool) { this(index, TokenType.BOOLEAN_LITERAL, bool); } public LiteralToken(int index, String string) { this(index, TokenType.STRING_LITERAL, string); } private LiteralToken(int index, TokenType type, Object value) { super(index, type, String.valueOf(value)); this.value = value; } public Object getValue() { return value; } }
cced93e268fc477dded6669e07310ccfbc5a739c
{ "blob_id": "cced93e268fc477dded6669e07310ccfbc5a739c", "branch_name": "refs/heads/master", "committer_date": "2018-05-08T00:17:49", "content_id": "611a36abfe301178a21e55f6aad630513f38a7dd", "detected_licenses": [ "MIT" ], "directory_id": "f4bd4a649a7ffc67f4de52b77c2d461907c1ba93", "extension": "java", "filename": "LiteralToken.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 109596125, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 741, "license": "MIT", "license_type": "permissive", "path": "/src/main/java/com/kmecpp/jspark/compiler/tokenizer/LiteralToken.java", "provenance": "stack-edu-0027.json.gz:380112", "repo_name": "kmecpp/JSpark", "revision_date": "2018-05-08T00:17:49", "revision_id": "27f70839adabdb9477a1bcbf638a4008efc50f96", "snapshot_id": "8893e88b846c7998ac927e8b51710ebf8e29a089", "src_encoding": "UTF-8", "star_events_count": 7, "url": "https://raw.githubusercontent.com/kmecpp/JSpark/27f70839adabdb9477a1bcbf638a4008efc50f96/src/main/java/com/kmecpp/jspark/compiler/tokenizer/LiteralToken.java", "visit_date": "2021-09-14T03:54:55.464710", "added": "2024-11-18T22:25:11.434586+00:00", "created": "2018-05-08T00:17:49", "int_score": 3, "score": 2.953125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0045.json.gz" }
package krati.core.array.entry; public class EntryValueBatchShort extends EntryValueBatch { public EntryValueBatchShort() { this(1000); } public EntryValueBatchShort(int capacity) { /* EntryValueLong * int position; * short value; * long scn; */ super(14, capacity); } public void add(int pos, short val, long scn) { _buffer.putInt(pos); /* array position */ _buffer.putShort(val); /* data value */ _buffer.putLong(scn); /* SCN value */ } }
7f5669d36ac32ea02e5befa4410d8d4709ab594e
{ "blob_id": "7f5669d36ac32ea02e5befa4410d8d4709ab594e", "branch_name": "refs/heads/master", "committer_date": "2011-02-21T21:33:31", "content_id": "bf4ee2592667b473e34f994f7ed8b95c0cd24bbb", "detected_licenses": [ "Apache-2.0" ], "directory_id": "5eafe883e0177e6414d6525e86f1245fc5c2b822", "extension": "java", "filename": "EntryValueBatchShort.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 1174028, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 590, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/main/java/krati/core/array/entry/EntryValueBatchShort.java", "provenance": "stack-edu-0031.json.gz:607623", "repo_name": "cstamas/krati", "revision_date": "2010-12-16T12:54:05", "revision_id": "a6995d55ad7381babf8d70a2a23fb5d720818fa7", "snapshot_id": "17db1ccd45eb0ffd84b2c2ee19797b731bedbed4", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/cstamas/krati/a6995d55ad7381babf8d70a2a23fb5d720818fa7/src/main/java/krati/core/array/entry/EntryValueBatchShort.java", "visit_date": "2020-11-30T12:33:22.523301", "added": "2024-11-19T01:43:05.947463+00:00", "created": "2010-12-16T12:54:05", "int_score": 3, "score": 2.703125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0049.json.gz" }
import parse from '.'; // const pizzahutUS = '+1 650-361-8700'; const pizzahutUK = '+44 1473 748635'; describe('parse', () => { test('detect invalid characters', () => { expect(parse({ input: 'abc' }).isValid).toBe(false); }); test('detect invalid numbers', () => { expect(parse({ input: '' }).isValid).toBe(false); expect(parse({ input: '+*234' }).isValid).toBe(false); expect(parse({ input: '+' }).isValid).toBe(false); expect(parse({ input: '#' }).isValid).toBe(false); expect(parse({ input: '-' }).isValid).toBe(false); expect(parse({ input: '#-' }).isValid).toBe(false); expect(parse({ input: '_' }).isValid).toBe(false); expect(parse({ input: '_#' }).isValid).toBe(false); }); test('parse correct number', () => { expect(parse({ input: '+1 650-361-8700' })).toMatchObject({ input: '+1 650-361-8700', isServiceNumber: false, hasInvalidChars: false, isExtension: false, parsedCountry: 'US', parsedNumber: '6503618700', phoneNumber: '+16503618700', extension: null, isValid: true, hasPlus: true, }); }); test('detect country', () => { expect(parse({ input: pizzahutUK })).toMatchObject({ input: pizzahutUK, isServiceNumber: false, hasInvalidChars: false, isExtension: false, parsedCountry: 'GB', parsedNumber: '1473748635', phoneNumber: '+441473748635', extension: null, isValid: true, hasPlus: true, }); }); test('parse correct number without +', () => { expect(parse({ input: '1 650-361-8700' })).toMatchObject({ input: '1 650-361-8700', isServiceNumber: false, hasInvalidChars: false, isExtension: false, parsedCountry: 'US', phoneNumber: '16503618700', parsedNumber: '6503618700', extension: null, isValid: true, hasPlus: false, }); }); test('parse correct number without country code', () => { expect(parse({ input: '650-361-8700' })).toMatchObject({ input: '650-361-8700', isServiceNumber: false, hasInvalidChars: false, isExtension: false, parsedCountry: 'US', phoneNumber: '6503618700', parsedNumber: '6503618700', extension: null, isValid: true, hasPlus: false, }); }); test('parse number with extension', () => { expect(parse({ input: '650-361-8700 * 123' })).toMatchObject({ input: '650-361-8700 * 123', isServiceNumber: false, hasInvalidChars: false, isExtension: false, parsedCountry: 'US', parsedNumber: '6503618700', phoneNumber: '6503618700', extension: '123', isValid: true, hasPlus: false, }); expect(parse({ input: '+1 650-361-8700 * 123' })).toMatchObject({ input: '+1 650-361-8700 * 123', isServiceNumber: false, hasInvalidChars: false, isExtension: false, parsedCountry: 'US', phoneNumber: '+16503618700', parsedNumber: '6503618700', extension: '123', isValid: true, hasPlus: true, }); }); test('parse service number', () => { expect(parse({ input: '*123' })).toMatchObject({ input: '*123', isServiceNumber: true, hasInvalidChars: false, isExtension: false, parsedCountry: null, parsedNumber: null, phoneNumber: '*123', extension: null, isValid: true, hasPlus: false, }); }); test('parse extension number', () => { expect(parse({ input: '123456' })).toMatchObject({ input: '123456', isServiceNumber: false, hasInvalidChars: false, isExtension: true, parsedCountry: null, parsedNumber: null, phoneNumber: '123456', extension: null, isValid: true, hasPlus: false, }); }); test('parse extension number with max extension length is 8 digits', () => { expect(parse({ input: '12345678', maxExtensionLength: 8 })).toMatchObject({ input: '12345678', isServiceNumber: false, hasInvalidChars: false, isExtension: true, parsedCountry: null, parsedNumber: null, phoneNumber: '12345678', extension: null, isValid: true, hasPlus: false, }); expect( parse({ input: '12345678 * 103', maxExtensionLength: 8 }), ).toMatchObject({ input: '12345678 * 103', isServiceNumber: false, hasInvalidChars: false, isExtension: true, parsedCountry: null, parsedNumber: null, phoneNumber: '12345678', extension: null, isValid: true, hasPlus: false, }); }); test('parse short number with +', () => { expect(parse({ input: '+123456' })).toMatchObject({ input: '+123456', isServiceNumber: false, hasInvalidChars: false, isExtension: false, parsedCountry: null, parsedNumber: '+1 234 56', phoneNumber: '+123456', extension: null, isValid: true, hasPlus: true, }); }); test('extract extended controls', () => { expect(parse({ input: '+12345,,123,45#' })).toMatchObject({ extendedControls: [',', ',', '123', ',', '45#'], }); }); });
eaedd067adc90c0dabdb18181de49f1eb5997fd7
{ "blob_id": "eaedd067adc90c0dabdb18181de49f1eb5997fd7", "branch_name": "refs/heads/master", "committer_date": "2023-07-24T08:49:56", "content_id": "de96491c0f3a29946ef50f8da14aa1bc74836b36", "detected_licenses": [ "MIT" ], "directory_id": "49cceb9a8d6d112760f9b57b71225f4403f8cdfe", "extension": "js", "filename": "index.test.js", "fork_events_count": 40, "gha_created_at": "2016-05-06T01:45:07", "gha_event_created_at": "2023-09-06T02:32:17", "gha_language": "TypeScript", "gha_license_id": "MIT", "github_id": 58172287, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 5187, "license": "MIT", "license_type": "permissive", "path": "/packages/phone-number/lib/parse/index.test.js", "provenance": "stack-edu-0041.json.gz:723629", "repo_name": "ringcentral/ringcentral-js-widgets", "revision_date": "2023-07-24T08:49:56", "revision_id": "25fb1eb287b286717c6bbe6034e91b3c5704dc62", "snapshot_id": "8e3f2664634671849f58b7ba768cc427c9c676a6", "src_encoding": "UTF-8", "star_events_count": 42, "url": "https://raw.githubusercontent.com/ringcentral/ringcentral-js-widgets/25fb1eb287b286717c6bbe6034e91b3c5704dc62/packages/phone-number/lib/parse/index.test.js", "visit_date": "2023-08-04T00:57:30.532217", "added": "2024-11-18T23:23:54.215442+00:00", "created": "2023-07-24T08:49:56", "int_score": 2, "score": 2.359375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0059.json.gz" }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ //---------------------------------------------------// Route::group(['middlewaregroups' => ['web']], function () { Route::get('/', function () { if (Auth::check()) { return redirect()->route('home'); } return view('welcome'); }); //------------------------------- //Searching...... Route::get('search_results',['as'=>'group.searching', 'uses'=>'GroupController@searching']); //------------------------------- //register route Route::get('registerTeacher',['as'=>'registerTeacher','uses'=>'MyLogController@registerTeacher']); Route::post('storeTeacherInfo',['as'=>'storeTeacherInfo','uses'=>'MyLogController@storeTeacherInfo']); Route::get('registerStudent',['as'=>'registerStudent','uses'=>'MyLogController@registerStudent']); Route::post('storeStudentInfo',['as'=>'storeStudentInfo','uses'=>'MyLogController@storeStudentInfo']); //------------------------------------------------------------- //------UserManagement routes are started here (HomeController)------- Route::get('password_changed',['as'=>'changed.password', 'uses' =>'HomeController@changedPassword']); Route::post('password_changed',['as'=>'store.password', 'uses' =>'HomeController@storePassword']); Route::get('add_photo',['as'=>'add.photo', 'uses' =>'HomeController@addPhoto']); Route::post('add_photo',['as'=>'store.photo', 'uses' =>'HomeController@storePhoto']); //----------------UserManagement routes ended-------------------- //---------------------------------------------------------------// // For group controlling , all the methods are defined in the GroupController Route::get('/group/{id}', ['as'=>'id','middleware'=>'group','uses'=>'GroupController@index']); Route::get('/group/{id}/edit',['as'=>'group_id','uses'=>'GroupController@edit']); Route::patch('/group/{id}/update',['as'=>'update','uses'=>'GroupController@update']); Route::get('/create',['as'=>'create','uses'=>'GroupController@create']); Route::post('/store',['as'=>'store','uses'=>'GroupController@store']); Route::get('group/{id}/delete',['as'=>'group_deleted_id','uses'=>'GroupController@delete']); Route::get('/joinGroup',['as' => 'joinGroupid', 'uses' => 'GroupController@joinGroup']); Route::post('/checkGroup' , [ 'as' => 'checkGroup','uses' => 'GroupController@checkGroupForJoining']); Route::get('leftgroup/{gid}/{mid}',['as' => 'left_group', 'uses' => 'GroupController@leftGroup' ]); Route::get('allMembers/{gid}',['as' => 'allMembers', 'uses' => 'GroupController@allMembers' ]); Route::get('removeMember/{id}',['as'=>'removeMember','uses'=> 'GroupController@removeMember']); //-----------------------------------------------------------// //PostController routes are started here Route::get('group/{gid}/createPost',['as' => 'createPost','uses' => 'PostController@createPost']); Route::post('group/{gid}/storePost',['as' =>'storePost', 'uses' =>'PostController@storePost']); Route::get('group/{gid}/allPosts', ['as' => 'allPosts' ,'uses' => 'PostController@allPosts']); Route::get('group/{gid}/post/{type}/{pid}/edit',['as' => 'edit_post' ,'uses' => 'PostController@edit']); Route::patch('group/{gid}/post/{type}/{pid}/update',['as' => 'updatePost', 'uses' =>'PostController@update']); Route::get('group/{gid}/post/{pid}/{type}/delete', ['as' => 'post_deleted', 'uses' => 'PostController@delete']); Route::get('download/{file}',['as' => 'download' , 'uses' => 'PostController@download']); Route::get('group/{gid}/allLectures',['as' => 'allLectures' , 'uses' => 'PostController@allLectures']); Route::get('group/{gid}/createLecture',['as' => 'createLecture','uses' => 'PostController@createLecture']); Route::post('group/Lecture/store',['as' => 'storeLecture','uses' => 'PostController@storeLecture']); //-----------------------------------------------------------------------// //Assignments related routes are here Route::get('group/{gid}/allAssignments',['as' => 'allAssignments' , 'uses' => 'PostController@allAssignments']); Route::get('group/{gid}/createAssignment',['as' => 'createAssignment' ,'uses' =>'PostController@createAssignment']); Route::post('group/{gid}/storeAssignment',['as' => 'storeAssignment' ,'uses' =>'PostController@storeAssignment']); Route::get('group/{gid}/{type}/{pid}/assignment/submit',['as' => 'submitAssignment' ,'uses' =>'PostController@submitAssignment']); Route::post('group/assignment/store',['as' =>'submitByStudent','uses' => 'PostController@assignmentSubmitByStudent']); Route::get('group/submittedAssinment/{gid}/show',['as'=> 'submittedAssignments','uses' => 'PostController@submittedAssignments']); Route::get('downloadA/{file}',['as' => 'downloadA' , 'uses' => 'PostController@downloadA']); //PostController routes are ended //------------------------------------------------// //CommentController routes are started from here Route::post('group/{gid}/post/{pid}/comment/{type}/store',['as' => 'post_comment' ,'uses' =>'CommentController@store']); Route::get('group/{gid}/post/{pid}/comment/{cid}/{type}/edit',['as' => 'post_comment_edit' ,'uses' =>'CommentController@edit']); Route::patch('group/{gid}/post/{pid}/comment/{cid}/{type}/edit',['as' => 'post_comment_update' ,'uses' =>'CommentController@update']); Route::get('group/{gid}/comment/{id}',['as' => 'comment_delete' ,'uses' =>'CommentController@delete']); //CommentController routes are ended //------------------------------------------------// //EmailController routes are started from here Route::get('emailCreate/{gid}',['as' => 'emailCreate', 'uses' => 'EmailController@emailCreate']); Route::post('send',['as' => 'send', 'uses' => 'EmailController@send']); //EmailController routes ended //-----------------------------------------------------// //HomeController routes are started from here Route::auth(); Route::get('/home', ['as'=>'home', 'uses'=>'HomeController@index'] ); //HomeController routes ended //-----------------------------------------------------// //unused till now Route::get('/assignmentFilter/{id}/{gid}',['as'=>'ajaxReq','uses' =>'PostController@assignmentFilter']); }); //-----------------------------------------------------// //AdminController routes are started ... Route::group(['middleware' => ['auth','isAdmin']],function(){ Route::get('admin',['as' => 'admin' , 'uses' => 'AdminController@index']); Route::get('admin/allgroups',['as'=> 'adminAllGroups','uses' =>'AdminController@allGroups']); Route::get('admin/allPosts',['as'=> 'adminGroupPosts','uses' =>'AdminController@groupPosts']); Route::get('admin/allComments',['as'=> 'adminGroupComments','uses' =>'AdminController@groupComments']); Route::get('admin/addAdmin',['as'=> 'add.admin','uses' =>'AdminController@addAdmin']); Route::post('admin/addAdmin',['as'=> 'store.admin','uses' =>'AdminController@storeAdmin']); //ajax calling Route::get('admin/searchGroup',['as'=>'searchGroup','uses'=> 'AdminController@searchGroup']); Route::get('admin/deleteGroup',['as'=>'deleteGroup','uses'=> 'AdminController@deleteGroup']); Route::get('admin/searchPost',['as'=>'searchPost','uses'=> 'AdminController@searchPost']); Route::get('admin/deletePost',['as'=>'deletePost','uses'=> 'AdminController@deletePost']); Route::get('admin/searchComment',['as'=>'searchComment','uses'=> 'AdminController@searchComment']); Route::get('admin/deleteComment',['as'=>'deleteComment','uses'=> 'AdminController@deleteComment']); }); //-----------------------------------------------------// //The purpose of these routes is for testing some features Route::get('test1/{id}',['as' => 'test1' ,'uses' => 'CommentController@test1']); Route::post('test2',['as' =>'test2' ,'uses' => 'CommentController@test2']); //Teacher activities ... Route::get('/pagenotfound',function(){ return view('errors.empty'); }); Route::get('teacher/',function (){ return view('teachers.indexTeacher'); }); Route::get('/blank',function(){ return view('blank'); }); Route::post('/models',function(){ if(Request::ajax()) { return "ok"; } }); Route::get('test',array('as'=>'myform','uses'=>'HomeController@myform')); Route::get('test/ajax/{id}',array('as'=>'myform.ajax','uses'=>'HomeController@myformAjax'));
7313490bdd5287853e89099434d30d83e9cdf942
{ "blob_id": "7313490bdd5287853e89099434d30d83e9cdf942", "branch_name": "refs/heads/master", "committer_date": "2017-09-23T07:13:24", "content_id": "850b7730cd0c6fb17987c03a876aa62095f54382", "detected_licenses": [ "MIT" ], "directory_id": "520f6b61122c29d67b423c01dcb4df3ff84a5405", "extension": "php", "filename": "routes.php", "fork_events_count": 1, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 86321384, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 8871, "license": "MIT", "license_type": "permissive", "path": "/app/Http/routes.php", "provenance": "stack-edu-0047.json.gz:477", "repo_name": "najmulcse/Teacher-Student-Collaboration", "revision_date": "2017-09-23T07:13:24", "revision_id": "6dcb7df7777de064d21a2bb833c102bc42793d78", "snapshot_id": "ace6928e4a077ee3227ecf125703b229cb8932dc", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/najmulcse/Teacher-Student-Collaboration/6dcb7df7777de064d21a2bb833c102bc42793d78/app/Http/routes.php", "visit_date": "2021-01-23T05:35:53.197181", "added": "2024-11-18T18:30:45.407897+00:00", "created": "2017-09-23T07:13:24", "int_score": 2, "score": 2.109375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0065.json.gz" }
/** * Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) * * 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. */ import styled from "@emotion/styled" export const StyledAppViewContainer = styled.div(({ theme }) => ({ display: "flex", flexDirection: "row", justifyContent: "flex-start", alignItems: "stretch", alignContent: "flex-start", position: "absolute", top: 0, left: 0, right: 0, bottom: 0, overflow: "hidden", "@media print": { display: "block", float: "none", height: theme.sizes.full, position: "static", overflow: "visible", }, })) export interface StyledAppViewMainProps { isEmbedded: boolean disableScrolling: boolean } export const StyledAppViewMain = styled.section<StyledAppViewMainProps>( ({ disableScrolling, theme }) => ({ display: "flex", flexDirection: "column", width: theme.sizes.full, overflow: disableScrolling ? "hidden" : "auto", alignItems: "center", "&:focus": { outline: "none", }, // Added so sidebar overlays main app content on // smaller screen sizes [`@media (max-width: ${theme.breakpoints.md})`]: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0, }, "@media print": { position: "relative", display: "block", }, }) ) export interface StyledAppViewBlockContainerProps { isWideMode: boolean showPadding: boolean addPaddingForHeader: boolean addPaddingForChatInput: boolean events: boolean } export const StyledAppViewBlockContainer = styled.div<StyledAppViewBlockContainerProps>( ({ isWideMode, showPadding, addPaddingForHeader, addPaddingForChatInput, events, theme, }) => { let topEmbedPadding: string = showPadding ? "6rem" : "1rem" if (addPaddingForHeader && !showPadding) { topEmbedPadding = "3rem" } const bottomEmbedPadding = showPadding || addPaddingForChatInput ? "10rem" : "1rem" const wideSidePadding = isWideMode ? "5rem" : theme.spacing.lg return { // Don't want to display this element for events (which are outside main/sidebar flow) ...(events && { display: "none" }), width: theme.sizes.full, paddingLeft: theme.inSidebar ? theme.spacing.none : theme.spacing.lg, paddingRight: theme.inSidebar ? theme.spacing.none : theme.spacing.lg, // Increase side padding, if layout = wide and we're not on mobile "@media (min-width: 576px)": { paddingLeft: theme.inSidebar ? theme.spacing.none : wideSidePadding, paddingRight: theme.inSidebar ? theme.spacing.none : wideSidePadding, }, paddingTop: theme.inSidebar ? theme.spacing.none : topEmbedPadding, paddingBottom: theme.inSidebar ? theme.spacing.none : bottomEmbedPadding, minWidth: isWideMode ? "auto" : undefined, maxWidth: isWideMode ? "initial" : theme.sizes.contentMaxWidth, [`@media print`]: { minWidth: "100%", paddingTop: 0, }, } } ) export const StyledAppViewBlockSpacer = styled.div(({ theme }) => { return { width: theme.sizes.full, flexGrow: 1, } }) export const StyledAppViewFooterLink = styled.a(({ theme }) => ({ color: theme.colors.fadedText60, // We do not want to change the font for this based on theme. fontFamily: theme.genericFonts.bodyFont, textDecoration: "none", transition: "color 300ms", "&:hover": { color: theme.colors.bodyText, textDecoration: "underline", }, })) export interface StyledAppViewFooterProps { isWideMode: boolean } export const StyledAppViewFooter = styled.footer<StyledAppViewFooterProps>( ({ isWideMode, theme }) => { const wideSidePadding = isWideMode ? "5rem" : theme.spacing.lg return { color: theme.colors.fadedText40, fontSize: theme.fontSizes.sm, height: theme.sizes.footerHeight, minWidth: isWideMode ? "auto" : undefined, maxWidth: isWideMode ? "initial" : theme.sizes.contentMaxWidth, padding: `${theme.spacing.sm} ${theme.spacing.lg}`, // Increase side padding, if layout = wide and we're not on mobile "@media (min-width: 576px)": { paddingLeft: wideSidePadding, paddingRight: wideSidePadding, }, width: theme.sizes.full, a: { color: theme.colors.fadedText60, }, } } ) export interface StyledIFrameResizerAnchorProps { hasFooter: boolean } // The anchor appears above the footer, so we need to offset it by the footer // if the app is not embedded. export const StyledIFrameResizerAnchor = styled.div<StyledIFrameResizerAnchorProps>(({ theme, hasFooter }) => ({ position: "relative", bottom: hasFooter ? `-${theme.sizes.footerHeight}` : "0", }))
7f73161b8c3852b306dff43239ddb91b54e833d0
{ "blob_id": "7f73161b8c3852b306dff43239ddb91b54e833d0", "branch_name": "refs/heads/develop", "committer_date": "2023-09-04T13:53:20", "content_id": "985537a2c05d57e0106b92ff1944beb30da0fd0f", "detected_licenses": [ "Apache-2.0" ], "directory_id": "9c8e06301f6559a106b805dfe0b372ad2e6bc4d8", "extension": "ts", "filename": "styled-components.ts", "fork_events_count": 2739, "gha_created_at": "2019-08-24T00:14:52", "gha_event_created_at": "2023-09-14T19:08:39", "gha_language": "Python", "gha_license_id": "Apache-2.0", "github_id": 204086862, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 5352, "license": "Apache-2.0", "license_type": "permissive", "path": "/frontend/app/src/components/AppView/styled-components.ts", "provenance": "stack-edu-0073.json.gz:51356", "repo_name": "streamlit/streamlit", "revision_date": "2023-09-04T13:53:20", "revision_id": "4f45c18a4323a796440d651ba77b5eb29409cb2b", "snapshot_id": "beecb89300d6f219f3a43ed328f22d3656243f26", "src_encoding": "UTF-8", "star_events_count": 27877, "url": "https://raw.githubusercontent.com/streamlit/streamlit/4f45c18a4323a796440d651ba77b5eb29409cb2b/frontend/app/src/components/AppView/styled-components.ts", "visit_date": "2023-09-06T06:22:40.853489", "added": "2024-11-18T23:47:17.096610+00:00", "created": "2023-09-04T13:53:20", "int_score": 2, "score": 2.109375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0091.json.gz" }
const http = require("http"); const { pipeline } = require("stream"); const debug = require("debug")("proxy-supervisor:proxy:http"); module.exports = (url, options, clientReq, clientRes, callback) => { let finished = false; const targetReq = http.request({ ...options, path: url.href }); targetReq.once("timeout", () => { debug("timeout triggered"); targetReq.destroy(new Error("TIMEOUT")); }); targetReq.once("response", targetRes => { debug("response triggered with %d status code", targetRes.statusCode); clientRes.writeHead( targetRes.statusCode, targetRes.statusMessage, targetRes.headers ); return pipeline(targetRes, clientRes, () => { debug("response pipeline finished"); if (finished) return; return callback(null, targetRes); }); }); targetReq.once("error", err => { debug("error triggered %s", err.message); finished = true; const writableEnded = clientRes.writableEnded === undefined ? clientRes.finished : clientRes.writableEnded; if (!writableEnded) { clientRes.writeHead(502); clientRes.end(); } return callback(err); }); pipeline(clientReq, targetReq, () => { debug("client payload sent to target"); }); };
3efbb6d2c0874ce7b2e0b687fa7a846927908a5f
{ "blob_id": "3efbb6d2c0874ce7b2e0b687fa7a846927908a5f", "branch_name": "refs/heads/master", "committer_date": "2023-07-04T13:17:01", "content_id": "219035dc72a7344b0fe2c32d821f52b0d76658bf", "detected_licenses": [ "MIT" ], "directory_id": "95149425b2ba58a766d5c757548a61023ab37d97", "extension": "js", "filename": "http.js", "fork_events_count": 8, "gha_created_at": "2017-04-13T07:33:33", "gha_event_created_at": "2023-01-05T17:56:12", "gha_language": "JavaScript", "gha_license_id": "MIT", "github_id": 88137888, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 1280, "license": "MIT", "license_type": "permissive", "path": "/lib/tools/net/http.js", "provenance": "stack-edu-0043.json.gz:237565", "repo_name": "Vladislao/proxy-supervisor", "revision_date": "2023-07-04T13:17:01", "revision_id": "00fbebf4fa4363f1e39a0aea6bff7944a0a552b2", "snapshot_id": "fc7055a79e5f27223909d0e3fdae3dd5cad1523d", "src_encoding": "UTF-8", "star_events_count": 15, "url": "https://raw.githubusercontent.com/Vladislao/proxy-supervisor/00fbebf4fa4363f1e39a0aea6bff7944a0a552b2/lib/tools/net/http.js", "visit_date": "2023-07-06T05:33:40.953985", "added": "2024-11-19T01:15:49.374066+00:00", "created": "2023-07-04T13:17:01", "int_score": 2, "score": 2.40625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0061.json.gz" }
package com.example.centerprimesampleethsdk; import android.os.Bundle; import android.text.TextUtils; import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import androidx.databinding.DataBindingUtil; import com.centerprime.ethereum_client_sdk.EthManager; import com.example.centerprimesampleethsdk.databinding.ActivityErc20TokenBalanceBinding; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.schedulers.Schedulers; public class CheckERCTokenBalanceActivity extends AppCompatActivity { ActivityErc20TokenBalanceBinding binding; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_erc20_token_balance); /** * Using this getTokenBalance function you can check balance of provided walletAddress with smart contract. * * @param walletAddress - which user want to check it's balance * @param password - password of provided password * @param contractAddress - contract address of token * * @return balance */ EthManager ethManager = EthManager.getInstance(); /** * @param infura - Initialize infura */ ethManager.init("https://mainnet.infura.io/v3/a396c3461ac048a59f389c7778f06689"); binding.checkBtn.setOnClickListener(v -> { if (!TextUtils.isEmpty(binding.address.getText().toString()) && !TextUtils.isEmpty(binding.walletPassword.getText().toString()) && !TextUtils.isEmpty(binding.contractAddress.getText().toString())) { String walletAddress = binding.address.getText().toString().trim(); String password = binding.walletPassword.getText().toString().trim(); String erc20TokenContractAddress = binding.contractAddress.getText().toString().trim(); ethManager.getTokenBalance(walletAddress, password, erc20TokenContractAddress, this) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(balance -> { binding.balanceTxt.setText("Token Balance :" + balance.toString()); }, error -> { Toast.makeText(this, error.getMessage(), Toast.LENGTH_SHORT).show(); }); } else { Toast.makeText(this, "Fill fields!", Toast.LENGTH_SHORT).show(); } }); } }
a05567ad595bbcc5aae99f1031988b95f2287b9e
{ "blob_id": "a05567ad595bbcc5aae99f1031988b95f2287b9e", "branch_name": "refs/heads/master", "committer_date": "2021-02-03T08:44:22", "content_id": "167873b1f15583aaf6aadc48d0844213dcec486d", "detected_licenses": [ "MIT" ], "directory_id": "d8353d52952c85d9aa424cf2114da853ee873d16", "extension": "java", "filename": "CheckERCTokenBalanceActivity.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": 2696, "license": "MIT", "license_type": "permissive", "path": "/app/src/main/java/com/example/centerprimesampleethsdk/CheckERCTokenBalanceActivity.java", "provenance": "stack-edu-0027.json.gz:68929", "repo_name": "MaASemenycheva/Ethereum-Android-Wallet-Sample", "revision_date": "2021-02-03T08:44:22", "revision_id": "b3fe93d4f5e177e220a305b6d49085e4f47fd85a", "snapshot_id": "43953499049764de8d4da8ca247e563b38d8710f", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/MaASemenycheva/Ethereum-Android-Wallet-Sample/b3fe93d4f5e177e220a305b6d49085e4f47fd85a/app/src/main/java/com/example/centerprimesampleethsdk/CheckERCTokenBalanceActivity.java", "visit_date": "2023-03-01T13:48:55.711948", "added": "2024-11-19T01:52:56.197594+00:00", "created": "2021-02-03T08:44:22", "int_score": 2, "score": 2.34375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0045.json.gz" }
#include <Arduino.h> #include <ArduinoJson.h> #include "dustSensor.hpp" #include "gps.hpp" #include "globals.hpp" #include "message.hpp" #include "loraTransmission.hpp" #include "powerManagement.hpp" #include "fileSystemAccess.hpp" int state = INIT; String PacketToJson(Sensorpacket pkt, unsigned long time){ String output; const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(4); DynamicJsonDocument doc(capacity); doc["sensor"] = "291A45544A0FA55D"; doc["time"] = time; JsonObject data = doc.createNestedObject("data"); data["pm25"] = pkt.sensorContent.pm25; data["lat"] = pkt.sensorContent.lat; data["lng"] = pkt.sensorContent.lng; data["nonce"] = pkt.sensorContent.nonce; serializeJson(doc, output); return output; } void stateLedThread(void *Param){ for(;;){ digitalRead(LED_BUILTIN)?digitalWrite(LED_BUILTIN,0):digitalWrite(LED_BUILTIN,1); digitalRead(LED_BUILTIN)?delay(1000):delay((state+1)*1000);// Change blink speed depending on state } } void MessageStateMachine(){ switch(state){ case INIT:{ // to make sure we dont send the same packet twice to the webserver // we generate a random number LoraPacket.sensorContent.nonce = esp_random(); Serial.println("Inital Init"); initGPS(); initSDS(); state = GPS; Serial.println("GPS Sate"); } case GPS:{ doGPSTask(); bool gpsSet = LoraPacket.sensorContent.lat != GPS_NULL && LoraPacket.sensorContent.lng != GPS_NULL; state = gpsSet?SDS_INIT:GPS; break; } case SDS_INIT:{ Serial.println("SDS state"); SDSstateInit(); state = SDS; break; } case SDS:{ doSDS(); bool pmSet = LoraPacket.sensorContent.pm25 != -1; state = pmSet?LORA_JOIN:SDS; break; } case LORA_JOIN:{ Serial.println("Send State"); loraInit(); state=LORA_SEND; break; } case LORA_SEND:{ loraLoop(); break; } case LORA_FAILED: failedmessageState(); break; case SLEEP:{ startTimerDeepSleep(); break; } } }
65dd04a7844aeac42609edcfd739330472bab884
{ "blob_id": "65dd04a7844aeac42609edcfd739330472bab884", "branch_name": "refs/heads/master", "committer_date": "2020-05-13T19:31:23", "content_id": "da7ce6f7644aab8c87e57377a8e82dffc27a5480", "detected_licenses": [ "MIT" ], "directory_id": "bc63a622684faee42295947f196c5cff61af99e3", "extension": "cpp", "filename": "message.cpp", "fork_events_count": 0, "gha_created_at": "2020-01-04T22:40:11", "gha_event_created_at": "2020-04-21T22:09:11", "gha_language": "C++", "gha_license_id": null, "github_id": 231838519, "is_generated": false, "is_vendor": false, "language": "C++", "length_bytes": 2397, "license": "MIT", "license_type": "permissive", "path": "/src/message.cpp", "provenance": "stack-edu-0003.json.gz:26851", "repo_name": "ioangogo/pollutionCommute_sensor", "revision_date": "2020-05-13T19:31:23", "revision_id": "f5225014d8e6d5e31ec62e7f441d33f7b5fcbb67", "snapshot_id": "e72e1ba2234f52bddefce0920878e62d413deb9d", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/ioangogo/pollutionCommute_sensor/f5225014d8e6d5e31ec62e7f441d33f7b5fcbb67/src/message.cpp", "visit_date": "2022-07-02T13:44:27.012323", "added": "2024-11-18T22:41:07.213911+00:00", "created": "2020-05-13T19:31:23", "int_score": 2, "score": 2.375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0021.json.gz" }
/******************************************************************************* * Copyright 2021-2023 Intel Corporation * * 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. *******************************************************************************/ #ifndef GPU_BLOCK_STRUCTURE_HPP #define GPU_BLOCK_STRUCTURE_HPP #include <sstream> #include <vector> #include "common/c_types_map.hpp" #include "common/memory_desc_wrapper.hpp" #include "common/utils.hpp" #include "gpu/serialization.hpp" namespace dnnl { namespace impl { namespace gpu { class stride_t { public: stride_t() = default; stride_t(dim_t stride) : stride_(stride) {} bool operator==(const stride_t &other) const { return stride_ == other.stride_; } bool operator!=(const stride_t &other) const { return !operator==(other); } size_t get_hash() const { return dnnl::impl::gpu::get_hash(this); } operator dim_t() const { assert(is_fixed()); return stride_; } bool is_fixed() const { return !is_unknown() && !is_undefined(); } bool is_unknown() const { return stride_ == unknown_stride; } bool is_undefined() const { return stride_ == undefined_stride; } stride_t &operator*=(const stride_t &other) { if (is_fixed() && other.is_fixed()) { stride_ *= other.stride_; } else { stride_ = unknown_stride; } return *this; } // XXX: Ambiguous when coprime stride_t &operator/=(const stride_t &other) { if (is_fixed() && other.is_fixed()) { stride_ /= other.stride_; } else { stride_ = unknown_stride; } return *this; } std::string str() const { std::ostringstream oss; if (is_fixed()) { oss << stride_; } else if (is_unknown()) { oss << "(unknown)"; } else { oss << "(invalid)"; } return oss.str(); } static stride_t unknown() { return stride_t(unknown_stride); } static stride_t undefined() { return stride_t(undefined_stride); } private: // Both negative sentinels: won't interfere with valid strides static constexpr dim_t unknown_stride = std::numeric_limits<dim_t>::min(); static constexpr dim_t undefined_stride = unknown_stride + 1; dim_t stride_ = undefined_stride; }; assert_trivially_serializable(stride_t); inline stride_t operator*(const stride_t &a, const stride_t &b) { stride_t tmp = a; return tmp *= b; } inline stride_t operator*(const stride_t &a, dim_t b) { return a * stride_t(b); } inline stride_t operator*(dim_t a, const stride_t &b) { return stride_t(a) * b; } static constexpr dim_t undefined_dim_idx = -1; struct block_t { block_t() = default; block_t(int dim_idx, dim_t block, const stride_t &stride) : dim_idx(dim_idx), block(block), stride(stride) {} #if __cplusplus >= 202002L // Enabling default operator== on C++20 for validation purposes. bool operator==(const block_t &) const = default; #else bool operator==(const block_t &other) const { return (dim_idx == other.dim_idx) && (block == other.block) && (stride == other.stride); } #endif bool operator!=(const block_t &other) const { return !(*this == other); } size_t get_hash() const { return dnnl::impl::gpu::get_hash(this); } std::string str() const { std::ostringstream oss; oss << "block_t(dim_idx = " << dim_idx; oss << ", block = " << block; oss << ", stride = " << stride; oss << ")"; return oss.str(); } bool is_empty() const { return dim_idx == undefined_dim_idx; } dim_t dim_idx = undefined_dim_idx; // Dimension index. dim_t block = 1; // Block size. stride_t stride; // Stride between elements of the block. }; assert_trivially_serializable(block_t); std::vector<block_t> normalize_blocks( const std::vector<block_t> &blocks, bool remove_size_1_blocks = true); std::vector<block_t> compute_block_structure(const memory_desc_wrapper &mdw, bool inner_only = false, bool do_normalize = true); } // namespace gpu } // namespace impl } // namespace dnnl #endif
13a04fb07936b18aad7d19b60a4a9d9313785bc2
{ "blob_id": "13a04fb07936b18aad7d19b60a4a9d9313785bc2", "branch_name": "refs/heads/master", "committer_date": "2023-09-05T13:13:34", "content_id": "b7d865f0df6cc0ce6b68a823d833b658fb526c7f", "detected_licenses": [ "BSD-3-Clause", "MIT", "Intel", "BSL-1.0", "Apache-2.0", "BSD-2-Clause" ], "directory_id": "c95937d631510bf5a18ad1c88ac59f2b68767e02", "extension": "hpp", "filename": "block_structure.hpp", "fork_events_count": 480, "gha_created_at": "2016-05-09T23:26:42", "gha_event_created_at": "2023-09-14T07:09:12", "gha_language": "C++", "gha_license_id": "Apache-2.0", "github_id": 58414589, "is_generated": false, "is_vendor": false, "language": "C++", "length_bytes": 4719, "license": "BSD-3-Clause,MIT,Intel,BSL-1.0,Apache-2.0,BSD-2-Clause", "license_type": "permissive", "path": "/src/gpu/block_structure.hpp", "provenance": "stack-edu-0008.json.gz:128059", "repo_name": "oneapi-src/oneDNN", "revision_date": "2023-08-09T07:55:23", "revision_id": "aef984b66360661b3116d9d1c1c9ca0cad66bf7f", "snapshot_id": "5cdaa8d5b82fc23058ffbf650eb2f050b16a9d08", "src_encoding": "UTF-8", "star_events_count": 1544, "url": "https://raw.githubusercontent.com/oneapi-src/oneDNN/aef984b66360661b3116d9d1c1c9ca0cad66bf7f/src/gpu/block_structure.hpp", "visit_date": "2023-09-05T22:08:47.214983", "added": "2024-11-18T22:24:53.059342+00:00", "created": "2023-08-09T07:55:23", "int_score": 2, "score": 2.359375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0026.json.gz" }
# Benefits & Memorials Team 2 Sprint Objectives This is a high-level summary of the current goals and tasks in the current Sprint set forth by the [Benefits & Memorials 2 Team](https://github.com/department-of-veterans-affairs/va.gov-team/blob/master/teams/vsa/teams/benefits-memorials-2/charter.md). ### Guided by: - _"How will this help the Veteran, their dependents, and caregivers get the benefits they deserve?"_ - Deliver value in every Sprint - Communicate and embrace transparency - Stay organized and help your future self and team - Measure outcomes where possible - Remember the Contact Center ---- ## **Sprint 9 (11/20 – 12/3)** ```diff - # points over # issues ``` ### 1. Medical Device Ordering Tool **[Epic] Form 2345 - Ordering Prosthetic Socks** (Discovery) Fully understand and document in GitHub how form 2345 works - Veteran perspective; what is the Veteran attempting to do, what steps are they taking to do that? - DLC perspective, including requirements; what do they need - What information is coming from the medical side - DLC Data; what is done with the information once they receive it (Design) Create a mockup of the process at a high level that can be iterated on as more information develops (Frontend) Stub out the anticipated components using the existing VA Design System and the Form Configuration Tool (Backend) Fully understand and document in GitHub the currently existing API endpoints and what services are being used **[Epic] Form 2346 - Ordering Hearing Aid Batteries** (Discovery) Fully understand and document in GitHub how form 2346 works - Veteran perspective; what is the Veteran attempting to do, what steps are they taking to do that? - DLC perspective, including requirements; what do they need - What information is coming from the medical side (doctors) - DLC Data; what is done with the information once they receive it (Design) Create a mockup of the process at a high level that can be iterated on as more information develops (Frontend) Stub out the anticipated components using the existing VA Design System and the Form Configuration Tool (Backend) Fully understand and document in GitHub the currently existing API endpoints and what services are being used
1c035e82eb4269467877ce86695398b083ae1c75
{ "blob_id": "1c035e82eb4269467877ce86695398b083ae1c75", "branch_name": "refs/heads/master", "committer_date": "2020-04-23T17:57:50", "content_id": "63196a2e23118898df5ea68463db7b09c4029a59", "detected_licenses": [ "MIT" ], "directory_id": "8fe7e2ef7fed6ac4642b040a9cdd674226e09667", "extension": "md", "filename": "sprint-objectives.md", "fork_events_count": 1, "gha_created_at": "2020-04-16T14:50:44", "gha_event_created_at": "2020-04-16T14:50:45", "gha_language": null, "gha_license_id": null, "github_id": 256245187, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 2276, "license": "MIT", "license_type": "permissive", "path": "/teams/vsa/teams/benefits-memorials-2/sprint-objectives.md", "provenance": "stack-edu-markdown-0009.json.gz:310391", "repo_name": "billfienberg/va.gov-team", "revision_date": "2020-04-23T17:57:50", "revision_id": "c7e810aa81fb1f3b176db6e702e6d92d3b92982f", "snapshot_id": "9bd57c9a28805487e48494331d6a65fa3f79f503", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/billfienberg/va.gov-team/c7e810aa81fb1f3b176db6e702e6d92d3b92982f/teams/vsa/teams/benefits-memorials-2/sprint-objectives.md", "visit_date": "2022-04-21T00:20:13.108112", "added": "2024-11-18T23:36:46.941131+00:00", "created": "2020-04-23T17:57:50", "int_score": 3, "score": 2.96875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0009.json.gz" }
<?php class TestSSL { public function menu() { echo('<li><a href="plugin/p='.get_class().'">'.get_class().'</a></li>'); } }
33f2c1ed61f825b11780229f24293426d2a8e310
{ "blob_id": "33f2c1ed61f825b11780229f24293426d2a8e310", "branch_name": "refs/heads/main", "committer_date": "2020-11-05T11:22:43", "content_id": "c79ad92c0c3933353289067ff4a31dff34efdf86", "detected_licenses": [ "MIT" ], "directory_id": "754ddb87b386649c89dd9bdc18fd6625dfd6f23d", "extension": "php", "filename": "TestSSL.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 309925455, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 144, "license": "MIT", "license_type": "permissive", "path": "/files/TestSSL.php", "provenance": "stack-edu-0047.json.gz:281861", "repo_name": "magnuslarsen/librenms-puppet", "revision_date": "2020-11-05T11:22:43", "revision_id": "8d3dfd44959e2ce9a7ff6d2c222d1426809590ed", "snapshot_id": "49cbf05b37ca6d108ced458c520741c06be5365d", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/magnuslarsen/librenms-puppet/8d3dfd44959e2ce9a7ff6d2c222d1426809590ed/files/TestSSL.php", "visit_date": "2023-01-04T18:05:51.896801", "added": "2024-11-18T21:32:07.308740+00:00", "created": "2020-11-05T11:22:43", "int_score": 2, "score": 2.046875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0065.json.gz" }
import { Component, ElementRef, ViewChild } from '@angular/core'; import { FormControl } from '@angular/forms'; import { McAutocomplete, McAutocompleteSelectedEvent } from '@ptsecurity/mosaic/autocomplete'; import { McTagInputEvent, McTagList } from '@ptsecurity/mosaic/tags'; import { merge } from 'rxjs'; import { map } from 'rxjs/operators'; /** * @title Basic tags autocomplete */ @Component({ selector: 'tags-autocomplete-example', templateUrl: 'tags-autocomplete-example.html', styleUrls: ['tags-autocomplete-example.css'] }) export class TagsAutocompleteExample { @ViewChild('tagList', { static: false }) tagList: McTagList; @ViewChild('tagInput', { static: false }) tagInput: ElementRef<HTMLInputElement>; @ViewChild('autocomplete', { static: false }) autocomplete: McAutocomplete; control = new FormControl(); allTags: string[] = ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6', 'tag7', 'tag8', 'tag9', 'tag10']; filteredTagsByInput: string[] = []; selectedTags: string[] = ['tag1']; filteredTags: any; ngAfterViewInit(): void { this.filteredTags = merge( this.tagList.tagChanges.asObservable() .pipe(map((selectedTags) => { const values = selectedTags.map((tag: any) => tag.value); return this.allTags.filter((tag) => !values.includes(tag)); })), this.control.valueChanges .pipe(map((value) => { const typedText = (value && value.new) ? value.value : value; this.filteredTagsByInput = typedText ? this.filter(typedText) : this.allTags.slice(); return this.filteredTagsByInput.filter( // @ts-ignore (tag) => !this.selectedTags.includes(tag) ); })) ); } addOnBlurFunc(event: FocusEvent) { const target: HTMLElement = event.relatedTarget as HTMLElement; if (!target || target.tagName !== 'MC-OPTION') { const mcTagEvent: McTagInputEvent = { input: this.tagInput.nativeElement, value : this.tagInput.nativeElement.value }; this.onCreate(mcTagEvent); } } onCreate(event: McTagInputEvent): void { const input = event.input; const value = event.value; if ((value || '').trim()) { const isOptionSelected = this.autocomplete.options.some((option) => option.selected); if (!isOptionSelected) { this.selectedTags.push(value.trim()); } } if (input) { input.value = ''; } this.control.setValue(null); } onSelect(event: McAutocompleteSelectedEvent): void { event.option.deselect(); if (event.option.value.new) { this.selectedTags.push(event.option.value.value); } else { this.selectedTags.push(event.option.value); } this.tagInput.nativeElement.value = ''; this.control.setValue(null); } onRemove(fruit: any): void { const index = this.selectedTags.indexOf(fruit); if (index >= 0) { this.selectedTags.splice(index, 1); } } private filter(value: string): string[] { const filterValue = value.toLowerCase(); return this.allTags.filter((tag) => tag.toLowerCase().indexOf(filterValue) === 0); } }
7633c154f5dc0f1d8192230ab9f33b7c1ea4e600
{ "blob_id": "7633c154f5dc0f1d8192230ab9f33b7c1ea4e600", "branch_name": "refs/heads/master", "committer_date": "2022-04-13T11:45:09", "content_id": "4acc9d7a2c23851cb7bf06fbb20214629485fc8b", "detected_licenses": [ "MIT" ], "directory_id": "03996de77d79245eec3c24c8337531e0cec7ff94", "extension": "ts", "filename": "tags-autocomplete-example.ts", "fork_events_count": 58, "gha_created_at": "2016-09-30T12:22:09", "gha_event_created_at": "2022-04-13T12:27:40", "gha_language": "TypeScript", "gha_license_id": "MIT", "github_id": 69664547, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 3537, "license": "MIT", "license_type": "permissive", "path": "/packages/mosaic-examples/mosaic/tags/tags-autocomplete/tags-autocomplete-example.ts", "provenance": "stack-edu-0076.json.gz:482931", "repo_name": "positive-js/mosaic", "revision_date": "2022-04-12T10:46:20", "revision_id": "f90cbc3438900b1ec94780a8c8aeb4cc1a60138a", "snapshot_id": "009b86033c4840d1244821a76663df2afc7f3fc7", "src_encoding": "UTF-8", "star_events_count": 157, "url": "https://raw.githubusercontent.com/positive-js/mosaic/f90cbc3438900b1ec94780a8c8aeb4cc1a60138a/packages/mosaic-examples/mosaic/tags/tags-autocomplete/tags-autocomplete-example.ts", "visit_date": "2022-09-30T01:32:27.913319", "added": "2024-11-18T23:21:46.517298+00:00", "created": "2022-04-12T10:46:20", "int_score": 2, "score": 2.375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0094.json.gz" }
package fs import ( "io" "os" "path/filepath" ) type Exportable interface { ExportTo(destination string) error } type WriterTo interface { WriteAllTo(io.Writer) error } type File struct { Name string Contents WriterTo } func (f *File) ExportTo(destination string) error { filename := filepath.Join(destination, f.Name) file, err := os.Create(filename) if err != nil { return err } err = f.Contents.WriteAllTo(file) if closeErr := file.Close(); err == nil { err = closeErr } return err } type Directory struct { Name string Children []Exportable } func (d *Directory) ExportTo(destination string) error { dir := filepath.Join(destination, d.Name) if err := os.RemoveAll(dir); err != nil { return err } if err := os.Mkdir(dir, 0766); err != nil { return err } for _, child := range d.Children { if err := child.ExportTo(dir); err != nil { return err } } return nil } var _ Exportable = (*Directory)(nil) var _ Exportable = (*File)(nil)
9d6b485fc97d1bae83b36a5b54a22df12fe16033
{ "blob_id": "9d6b485fc97d1bae83b36a5b54a22df12fe16033", "branch_name": "refs/heads/master", "committer_date": "2016-09-23T06:27:46", "content_id": "597a00e23c5a8317caed025852cf34b7cffb2ac6", "detected_licenses": [ "MIT" ], "directory_id": "f32b9784f8359b701ec6dac598ec9546161c21b7", "extension": "go", "filename": "fs.go", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 68049272, "is_generated": false, "is_vendor": false, "language": "Go", "length_bytes": 990, "license": "MIT", "license_type": "permissive", "path": "/internal/fs/fs.go", "provenance": "stack-edu-0018.json.gz:559290", "repo_name": "nicksnyder/xb", "revision_date": "2016-09-23T06:27:46", "revision_id": "d768eb0b14ff478e6088354a0d7a1f60a91460a6", "snapshot_id": "1b9039f4b9834e87546ee66c4808bb9995c27bfa", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/nicksnyder/xb/d768eb0b14ff478e6088354a0d7a1f60a91460a6/internal/fs/fs.go", "visit_date": "2020-04-09T16:27:16.567882", "added": "2024-11-18T20:19:02.980951+00:00", "created": "2016-09-23T06:27:46", "int_score": 3, "score": 2.890625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0036.json.gz" }
from django.conf import settings from django.db import models from django.db.models import Q from django.forms import ValidationError from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from brouwers.general.utils import get_username class Ban(models.Model): """Model to hold bans. Middleware grabs the bans from the database.""" # TODO: lighten the load on the database: cache the bans, invalidate the # cache when bans are added, deleted or modified (on delete() and save()) # Be carefull, queryset.delete() might not fire signals... user = models.ForeignKey( settings.AUTH_USER_MODEL, verbose_name=_("user"), blank=True, null=True, on_delete=models.SET_NULL, ) ip = models.GenericIPAddressField( _("ip"), blank=True, null=True, help_text=_("Ip address to ban.") ) expiry_date = models.DateTimeField( _("expiry date"), blank=True, null=True, help_text=_("Date the ban expires. Leave blank for permabans."), ) reason_internal = models.TextField(_("reason (internal)"), blank=True) reason = models.TextField( _("reason"), blank=True, help_text=_("This reason will be shown to the banned user."), ) automatic = models.BooleanField(_("automatically created?"), default=False) class Meta: verbose_name = _("ban") verbose_name_plural = _("bans") @property def expires(self): if not self.expiry_date: return _("never") return self.expiry_date @property def type(self): if not self.user: return _("ip ban") return _("account ban") def __str__(self): if self.user: return _("Ban: %(username)s") % {"username": get_username(self)} else: return _("Ban: %(ip)s") % {"ip": self.ip} def clean(self): super().clean() if not self.ip and not self.user: raise ValidationError(_("Submit either an user or IP address.")) return self def save(self, *args, **kwargs): if not self.ip: self.ip = "0.0.0.0" # bogus ip super().save(*args, **kwargs) @classmethod def get_bans_queryset(cls): q_date = Q(expiry_date__gte=timezone.now()) | Q(expiry_date=None) qs = cls.objects.filter(q_date) return qs
ec6bbc8dac51610216971094b444a41e9bc07b1f
{ "blob_id": "ec6bbc8dac51610216971094b444a41e9bc07b1f", "branch_name": "refs/heads/main", "committer_date": "2023-07-30T20:28:34", "content_id": "d4547db389e44363fc08b2b5575069c847a3972b", "detected_licenses": [], "directory_id": "6a8eac5877ea4f782c094ad7b974d03e1dc86401", "extension": "py", "filename": "models.py", "fork_events_count": 3, "gha_created_at": "2013-10-25T21:51:20", "gha_event_created_at": "2023-05-29T15:33:06", "gha_language": "Python", "gha_license_id": "MIT", "github_id": 13872961, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2425, "license": "", "license_type": "permissive", "path": "/src/brouwers/banning/models.py", "provenance": "stack-edu-0060.json.gz:535881", "repo_name": "modelbrouwers/modelbrouwers", "revision_date": "2023-07-30T20:28:34", "revision_id": "7713e78eeb31809e04b0b316ec8f8deed0808fc9", "snapshot_id": "cb2bbea34e70f4a1d9a7361dfe7131a20ea26b02", "src_encoding": "UTF-8", "star_events_count": 7, "url": "https://raw.githubusercontent.com/modelbrouwers/modelbrouwers/7713e78eeb31809e04b0b316ec8f8deed0808fc9/src/brouwers/banning/models.py", "visit_date": "2023-08-06T10:49:33.804123", "added": "2024-11-18T19:07:07.329187+00:00", "created": "2023-07-30T20:28:34", "int_score": 2, "score": 2.203125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0078.json.gz" }
package org.datadog.jenkins.plugins.datadog.util.json; import static org.junit.Assert.assertEquals; import org.datadog.jenkins.plugins.datadog.model.StageData; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @RunWith(Parameterized.class) public class JsonUtilsTest { private static final String SAMPLE_NAME = "stage-name"; private static final StageData STAGE = StageData.builder() .withName(SAMPLE_NAME) .withStartTimeInMicros(1000) .withEndTimeInMicros(2000) .build(); @Parameterized.Parameters public static Collection<Object[]> data() { return Arrays.asList(new Object[][]{ {null, "[]"}, {Collections.EMPTY_LIST, "[]"}, {Collections.singletonList(STAGE), "[{\"name\":\"stage-name\",\"duration\":1000000}]"}, {Arrays.asList(STAGE, STAGE), "[{\"name\":\"stage-name\",\"duration\":1000000},{\"name\":\"stage-name\",\"duration\":1000000}]"} }); } private final List<ToJson> items; private final String expectedJson; public JsonUtilsTest(List<ToJson> items, String expectedJson) { this.items = items; this.expectedJson = expectedJson; } @Test public void shouldReturnCorrectJson() { assertEquals(expectedJson, JsonUtils.toJson(items)); } }
a17fec8bb3c11282b64109d59b8fab72f607198d
{ "blob_id": "a17fec8bb3c11282b64109d59b8fab72f607198d", "branch_name": "refs/heads/master", "committer_date": "2021-02-16T17:09:36", "content_id": "79febb129f0e5e6969d993644546688e2dd3709b", "detected_licenses": [ "MIT" ], "directory_id": "8378c195c856a5970e01643686deb6a65d6241a6", "extension": "java", "filename": "JsonUtilsTest.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": 1503, "license": "MIT", "license_type": "permissive", "path": "/src/test/java/org/datadog/jenkins/plugins/datadog/util/json/JsonUtilsTest.java", "provenance": "stack-edu-0025.json.gz:787855", "repo_name": "cyrille-leclerc/datadog-plugin", "revision_date": "2021-02-16T17:09:36", "revision_id": "7196b835c6b12fffc75c53f1d536d517c94909de", "snapshot_id": "63fec6d06a39f9f1b108aef9029e2bbed4b42b8a", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/cyrille-leclerc/datadog-plugin/7196b835c6b12fffc75c53f1d536d517c94909de/src/test/java/org/datadog/jenkins/plugins/datadog/util/json/JsonUtilsTest.java", "visit_date": "2023-03-06T20:57:24.021785", "added": "2024-11-18T22:43:38.411185+00:00", "created": "2021-02-16T17:09:36", "int_score": 2, "score": 2.34375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0043.json.gz" }
<?php /* * This file is auto generated! Do not edit! */ declare(strict_types=1); namespace Vazaha\Mastodon\Models; use Vazaha\Mastodon\Abstracts\Model; /** * Represents a hashtag used within the content of a status. * * @see https://docs.joinmastodon.org/entities/Tag/ */ class TagModel extends Model { /** * The value of the hashtag after the # sign. */ public string $name; /** * A link to the hashtag on the instance. */ public string $url; /** * Usage statistics for given days (typically the past week). * * @var array<mixed> */ public array $history; /** * Whether the current token's authorized user is following this tag. */ public ?bool $following = null; }
af3c21599ff12a9e0daf2c038a971bc86452165e
{ "blob_id": "af3c21599ff12a9e0daf2c038a971bc86452165e", "branch_name": "refs/heads/main", "committer_date": "2023-08-11T13:05:48", "content_id": "354dc5913ac374bf9a7b11ccbb106d2dd73254db", "detected_licenses": [ "MIT" ], "directory_id": "de7d1a1fc9dd826f726fc35a3757cb77018ab244", "extension": "php", "filename": "TagModel.php", "fork_events_count": 0, "gha_created_at": "2023-07-05T14:02:23", "gha_event_created_at": "2023-08-10T21:07:52", "gha_language": "PHP", "gha_license_id": "MIT", "github_id": 662613252, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 763, "license": "MIT", "license_type": "permissive", "path": "/src/Models/TagModel.php", "provenance": "stack-edu-0051.json.gz:349123", "repo_name": "vazaha-nl/mastodon-api-client", "revision_date": "2023-08-11T13:05:48", "revision_id": "8f175640e97b715a638ebd491888b6ded027ee3a", "snapshot_id": "7cfe7627086b7ca19b2b1a6ab37326ccd5c7ade9", "src_encoding": "UTF-8", "star_events_count": 14, "url": "https://raw.githubusercontent.com/vazaha-nl/mastodon-api-client/8f175640e97b715a638ebd491888b6ded027ee3a/src/Models/TagModel.php", "visit_date": "2023-08-17T18:58:16.726808", "added": "2024-11-18T21:36:29.259025+00:00", "created": "2023-08-11T13:05:48", "int_score": 3, "score": 2.65625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0069.json.gz" }
package io.stepinto.demo.wildfly.swarm.story.service.rest; import io.stepinto.demo.wildfly_swarm.dto.story.story.CreateStoryRequest; import io.stepinto.demo.wildfly_swarm.dto.story.story.CreateStoryResponse; import io.stepinto.demo.wildfly_swarm.dto.story.story.StoryListResponse; import io.stepinto.demo.wildfly_swarm.dto.story.story.StoryResponse; import io.stepinto.wildfly.swarm.demo.common.exception.BaseException; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Api("Történet szálakat kezelő végpont") @Path("/storyService/story") public interface StoryResource { @GET @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @ApiOperation(value = "Történetszál lekérdezése azonosító alapján.", response = StoryResponse.class) StoryResponse getById(@ApiParam(value = "id", required = true) @PathParam("id") String id) throws BaseException; @GET @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @ApiOperation(value = "Rendszerben lévő történetszálak lekédezése.", response = StoryListResponse.class) StoryListResponse findAll() throws BaseException; @POST @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) @ApiOperation(value = "Történetszál létrehozása kérés objektum alapján.", response = CreateStoryResponse.class) CreateStoryResponse createStory(CreateStoryRequest createStoryRequest) throws BaseException; }
39af9b6eaee1e447c3e21f1b7bf936a863b64ce4
{ "blob_id": "39af9b6eaee1e447c3e21f1b7bf936a863b64ce4", "branch_name": "refs/heads/master", "committer_date": "2018-10-03T19:51:58", "content_id": "efbf7e9a54fd6238d77e2f30cf66c3502b8c45fb", "detected_licenses": [ "MIT" ], "directory_id": "4c80d28e191a8de23225d3c5c7641abdba173b38", "extension": "java", "filename": "StoryResource.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": 1805, "license": "MIT", "license_type": "permissive", "path": "/demo/story-service/src/main/java/io/stepinto/demo/wildfly/swarm/story/service/rest/StoryResource.java", "provenance": "stack-edu-0030.json.gz:337086", "repo_name": "stepintomeetups/2018-10-wildfly-swarm", "revision_date": "2018-10-03T19:51:58", "revision_id": "6258c3ae80671f32f0497992d903d1a6612b1c52", "snapshot_id": "e8c5a2ce02423286336d40879d677b5741e3ed4e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/stepintomeetups/2018-10-wildfly-swarm/6258c3ae80671f32f0497992d903d1a6612b1c52/demo/story-service/src/main/java/io/stepinto/demo/wildfly/swarm/story/service/rest/StoryResource.java", "visit_date": "2021-09-24T05:25:12.726257", "added": "2024-11-19T01:44:59.278610+00:00", "created": "2018-10-03T19:51:58", "int_score": 2, "score": 2.09375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0048.json.gz" }
/* * Copyright 2021 Axway Software * * 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 com.axway.ats.core.dbaccess.mariadb; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.util.HashMap; import java.util.Map; import org.junit.Test; import org.mariadb.jdbc.Driver; import org.mariadb.jdbc.MariaDbPoolDataSource; import com.axway.ats.common.dbaccess.DbKeys; import com.axway.ats.core.BaseTest; public class Test_DbConnMariaDB extends BaseTest { @Test public void accessors() { Map<String, Object> customProperties = new HashMap<String, Object>(); customProperties.put(DbKeys.PORT_KEY, 123); DbConnMariaDB dbConnection = new DbConnMariaDB("host", "db", "user", "pass", customProperties); assertEquals(DbConnMariaDB.DATABASE_TYPE, dbConnection.getDbType()); assertEquals("host", dbConnection.getHost()); assertEquals("db", dbConnection.getDb()); assertEquals("user", dbConnection.getUser()); assertEquals("pass", dbConnection.getPassword()); assertEquals("jdbc:mariadb://host:123/db", dbConnection.getURL()); assertTrue(dbConnection.getConnHash().startsWith("host_123_db")); assertEquals("MariaDB connection to host:123/db, not using SSL", dbConnection.getDescription()); assertEquals(Driver.class, dbConnection.getDriverClass()); } @Test public void accessorsWithSSLAndDefaultPort() { Map<String, Object> customProperties = new HashMap<String, Object>(); //customProperties.put(DbKeys.PORT_KEY, 123); //customProperties.put(DbConnMySQL.USE_SSL_PROPERTY_NAME, "true"); customProperties.put(DbKeys.USE_SECURE_SOCKET, "true"); DbConnMariaDB dbConnection = new DbConnMariaDB("host", "db", "user", "pass", customProperties); assertEquals(DbConnMariaDB.DATABASE_TYPE, dbConnection.getDbType()); assertEquals("host", dbConnection.getHost()); assertEquals("db", dbConnection.getDb()); assertEquals("user", dbConnection.getUser()); assertEquals("pass", dbConnection.getPassword()); assertEquals("jdbc:mariadb://host:3306/db?useSSL=true", dbConnection.getURL()); assertTrue(dbConnection.getConnHash().startsWith("host_3306_db")); assertEquals("MariaDB connection to host:3306/db, using SSL", dbConnection.getDescription()); assertEquals(org.mariadb.jdbc.Driver.class, dbConnection.getDriverClass()); } @Test public void getDataSource() { Map<String, Object> customProperties = new HashMap<>(); customProperties.put(DbConnMariaDB.CONNECT_TIMEOUT, "2000"); DbConnMariaDB dbConnection = new DbConnMariaDB("__invalid_host__", "db", "user", "pass", customProperties); assertEquals(MariaDbPoolDataSource.class, dbConnection.getDataSource().getClass()); } }
730be3b3ab789bf8b33e1923a3a63386ca638688
{ "blob_id": "730be3b3ab789bf8b33e1923a3a63386ca638688", "branch_name": "refs/heads/master_wo_log4j2", "committer_date": "2023-03-28T13:48:28", "content_id": "c575185f98899a7ebdca877cd03fa423b5f913c4", "detected_licenses": [ "Apache-2.0" ], "directory_id": "a39b96a5aa87ef82f98815f584eec26190937cfd", "extension": "java", "filename": "Test_DbConnMariaDB.java", "fork_events_count": 61, "gha_created_at": "2017-02-24T14:00:11", "gha_event_created_at": "2023-04-14T17:16:16", "gha_language": "Java", "gha_license_id": "Apache-2.0", "github_id": 83046783, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 3398, "license": "Apache-2.0", "license_type": "permissive", "path": "/corelibrary/src/test/java/com/axway/ats/core/dbaccess/mariadb/Test_DbConnMariaDB.java", "provenance": "stack-edu-0021.json.gz:609572", "repo_name": "Axway/ats-framework", "revision_date": "2023-03-28T13:48:28", "revision_id": "c3e97bc27a4a46c95253dbde1c1b303849066069", "snapshot_id": "1dcb16cd69ffa171903ee637bb7aa9d4c7fd4006", "src_encoding": "UTF-8", "star_events_count": 37, "url": "https://raw.githubusercontent.com/Axway/ats-framework/c3e97bc27a4a46c95253dbde1c1b303849066069/corelibrary/src/test/java/com/axway/ats/core/dbaccess/mariadb/Test_DbConnMariaDB.java", "visit_date": "2023-08-21T19:23:57.108588", "added": "2024-11-18T19:37:34.994913+00:00", "created": "2023-03-28T13:48:28", "int_score": 2, "score": 2.078125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0039.json.gz" }
# # explicit / implicit wave equation solve # import sys from manta import * from helperInclude import * gs = vec3( 113,127, 1) s = Solver(name='main', gridSize = gs, dim=2) # wave eq settings implicit = False s.timestep = 0.9 cSqr = 0.12 normalizeMass = True useCrankNicholson = False # allocate grids h = s.create(RealGrid) hprev = s.create(RealGrid) hnew = s.create(RealGrid) curv = s.create(RealGrid) vel = s.create(RealGrid) flags = s.create(FlagGrid) flags.initDomain() flags.fillGrid() timings = Timings() if 0 and (GUI): gui = Gui() gui.show() gui.pause() source = s.create(Box, p0=gs*vec3(0.3,0.3,0.3), p1=gs*vec3(0.5,0.5,0.5)) source.applyToGrid(grid=h, value=1) hprev.copyFrom(h) for t in range(40): mass = totalSum( height=h ) #print "Current mass %f " % mass if implicit: # implicit solve , cf. 07IntroToPDEs.pdf, page 19 cgSolveWE( flags=flags, ut=h, utm1=hprev, out=hnew , cSqr=cSqr, crankNic=useCrankNicholson ); else: # explicit solve , easier-to-read version with explicit velocity integration calcSecDeriv2d(h, curv) vel.addScaled(curv, cSqr * s.timestep) h.addScaled(vel,s.timestep) # switch to implicit for second half if(t>=20): implicit = True if normalizeMass: normalizeSumTo(h, mass) #gui.screenshot( 'out_%04d.png' % t ); #timings.display() s.step() doTestGrid( sys.argv[0], "height" , s, h , threshold=1e-08 , thresholdStrict=1e-10 ) doTestGrid( sys.argv[0], "vel" , s, vel, threshold=1e-08 , thresholdStrict=1e-10 )
3a70b98ec94f7c8dec3e80574103b5274ad61d40
{ "blob_id": "3a70b98ec94f7c8dec3e80574103b5274ad61d40", "branch_name": "refs/heads/master", "committer_date": "2022-07-21T08:39:53", "content_id": "70cc1176858b124eb48613a0cbe9d4915ddc7b07", "detected_licenses": [ "Apache-2.0" ], "directory_id": "0fca91ef15eba6bfe405520cc3db868257bd83bf", "extension": "py", "filename": "test_1030_waveeq.py", "fork_events_count": 19, "gha_created_at": "2018-11-02T16:53:49", "gha_event_created_at": "2022-10-26T16:13:22", "gha_language": "C++", "gha_license_id": "NOASSERTION", "github_id": 155895908, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1533, "license": "Apache-2.0", "license_type": "permissive", "path": "/tools/tests/test_1030_waveeq.py", "provenance": "stack-edu-0059.json.gz:338207", "repo_name": "thunil/mantaflow", "revision_date": "2022-07-21T08:39:53", "revision_id": "494445143507296d16e467160c1889be657f8f74", "snapshot_id": "87f94287c64c3def91f1397cbddcb7c996f3d613", "src_encoding": "UTF-8", "star_events_count": 99, "url": "https://raw.githubusercontent.com/thunil/mantaflow/494445143507296d16e467160c1889be657f8f74/tools/tests/test_1030_waveeq.py", "visit_date": "2022-11-04T04:59:25.200106", "added": "2024-11-19T01:38:45.801163+00:00", "created": "2022-07-21T08:39:53", "int_score": 2, "score": 2.28125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0077.json.gz" }
# -*- coding: utf-8 -*- """ Developed and tested with Python 2.7.15 @author: Alexander Tong """ import os import pandas as pd def main(): directory = r'D:\GLUE Datasets\Spectra\ecospeclib-1541789735754' # soil directory = r'D:\GLUE Datasets\Spectra\ecospeclib-1541790159942' # water # material = 'manmade' # material = 'soil' material = 'water' landsat_sensor = 5 process_emissivity(directory,material,landsat_sensor) def process_emissivity(directory,material,landsat_sensor): ''' Description: computes the average emissivity for material spectral response \n\ curves from the ASTER Spectral Library. Emissivity values are used in the \n\ calculation of land surface temperature. WARNING: only tested with soil and water spectra files; modify effective wavelength \n\ values in try/except statements as necessary Args: directory (str): specify directory of .txt files from ASTER Spectral Library material (str): specify material type as given by the file from ASTER Spectral Library (e.g., if manmade.concrete.constructionconcrete.solid.all.0598uuucnc.jhu.becknic.spectrum, then 'manmade') landsat_sensor (int): specify landsat sensor; currently only accepts 5, 7, or 8 Returns: print out of global (mean) emissivity of specified material at effective TIRS \n\ wavelength for Landsat 5/7/8 $Future Implementation: modify targeted effective wavelengths into own function due to multiple cases for different materials ''' material_type = [] df_list = [] headers_mean = ['Material', 'wavelength', '% reflectance','reflectance','emissivity'] df_select_mean = pd.DataFrame(columns=headers_mean) for root, dirnames, filenames in os.walk(directory): for file in range(len(filenames)): if filenames[file].endswith('spectrum.txt'): # if 'tir' in filenames[file]: #only for non-photosythethic or vegetation; not applicable for man-made if material in filenames[file]: count = 0 title = [] spectra_raw = [] spectra_cleaned = [] df_combine = pd.DataFrame() with open(os.path.join(root,filenames[file]) ,'r') as infile: for line in infile: if count == 0: title.append(line.rstrip('\n')) material_type.append(title[0][6:]) elif count > 20: spectra_raw.append('NaN' + '\t' + line) count += 1 headers = ['Material','wavelength','% reflectance'] #remove '\n' and convert '\t' to ',' for i in range(len(spectra_raw)): #clean and separate strip_n = spectra_raw[i].rstrip('\n') replace_tab = strip_n.split('\t') # convert values and re-combine title = replace_tab[0] wavelength = float(replace_tab[1]) reflectance = float(replace_tab[2]) combined = [title, wavelength, reflectance] # make multiple lists spectra_cleaned.append(combined) #empty list for re-population combined = [] # while len of all lists not 0, continue df = pd.DataFrame(spectra_cleaned, columns=headers) #calculate emissivity: create new columns df['reflectance'] = df['% reflectance']/100 df['emissivity'] = 1 - df['reflectance'] ''' $Future Implementation: modify into own function due to multiple cases for different materials''' # find effective wavelength; will be different, so factor for all cases # range provided factors for global range from spectra files try: ## WARNING BELOW RANGES ARE SET BASED ON <MATERIAL SPECTRA> TXT WAVELENGTH SAMPLING INTERVALS; \n\ ## WILL CHANGE WITH OTHER ASTER SPECTRAL CURVE TXT DATASETS if material == 'soil': # ----- ASTER lib: soil spectra all: START ------ # if landsat_sensor == 8: # 10.895 um df_select = df[(df['wavelength'] >= 10.89) & (df['wavelength'] <= 10.9)] # print df_select # fix such that it takes the average value from 10.2 and 10.3; not necessary for this wavelength elif landsat_sensor == 7: # 11.269 um (Revision of the Single-Channel Algorithm for Land Surface Temperature Retrieval From Landsat Thermal-Infrared Data) # only works for soil spectra df_select = df[(df['wavelength'] >= 11.26) & (df['wavelength'] <= 11.28)] # print df_select # fix such that it takes the average value from 11.4 and 11.5 elif landsat_sensor == 5: # 11.457 um (Revision of the Single-Channel Algorithm for Land Surface Temperature Retrieval From Landsat Thermal-Infrared Data) # get average value between 2 values; saves as series and all rows become float; not as a dataframe df_select = df[(df['wavelength'] >= 11.44) & (df['wavelength'] <= 11.47)].mean(axis = 0) # need to re-add name to series in order to be able to append to dataframe df_select = df_select.rename(index = df[(df['wavelength'] >= 11.44) & (df['wavelength'] <= 11.47)].index[0]) # append new row to list df_select_mean = df_select_mean.append(df_select) # at first column, convert row from float to string to allow for material name to added df_select_mean[['Material']] = df_select_mean[['Material']].astype(str) # print df_select # grab index of first of two items that were averaged in previous step # df_select_mean.index = df[(df['wavelength'] >= 11.44) & (df['wavelength'] <= 11.47)].head(1) # ----- ASTER lib: soil spectra all: END ------ # elif material == 'water': # ----- ASTER lib: water spectra all: START ------ # if landsat_sensor == 8: # 10.896 um df_select = df[(df['wavelength'] >= 10.8900) & (df['wavelength'] <= 10.9140)] # print df_select elif landsat_sensor == 7: # 11.269 um (Revision of the Single-Channel Algorithm for Land Surface Temperature Retrieval From Landsat Thermal-Infrared Data) df_select = df[(df['wavelength'] >= 11.2699) & (df['wavelength'] <= 11.2700)] # print df_select if df_select.empty: df_select = df[(df['wavelength'] >= 11.2000) & (df['wavelength'] <= 11.3000)].mean(axis = 0) # need to re-add name to series in order to be able to append to dataframe df_select = df_select.rename(index = df[(df['wavelength'] >= 11.2000) & (df['wavelength'] <= 11.3000)].index[0]) # append new row to list df_select_mean = df_select_mean.append(df_select) # at first column, convert row from float to string to allow for material name to added df_select_mean[['Material']] = df_select_mean[['Material']].astype(str) elif landsat_sensor == 5: # 11.457 um (Revision of the Single-Channel Algorithm for Land Surface Temperature Retrieval From Landsat Thermal-Infrared Data) df_select = df[(df['wavelength'] >= 11.4440) & (df['wavelength'] <= 11.4694)].mean(axis = 0) # if not NaN... continue if df_select.isnull().values.any() == False: # need to re-add name to series in order to be able to append to dataframe df_select = df_select.rename(index = df[(df['wavelength'] >= 11.4440) & (df['wavelength'] <= 11.4694)].index[0]) # append new row to list df_select_mean = df_select_mean.append(df_select) # at first column, convert row from float to string to allow for material name to added df_select_mean[['Material']] = df_select_mean[['Material']].astype(str) # if NaN, try searching at next hard-coded wavelength interval elif df_select.isnull().values.any() == True: df_select = df[(df['wavelength'] >= 11.4400) & (df['wavelength'] <= 11.4700)].mean(axis = 0) # if not NaN... continue if df_select.isnull().values.any() == False: # need to re-add name to series in order to be able to append to dataframe df_select = df_select.rename(index = df[(df['wavelength'] >= 11.4400) & (df['wavelength'] <= 11.4700)].index[0]) # append new row to list df_select_mean = df_select_mean.append(df_select) # at first column, convert row from float to string to allow for material name to added df_select_mean[['Material']] = df_select_mean[['Material']].astype(str) # if NaN, try searching at next hard-coded wavelength interval elif df_select.isnull().values.any() == True: df_select = df[(df['wavelength'] >= 11.4000) & (df['wavelength'] <= 11.500)].mean(axis = 0) # if not NaN... continue if df_select.isnull().values.any() == False: # need to re-add name to series in order to be able to append to dataframe df_select = df_select.rename(index = df[(df['wavelength'] >= 11.4000) & (df['wavelength'] <= 11.500)].index[0]) # append new row to list df_select_mean = df_select_mean.append(df_select) # at first column, convert row from float to string to allow for material name to added df_select_mean[['Material']] = df_select_mean[['Material']].astype(str) # ----- ASTER lib: water spectra all: END ------ # except: pass ## set material name from previous list # if NaN in df_select and df_select_mean is empty... if df_select.isnull().values.any() == False and df_select_mean.empty == True: # get value at index, and replace with material type name (index, col_name) df_select.at[df_select.index[0], 'Material'] = material_type[0] print df_select # convert values to list for processing df_select_val_process = df_select.values.tolist() # else if no NaN in df_select and df_select_mean is filled... elif df_select.notnull().values.any() == True and df_select_mean.empty == False: # get value at index, and replace with material type name (index, col_name) df_select_mean.at[df_select_mean.index[0], 'Material'] = material_type[0] print df_select_mean # convert values to list for processing df_select_val_process = df_select_mean.values.tolist() # remove each material name from end of list as it cycles through all txt files; # such that each txt gets its original material name before processing end material_type.pop(-1) df_list.append(df_select_val_process) # empty container for next val to be put into dataframe df_select_mean = pd.DataFrame(columns=headers_mean) # once all txt have cycled, append to new list for final output df_list_cleaned = [] for i in range(len(df_list)): df_list_cleaned.append(df_list[i][0]) headers_final = ['Material','wavelength','% reflectance','reflectance','emissivity'] df_analysis = pd.DataFrame(df_list_cleaned, columns=headers_final) # get mean value of emissivity for x material df_analysis['emissivity'].mean() df_analysis['emissivity'] df_analysis[['Material','emissivity']] df_analysis.head() print (df_analysis[['Material','emissivity']]) print ('\n' + 'Average emissivity of all {0} materials is {1}'.format(material,round(df_analysis['emissivity'].mean(),4))) # empty dataframes df_select = pd.DataFrame() df_select_mean = pd.DataFrame() main()
e503cabd73c60c60d97f7e2c5eaecbe448d0627a
{ "blob_id": "e503cabd73c60c60d97f7e2c5eaecbe448d0627a", "branch_name": "refs/heads/master", "committer_date": "2019-03-25T14:32:19", "content_id": "6bcba99be1a294ed4e8cf740963edb76df1f633b", "detected_licenses": [ "MIT" ], "directory_id": "d70916bf14871625d86a785d2d646545f2f97bd4", "extension": "py", "filename": "landsat_emissivity_calc.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": 16692, "license": "MIT", "license_type": "permissive", "path": "/Emissivity/landsat_emissivity_calc.py", "provenance": "stack-edu-0065.json.gz:82397", "repo_name": "leeeeeeeee2/Landsat_SC_NBEM_LST_Retrieval", "revision_date": "2019-03-25T14:32:19", "revision_id": "b3669991e407bbf1c2db0417d28b4d28021904f7", "snapshot_id": "bb7ddcc8236ac845aded64511f00ab17b387b593", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/leeeeeeeee2/Landsat_SC_NBEM_LST_Retrieval/b3669991e407bbf1c2db0417d28b4d28021904f7/Emissivity/landsat_emissivity_calc.py", "visit_date": "2022-02-17T08:40:37.979994", "added": "2024-11-18T20:39:58.510791+00:00", "created": "2019-03-25T14:32:19", "int_score": 3, "score": 2.71875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0083.json.gz" }
const Discord = require('discord.js') const db = require('quick.db') let supportIDs = ["291633488535486474", "529815278456930314", "320546614857170945", "601420236335480842"] module.exports = { name: "decline", description: "manually decline a bot app", aliases: ['d'], /** * @param {Discord.Client} bot * @param {Discord.Message} message * @param {String[]} args */ run: async (message, args, bot) => { if (!supportIDs.includes(message.author.id)) return let target = message.mentions.members.first() let botn = args[1] if (!botn) return if (!target) return let reason = args.slice(2).join(" ") if (!reason) reason = "N/A" let approvedEmbed = new Discord.MessageEmbed() .setTitle("Punch IT Bot Notice") .setColor("RANDOM") .setDescription("Hey! This is Punch IT Bot List here to inform you that, regretably, your application was denied. Don't fret! You can try again, or open a ticket to refute the decision!") .addField("Declined by", message.author.tag, true) .addField("Comments from Approval Team", reason, true) .setFooter(message.author.tag, message.author.displayAvatarURL({ dynamic: true, format: 'png'})) target.send(approvedEmbed) message.author.send("📧 Message sent 📧") let botLogDEmbed = new Discord.MessageEmbed() .setTitle(`Bot Denied.`) .setDescription(`${botn} by ${target} was denied by our moderators.\n ${target}, you can always re-apply once you have fixed the problem!`) .setColor('RED') .setFooter(message.author.username, message.author.displayAvatarURL({ dynamic: true, format: 'png' })) .setTimestamp(); bot.channels.cache.get('760042542141538324').send(botLogDEmbed); } }
ae432feb9c452e5fa737d0ce0f67f63c4a25e687
{ "blob_id": "ae432feb9c452e5fa737d0ce0f67f63c4a25e687", "branch_name": "refs/heads/main", "committer_date": "2021-07-04T20:14:35", "content_id": "d24c579e2c470ec71e7a01433a2fd57259689a81", "detected_licenses": [ "MIT" ], "directory_id": "1a2b4a7b03fef3fe699df9a2da10009b75ac9247", "extension": "js", "filename": "decline.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": 1754, "license": "MIT", "license_type": "permissive", "path": "/commands/decline.js", "provenance": "stack-edu-0042.json.gz:700972", "repo_name": "BrydenIsNotSmart/blistings-botlist", "revision_date": "2021-07-04T20:14:35", "revision_id": "a18b322bc8b81bf72c787844215186e18c069a6d", "snapshot_id": "6dc55bb6c334092ebb7287b57ac8ea0de2aa7d53", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/BrydenIsNotSmart/blistings-botlist/a18b322bc8b81bf72c787844215186e18c069a6d/commands/decline.js", "visit_date": "2023-06-16T04:01:49.946309", "added": "2024-11-18T20:54:09.112484+00:00", "created": "2021-07-04T20:14:35", "int_score": 2, "score": 2.28125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0060.json.gz" }
#!/usr/bin/env python # encoding: utf-8 """ @author:nikan(859905874@qq.com) @file: 1. Two Sum.py ~~~~~~~~~~~ :license: MIT, see LICENSE for more details. @time: 31/01/2018 1:26 PM """ """ Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. """ class Solution(object): def twoSum(self, nums, target): """通过构造一个 dict 来使得第二个数字的查询达到最好 O(1)的时间复杂度 Time Complexity: O(n) Space Complaxity: O(1) :type nums: List[int] :type target: int :rtype: List[int] """ num_map = dict((v, k) for k, v in enumerate(nums)) for index, value in enumerate(nums): """如果遍历 num_map来获取第一个数的下标, 对于重复数字的列表,如[3,3],得到 num_map{3:1},会导致错误,因此遍历 nums 列表是正确的做法。""" another = target - value another_index = num_map.get(another) if another_index: return [index, another_index] else: return None
b990bb980e1c3abdb1edf7d233cfd3ec92719d4d
{ "blob_id": "b990bb980e1c3abdb1edf7d233cfd3ec92719d4d", "branch_name": "refs/heads/master", "committer_date": "2018-02-01T03:21:41", "content_id": "83348c43891822e4b77b76d5d8defa0536364300", "detected_licenses": [ "MIT" ], "directory_id": "230e71a2f9acd05366c63a24dc41f25d636952b6", "extension": "py", "filename": "1. Two Sum.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 119638909, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1358, "license": "MIT", "license_type": "permissive", "path": "/Algorithms/1. Two Sum.py", "provenance": "stack-edu-0058.json.gz:486580", "repo_name": "nikan1996/LeetCode", "revision_date": "2018-02-01T03:21:41", "revision_id": "37ec3d8496589e3449ee05183067f533906a412f", "snapshot_id": "2b13e1cebfa49f1fde2d01435e9b9839391e118f", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/nikan1996/LeetCode/37ec3d8496589e3449ee05183067f533906a412f/Algorithms/1. Two Sum.py", "visit_date": "2021-05-08T21:20:32.936636", "added": "2024-11-18T20:23:38.876109+00:00", "created": "2018-02-01T03:21:41", "int_score": 4, "score": 3.953125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0076.json.gz" }
#!/bin/bash ################################################################################ ## File: rndgenerator.sh ## Desc: Install random number generator ################################################################################ # Source the helpers for use with the script source $HELPER_SCRIPTS/document.sh # Install haveged apt-get -y install haveged # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" for cmd in haveged; do if ! command -v $cmd; then echo "$cmd was not installed or not found on PATH" exit 1 fi done # Document what was added to the image echo "Lastly, documenting what we added to the metadata file" DocumentInstalledItem "Haveged $(dpkg-query --showformat='${Version}' --show haveged)"
2d1c881f2fc42b5e78cd79e5b1a65aa9e896df33
{ "blob_id": "2d1c881f2fc42b5e78cd79e5b1a65aa9e896df33", "branch_name": "refs/heads/main", "committer_date": "2021-03-04T05:07:05", "content_id": "c2575989345fcb77adae8e19d1b9e0ac88a85d53", "detected_licenses": [ "MIT" ], "directory_id": "60ac33a74a19433aca41cdbfb083f5fcbf3765bb", "extension": "sh", "filename": "rndgenerator.sh", "fork_events_count": 0, "gha_created_at": "2020-08-24T13:26:41", "gha_event_created_at": "2020-10-07T05:40:28", "gha_language": null, "gha_license_id": "MIT", "github_id": 289935414, "is_generated": false, "is_vendor": false, "language": "Shell", "length_bytes": 853, "license": "MIT", "license_type": "permissive", "path": "/images/linux/scripts/installers/rndgenerator.sh", "provenance": "stack-edu-0069.json.gz:459733", "repo_name": "henrypbriffel/virtual-environments", "revision_date": "2021-03-04T05:07:05", "revision_id": "9c61333bc99546b6c397369343ab9050b6c78a6f", "snapshot_id": "8ecdbb1cb8469ba230652513e7311cfd3affd180", "src_encoding": "UTF-8", "star_events_count": 3, "url": "https://raw.githubusercontent.com/henrypbriffel/virtual-environments/9c61333bc99546b6c397369343ab9050b6c78a6f/images/linux/scripts/installers/rndgenerator.sh", "visit_date": "2023-03-12T09:23:20.252095", "added": "2024-11-18T20:03:44.028282+00:00", "created": "2021-03-04T05:07:05", "int_score": 4, "score": 4, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0087.json.gz" }
// SPDX-License-Identifier: MIT #ifndef _PARSE_STACK_H #define _PARSE_STACK_H #ifndef KDKS_CONF_KERNEL #include <stdio.h> #include <stdbool.h> #endif /*TODO - need to find safe size for small stack limitation for kernel*/ #if defined(KDKS_CONF_KERNEL) && !defined(BUFSIZ) #define BUFSIZ (256) #endif typedef struct parse_stack { char buf[BUFSIZ]; int top; int n_parentheses; int n_brackets; } parse_stack; /*parse_stack interfaces*/ static inline void parse_stack__init(parse_stack *s) { s->top = 0; s->n_brackets = 0; s->n_parentheses = 0; //memset((void *)s->buf,0x00, BUFSIZ);; s->buf[0]='\0'; } static inline bool parse_stack__is_full(parse_stack *s) { return s-> top == BUFSIZ; } static inline bool parse_stack__is_empty(parse_stack *s) { return s->top == 0; } static inline void parse_stack__push(parse_stack *s, const char c) { if (parse_stack__is_full(s)) return; if(c == '(') s->n_parentheses++; if(c == '<') s->n_brackets++; s->buf[s->top++] = c; } static inline void parse_stack__pop(parse_stack *s){ while(!parse_stack__is_empty(s)){ s->top--; /*will removed*/ if(s->buf[s->top] == '(' || s->buf[s->top] == '<') break; /*pop*/ if(s->buf[s->top] == ')') s->n_parentheses--; if(s->buf[s->top] == '>') s->n_brackets--; } } #endif /* _PARSE_STACK_H */
9e3e04072c86158c81f797226d127a9cebb39696
{ "blob_id": "9e3e04072c86158c81f797226d127a9cebb39696", "branch_name": "refs/heads/main", "committer_date": "2021-11-12T04:25:46", "content_id": "354a9d17c060a16d702658ed7ebccface9e74172", "detected_licenses": [ "MIT" ], "directory_id": "c9d941ac962e308b4a3e5305427cc35b65be7459", "extension": "h", "filename": "parse_stack.h", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 422061483, "is_generated": false, "is_vendor": false, "language": "C", "length_bytes": 1318, "license": "MIT", "license_type": "permissive", "path": "/include/parse_stack.h", "provenance": "stack-edu-0001.json.gz:113718", "repo_name": "oslab-swrc/Dark-Insight", "revision_date": "2021-11-12T04:25:46", "revision_id": "71483af6f15ed3fddea10b5f16cf0edbfe4999e5", "snapshot_id": "1eb5878705b06fb79930559a658dd0dc60619c48", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/oslab-swrc/Dark-Insight/71483af6f15ed3fddea10b5f16cf0edbfe4999e5/include/parse_stack.h", "visit_date": "2023-09-03T10:55:58.665671", "added": "2024-11-18T22:42:29.920001+00:00", "created": "2021-11-12T04:25:46", "int_score": 3, "score": 2.84375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0019.json.gz" }
#include "jolt_gui.h" /* Text Screen Structure: * * SCREEN * +--LABEL_0 (title) * +--CONT_BODY * +--LABEL_0 */ static const char TAG[] = "jolt_gui_text"; jolt_gui_obj_t *jolt_gui_scr_text_create( const char *title, const char *body ) { jolt_gui_obj_t *parent = NULL; JOLT_GUI_CTX { parent = BREAK_IF_NULL( jolt_gui_scr_scroll_create( title ) ); jolt_gui_obj_t *label = jolt_gui_scr_scroll_add_text( parent, body ); if( NULL == label ) jolt_gui_obj_del( parent ); } return parent; }
0e9f263e0e557f7c426fcf3c61e63423dd6cc3a1
{ "blob_id": "0e9f263e0e557f7c426fcf3c61e63423dd6cc3a1", "branch_name": "refs/heads/master", "committer_date": "2020-07-19T20:52:28", "content_id": "195087a6aa548ba6cd741d94da302c5dc463d0d4", "detected_licenses": [ "MIT" ], "directory_id": "8ab6cc39fcc28a07a82ad0bb22056570f1921ae0", "extension": "c", "filename": "jolt_gui_text.c", "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": "C", "length_bytes": 559, "license": "MIT", "license_type": "permissive", "path": "/jolt_os/jolt_gui/jolt_gui_text.c", "provenance": "stack-edu-0000.json.gz:104954", "repo_name": "ayworld/jolt_wallet", "revision_date": "2020-07-19T20:52:28", "revision_id": "82f2ffaef99461e0dd3373c60567950cb4d27e30", "snapshot_id": "958a1f514a5768ab8059f4a728880e7c0a9bb28c", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/ayworld/jolt_wallet/82f2ffaef99461e0dd3373c60567950cb4d27e30/jolt_os/jolt_gui/jolt_gui_text.c", "visit_date": "2022-11-19T11:40:33.628532", "added": "2024-11-18T22:58:38.345539+00:00", "created": "2020-07-19T20:52:28", "int_score": 2, "score": 2.046875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0018.json.gz" }
import React from 'react' import Overdrive from 'react-overdrive' import Link from 'next/link' import {css} from 'glamor' css.global('*', { boxSizing: 'border-box' }); css.global('body', { fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif', textRendering: 'optimizeLegibility', margin: 0, fontWeight: 300, lineHeight: 1.4 }); const bold = css({ fontWeight: 400 }); const h1 = css({ fontSize: '32px', fontWeight: 200, lineHeight: '40px', marginTop: 0 }); const image = css({ background: '#fff', width: '80px', height: '80px', borderRadius: '50%', border: '1px solid #ccc', padding: '5px', margin: '10px' }); const container = css({ textAlign: 'center', ' a': { display: 'inline-block' }, marginTop: '50px' }); const inset = css({ width: '480px', maxWidth: '100%', margin: 'auto' }); const originalCharacters = [ { id: 'bender', name: 'Bender', image: '40Wzdn4OQbi2ncxkG96z' }, { id: 'fry', name: 'Fry', image: 'zbglqWZQAyYO5vsHqIbw' }, { id: 'leela', name: 'Leela', image: 'klwhl9wXRIqRTGWFNoBT' }, { id: 'zoidberg', name: 'Zoidberg', image: '6xL1j1OQDC4VLBBLieN7' } ]; const circle = css({ display: 'inline-block', width: '30px', height: '30px', borderRadius: '50%', background: '#3cafe4' }); const square = css({ display: 'inline-block', width: '30px', height: '30px', background: '#3ce4af' }); const triangle = css({ display: 'inline-block', width: '30px', height: '30px', borderStyle: 'solid', borderWidth: '0 15px 30px 15px', borderColor: 'transparent transparent #af3ce4 transparent' }); const code = css({ background: '#272822', color: '#fff', padding: '5px', textAlign: 'left' }); const regular = css({ padding: '60px' }); const inverse = css({ background: '#333', color: 'white', padding: '60px' }); const logos = [ 'spotify.com', 'google.com', 'apple.com', 'facebook.com', 'samsung.com', 'snapchat.com', 'tesla.com', 'walmart.com' ]; const Shape = ({shape, align}) => ( <Overdrive key="shape" id="shape" duration={1000} style={{textAlign: align}}> <div {...shape}/> </Overdrive> ); class page extends React.Component { constructor(props) { super(props); this.state = { logos, turn: 0 }; } componentDidMount() { this.interval = setInterval(() => { this.shuffleCharacters(); }, 2000); } componentWillUnmount() { clearInterval(this.interval); } shuffleCharacters() { const logos = [...this.state.logos]; for (let i = logos.length; i; i--) { let j = Math.floor(Math.random() * i); [logos[i - 1], logos[j]] = [logos[j], logos[i - 1]]; } this.setState({ logos, turn: (this.state.turn + 1) % 3 }); } render() { const {turn} = this.state; return ( <div {...container}> <div {...inset}> <h1 {...h1}> React Overdrive <br/> <span {...bold}>Simple</span> and <span {...bold}>Powerful</span> animations </h1> <code {...code}>npm install react-overdrive --save</code> <div style={{overflow: 'hidden', marginTop: '20px'}}> {turn === 0 && <Shape shape={square} align="left"/>} {turn === 1 && <Shape shape={circle} align="center"/>} {turn === 2 && <Shape shape={triangle} align="right"/>} {turn === 3 && <Shape shape={square} align="center"/>} </div> </div> <p> <strong>React Overdrive</strong> has a simple component based API to transition <strong> any </strong> element to <strong> any </strong> element </p> <div {...inverse}> <div {...inset}> <h1 {...h1}>Animate elements between <strong>different pages</strong></h1> <div style={{marginTop: '20px'}}> {originalCharacters.map(character => ( <Link key={character.id} prefetch href={`/character?id=${character.id}&name=${character.name}&image=${character.image}`}> <a> <Overdrive element="span" id={character.id} style={{display: 'inline-block'}}> <img {...image} src={`https://cdn.filestackcontent.com/${character.image}`}/> </Overdrive> </a> </Link> ))} </div> <small>(Click on a character)</small> </div> </div> <div {...regular}> <div {...inset}> <h1 {...h1}>Shuffle some <strong>Company</strong> logos</h1> <div style={{marginTop: '20px'}}> {this.state.logos.map(character => ( <Overdrive key={character} id={character} style={{display: 'inline-block'}}> <img {...image} src={`https://logo.clearbit.com/${character}`}/> </Overdrive> ))} </div> </div> </div> <div {...inverse}> Check out the GitHub project at <a href="https://github.com/berzniz/react-overdrive" style={{color: 'white'}}>react-overdrive</a> </div> </div> ); } } export default page;
bc9761458ed4cb4f5c6e2b39b8540c3f5f2a7579
{ "blob_id": "bc9761458ed4cb4f5c6e2b39b8540c3f5f2a7579", "branch_name": "refs/heads/master", "committer_date": "2017-04-15T11:54:19", "content_id": "0610ff9473633ce0a8a4b2a9bc23ac3d95ce0b24", "detected_licenses": [ "MIT" ], "directory_id": "8ada6a6ac2b6dd922e9b4473db8d1de7ad3a27d2", "extension": "js", "filename": "index.js", "fork_events_count": 0, "gha_created_at": "2017-04-15T10:42:45", "gha_event_created_at": "2017-04-15T10:42:45", "gha_language": null, "gha_license_id": null, "github_id": 88340684, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 6585, "license": "MIT", "license_type": "permissive", "path": "/demos/website/pages/index.js", "provenance": "stack-edu-0044.json.gz:43064", "repo_name": "yujiangshui/react-overdrive", "revision_date": "2017-04-15T11:54:19", "revision_id": "65c471c6579995238efb656ea62e9f37f4bb34c1", "snapshot_id": "73a304790c534eef860e5fb90501935b7a0126da", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/yujiangshui/react-overdrive/65c471c6579995238efb656ea62e9f37f4bb34c1/demos/website/pages/index.js", "visit_date": "2021-01-19T17:44:07.075460", "added": "2024-11-18T23:55:27.695123+00:00", "created": "2017-04-15T11:54:19", "int_score": 2, "score": 2.078125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0062.json.gz" }
struct HuffmanBinaryTreeNode { int left = 0; int right = 0; int payload = 0; bool filled = false; }; class HuffmanBinaryTree { public: void insert(int value, std::string key); int at(std::string key); private: const static int treeSize = 256; HuffmanBinaryTreeNode tree[treeSize]; int add(int index, int value, std::string key); int get(int index, std::string key); int nextIndex{0}; int getNextIndex(); };
d34cf46bc795be1114a47ad8b65ded80ea803d2b
{ "blob_id": "d34cf46bc795be1114a47ad8b65ded80ea803d2b", "branch_name": "refs/heads/master", "committer_date": "2016-01-02T10:41:05", "content_id": "81099e264b6c1a6f0e8527de126246b5f28a7a11", "detected_licenses": [ "MIT" ], "directory_id": "56663c4447fd84783649085004aa1fb9ac44b5b5", "extension": "h", "filename": "HufffmanBinaryTree.h", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 48906187, "is_generated": false, "is_vendor": false, "language": "C++", "length_bytes": 456, "license": "MIT", "license_type": "permissive", "path": "/HufffmanBinaryTree.h", "provenance": "stack-edu-0009.json.gz:23125", "repo_name": "aoloe/cpp-binary-tree-huffman", "revision_date": "2016-01-02T10:41:05", "revision_id": "1ff68df399949db2407f4d06a75ad7ec14a5a689", "snapshot_id": "d1999d603864a3562718b48a39570e4ac3598f21", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/aoloe/cpp-binary-tree-huffman/1ff68df399949db2407f4d06a75ad7ec14a5a689/HufffmanBinaryTree.h", "visit_date": "2016-08-12T04:15:30.258480", "added": "2024-11-18T22:18:26.523324+00:00", "created": "2016-01-02T10:41:05", "int_score": 3, "score": 2.578125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0027.json.gz" }
<?php define('TYPE_USER',2); function typecheck($id, $usertype){ if ($usertype == TYPE_USER){ $_SESSION['academic']['user']['user_id']=$id; $_SESSION['academic']['user']['usertype']=TYPE_USER; header("location:academic_forum.php"); } else{ echo "invalid username or password"; } }
d80b44ace27c64674f2702f6303d101ef051bf73
{ "blob_id": "d80b44ace27c64674f2702f6303d101ef051bf73", "branch_name": "refs/heads/master", "committer_date": "2017-09-18T07:32:26", "content_id": "adb6dd0e6f1e84ee4646432380ab7fbaa69d9738", "detected_licenses": [ "MIT" ], "directory_id": "4bbedc03e229ee06ced35727a29b316c7c35ad82", "extension": "php", "filename": "typecheck.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 103906262, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 374, "license": "MIT", "license_type": "permissive", "path": "/academic_forum/require/typecheck.php", "provenance": "stack-edu-0053.json.gz:937426", "repo_name": "esi143mhzn/alumni-core-php", "revision_date": "2017-09-18T07:32:26", "revision_id": "1063ae041c01d384cde62fde6441a8ec8e2375a0", "snapshot_id": "54240460601507222b291200f900f35e3cdff996", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/esi143mhzn/alumni-core-php/1063ae041c01d384cde62fde6441a8ec8e2375a0/academic_forum/require/typecheck.php", "visit_date": "2021-07-01T00:18:54.382114", "added": "2024-11-19T02:32:49.492493+00:00", "created": "2017-09-18T07:32:26", "int_score": 2, "score": 2.4375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0071.json.gz" }
<?php namespace frontend\models; use Yii; /** * This is the model class for table "dataanak". * * @property integer $id_anak * @property string $nama_anak * @property string $tempat_lahir * @property string $tanggal_lahir * @property string $tanggal_baptis * @property integer $id_keluarga * * @property Datakeluarga $idKeluarga */ class Dataanak extends \yii\db\ActiveRecord { /** * @inheritdoc */ public static function tableName() { return 'dataanak'; } /** * @inheritdoc */ public function rules() { return [ [['nama_anak', 'tempat_lahir', 'id_keluarga'], 'required'], [['tanggal_lahir', 'tanggal_baptis'], 'safe'], [['id_keluarga'], 'integer'], [['nama_anak', 'tempat_lahir'], 'string', 'max' => 64] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id_anak' => 'Id Anak', 'nama_anak' => 'Nama Anak', 'tempat_lahir' => 'Tempat Lahir', 'tanggal_lahir' => 'Tanggal Lahir', 'tanggal_baptis' => 'Tanggal Baptis', 'id_keluarga' => 'Id Keluarga', ]; } /** * @return \yii\db\ActiveQuery */ public function getIdKeluarga() { return $this->hasOne(Datakeluarga::className(), ['id_datakeluarga' => 'id_keluarga']); } }
86bd06ce2c3f9afad688d8fbc5e3fb7c578a0e74
{ "blob_id": "86bd06ce2c3f9afad688d8fbc5e3fb7c578a0e74", "branch_name": "refs/heads/master", "committer_date": "2016-09-22T14:00:55", "content_id": "c4caaa0bfc49994ba489bf4013b5c2bbab26f7fb", "detected_licenses": [ "BSD-3-Clause" ], "directory_id": "8c65590be045a25cebda379463bab3f31b1c3e7f", "extension": "php", "filename": "Dataanak.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": 1424, "license": "BSD-3-Clause", "license_type": "permissive", "path": "/advanced/frontend/models/Dataanak.php", "provenance": "stack-edu-0052.json.gz:356241", "repo_name": "fajars87/Sistem-Informasi-Gereja-GBKP-Balige", "revision_date": "2016-09-22T14:00:55", "revision_id": "b487099b024d00d7ed514064bca03e1a0c87b368", "snapshot_id": "e86ae90f99704be299a1c18dae88a7abf513e6bf", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/fajars87/Sistem-Informasi-Gereja-GBKP-Balige/b487099b024d00d7ed514064bca03e1a0c87b368/advanced/frontend/models/Dataanak.php", "visit_date": "2021-06-04T07:46:22.678544", "added": "2024-11-18T23:05:20.857711+00:00", "created": "2016-09-22T14:00:55", "int_score": 3, "score": 2.5625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0070.json.gz" }
<link rel="stylesheet" type="text/css" href="public/css/style.css"> <div id="content"> <div class="container"> <div class="cart-info"> <?php if (isset($_SESSION['cart'])) : ?> <p align="center"> Đang có <a href="?c=cart&m=index"> <?php echo count($_SESSION['cart']); ?> </a> sản phẩm trong giỏ hàng. </p> <?php else: ?> <p> Chưa có sản phẩm trong giỏ hàng. </p> <?php endif; ?> </div> <?php foreach ($products as $item) : ?> <div class="item"> <div class="name"> <p> <?php echo $item['name']; ?> </p> </div> <div class="img"> <img src="public/<?php echo $item['img']; ?>"> </div> <div class="price"> <p align="center"> Price : <?php echo $item['price']; ?> $ </p> </div> <div class="add-cart"> <a href="?c=cart&m=addCart&id=<?php echo $item['id']; ?>">Thêm vào giỏ hàng</a> </div> </div> <?php endforeach; ?> </div> </div>
84388596b076de76072f1c534c727ac07c6aa6f9
{ "blob_id": "84388596b076de76072f1c534c727ac07c6aa6f9", "branch_name": "refs/heads/main", "committer_date": "2021-02-02T02:42:39", "content_id": "d55c18c242ebb97bef286690d48d0fb8365d3215", "detected_licenses": [ "Apache-2.0" ], "directory_id": "28690662a4c941865105e2babca003112320eb7a", "extension": "php", "filename": "index.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 335145919, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 1088, "license": "Apache-2.0", "license_type": "permissive", "path": "/baitap/shoppingcart/views/products/index.php", "provenance": "stack-edu-0047.json.gz:492589", "repo_name": "huycanh14/php_olds", "revision_date": "2021-02-02T02:42:39", "revision_id": "1e2923683933760b090b0bc365fac104975ca0a9", "snapshot_id": "f21741ced2310479ba7d8e519a384ee3250e3c6f", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/huycanh14/php_olds/1e2923683933760b090b0bc365fac104975ca0a9/baitap/shoppingcart/views/products/index.php", "visit_date": "2023-02-26T21:08:02.795451", "added": "2024-11-19T03:22:29.760463+00:00", "created": "2021-02-02T02:42:39", "int_score": 2, "score": 2.46875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0065.json.gz" }
let injectionPromise = null; /** * ActiveTabUtility class */ class ActiveTabUtility { /** * Inject the content script and tell it to execute the paste command. */ static pasteInContent() { return new Promise(resolve => { ActiveTabUtility.injectScript().then(() => { chrome.tabs.sendMessage(Extension.activeTab.id, {type: 'paste'}, response => { resolve(); }); }); }); } /** * Inject the content script and tell it to execute the copy command. */ static copyContent() { return new Promise(resolve => { ActiveTabUtility.injectScript().then(() => { chrome.tabs.sendMessage(Extension.activeTab.id, {type: 'copy'}, response => { resolve(); }); }); }); } /** * Check if the content script has already been injected. * If not, inject the content script. */ static injectScript() { return new Promise((resolve, reject) => { if (Extension.activeTab.url.indexOf('chrome://') === -1) { chrome.tabs.executeScript({ code: 'typeof ContentInjector === "function";' }, isLoaded => { if (isLoaded[0]) { resolve(); } else { chrome.tabs.executeScript({ file: 'scripts/content/inject.js' }, () => { resolve(); }); } }); } }); } }
d1d1cc04a6e0b2be891cb69dce6b3df3a3545c2f
{ "blob_id": "d1d1cc04a6e0b2be891cb69dce6b3df3a3545c2f", "branch_name": "refs/heads/master", "committer_date": "2017-08-29T18:52:21", "content_id": "80e8066bfdecdda47046e9eea2cc7c9e352348d5", "detected_licenses": [ "MIT" ], "directory_id": "38dfc0ea1b6a7ea4e6c8e4be553d5926d49c8505", "extension": "js", "filename": "active-tab-utility.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": 1694, "license": "MIT", "license_type": "permissive", "path": "/scripts/background/active-tab-utility.js", "provenance": "stack-edu-0045.json.gz:704165", "repo_name": "chfoidl/chrome-clipboard2plaintext", "revision_date": "2017-08-29T18:52:21", "revision_id": "05597ad5db83257a51b99692060e3d8cb2478516", "snapshot_id": "326cd2ab7860e096cbe76c59e300a3558a092c99", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/chfoidl/chrome-clipboard2plaintext/05597ad5db83257a51b99692060e3d8cb2478516/scripts/background/active-tab-utility.js", "visit_date": "2021-07-14T14:08:07.679940", "added": "2024-11-18T21:45:17.913689+00:00", "created": "2017-08-29T18:52:21", "int_score": 2, "score": 2.46875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0063.json.gz" }
<?php namespace AppBundle\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use AppBundle\Entity\UserData; use AppBundle\Entity\UserFood; use AppBundle\Form\UserFoodForm; use AppBundle\Entity\Category; use AppBundle\Entity\Subcategory; use AppBundle\Entity\Food; use AppBundle\Service\MessageGenerator; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpFoundation\JsonResponse; class FoodSubcategoryController extends Controller { /** * @Route("/dodaj_produkt/{subcategory}", name="product_subcategory") */ public function showSubcategoryAction(Request $request, Subcategory $subcategory = null, SessionInterface $session, MessageGenerator $messageGenerator) { $products = $subcategory->getProduct(); $categoryName = $subcategory->getCategoryId()->getName(); $userFood = new UserFood(); $form = $this->createForm(UserFoodForm::class, $userFood); $form->handleRequest($request); if ($request->isXmlHttpRequest()) { $productArray = $this->getNutrients($products); return new JsonResponse($productArray); } $sessionMeal = $session->get('meal'); $user = $this->getUser(); if ($form->isSubmitted() && $form->isValid()) { $this->flushUserFood($form, $userFood, $session); $message = $messageGenerator->addProductMessage(); $this->addFlash('notice', $message); return $this->redirectToRoute('homepage'); } return $this->render('diet/subcategory.html.twig', [ 'products' => $products, 'category' => $categoryName, 'meal' => $sessionMeal, 'form' => $form->createView(), ]); } private function getNutrients($products) { $request = Request::createFromGlobals(); $productId = $request->get('productId'); $product = $products->get($productId); $foodId = $product->getId(); $name = $product->getName(); $calories = $product->getCalories(); $protein = $product->getTotalProtein(); $carbohydrates = $product->getCarbohydrates(); $fat = $product->getFat(); return $productArray = [ 'name' => $name, 'calories' => $calories, 'protein' => $protein, 'carbohydrates' => $carbohydrates, 'fat' => $fat, 'foodId' => $foodId, ]; } private function flushUserFood($form, UserFood $userFood, SessionInterface $session) { $userFood->setUserId($this->getUser()); $pickedDate = $session->get('pickedDate'); $userFood->setDate(new \DateTime($pickedDate)); $dbUserFood = $this->getDoctrine()->getManager(); $dbUserFood->persist($userFood); $dbUserFood->flush(); } }
5d7a60134b91caf2d534499389b1b97aa0136b87
{ "blob_id": "5d7a60134b91caf2d534499389b1b97aa0136b87", "branch_name": "refs/heads/master", "committer_date": "2018-07-19T18:18:10", "content_id": "83aedd7c27e125b614c5a79bf8709bc70110e5b1", "detected_licenses": [ "MIT" ], "directory_id": "784f47abc9ef660f1e42ea8f63f6575d636c618f", "extension": "php", "filename": "FoodSubcategoryController.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 108909770, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 2996, "license": "MIT", "license_type": "permissive", "path": "/src/AppBundle/Controller/FoodSubcategoryController.php", "provenance": "stack-edu-0047.json.gz:711951", "repo_name": "lasekmiroslaw/Diet_training", "revision_date": "2018-07-19T18:18:10", "revision_id": "c9303f925dc84fd0d30b2e1c2f4e89afbf763ed4", "snapshot_id": "ebeae4e7d55a90e596a813fddb517394627b5606", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/lasekmiroslaw/Diet_training/c9303f925dc84fd0d30b2e1c2f4e89afbf763ed4/src/AppBundle/Controller/FoodSubcategoryController.php", "visit_date": "2021-09-18T20:41:45.539675", "added": "2024-11-18T23:10:34.910048+00:00", "created": "2018-07-19T18:18:10", "int_score": 2, "score": 2.328125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0065.json.gz" }
<?php /* * Copyright 2014 Google Inc. * * 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. */ namespace Google\Service\HangoutsChat; class DialogAction extends \Google\Model { protected $actionStatusType = ActionStatus::class; protected $actionStatusDataType = ''; protected $dialogType = Dialog::class; protected $dialogDataType = ''; /** * @param ActionStatus */ public function setActionStatus(ActionStatus $actionStatus) { $this->actionStatus = $actionStatus; } /** * @return ActionStatus */ public function getActionStatus() { return $this->actionStatus; } /** * @param Dialog */ public function setDialog(Dialog $dialog) { $this->dialog = $dialog; } /** * @return Dialog */ public function getDialog() { return $this->dialog; } } // Adding a class alias for backwards compatibility with the previous class name. class_alias(DialogAction::class, 'Google_Service_HangoutsChat_DialogAction');
18932a4489179066a0aa76dd724d7a6c7e9c81ac
{ "blob_id": "18932a4489179066a0aa76dd724d7a6c7e9c81ac", "branch_name": "refs/heads/main", "committer_date": "2023-09-03T01:04:12", "content_id": "fd1b0dca69ae323324604517b887d569bff5e98a", "detected_licenses": [ "Apache-2.0" ], "directory_id": "691540caaf8a49878bce033ca440bb401db76da0", "extension": "php", "filename": "DialogAction.php", "fork_events_count": 210, "gha_created_at": "2016-03-04T22:12:28", "gha_event_created_at": "2023-09-14T01:06:15", "gha_language": "PHP", "gha_license_id": "Apache-2.0", "github_id": 53168835, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 1483, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/HangoutsChat/DialogAction.php", "provenance": "stack-edu-0053.json.gz:581977", "repo_name": "googleapis/google-api-php-client-services", "revision_date": "2023-09-03T01:04:12", "revision_id": "fe2f7513dc5a4a6cf82715fd0edf7589423d6535", "snapshot_id": "310073b01c2efb65795b940b050e6de2cd2d0d6a", "src_encoding": "UTF-8", "star_events_count": 848, "url": "https://raw.githubusercontent.com/googleapis/google-api-php-client-services/fe2f7513dc5a4a6cf82715fd0edf7589423d6535/src/HangoutsChat/DialogAction.php", "visit_date": "2023-09-04T11:07:14.213191", "added": "2024-11-18T22:17:31.251724+00:00", "created": "2023-09-03T01:04:12", "int_score": 2, "score": 2.265625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0071.json.gz" }
/* * * Copyright 2020 Wei-Ming Wu * * 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 com.github.wnameless.json.base; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import com.google.gson.reflect.TypeToken; public class JsonArrayBaseTest { String str = "text"; int i = 123; long l = 1234567890123456789L; double d = 45.67; boolean bool = true; Object obj = null; BigInteger bi = new BigInteger("1234567890123456789012345678901234567890"); BigDecimal bd = new BigDecimal("45.678912367891236789123678912367891236789123"); JsonPOJO jo = new JsonPOJO() { { setStr(str); setNum(new ArrayList<Number>() { private static final long serialVersionUID = 1L; { add(i); add(l); add(d); add(bi); add(bd); } }); setBool(bool); setObj(obj); } }; JsonArrayBase<?> gsonAry; JsonArrayBase<?> jacksonAry; @BeforeEach public void init() { Gson gson = new GsonBuilder().serializeNulls().create(); JsonElement jsonElement = gson.toJsonTree(jo, new TypeToken<JsonPOJO>() {}.getType()); gsonAry = new GsonJsonValue(jsonElement).asObject().get("num").asArray(); JsonNode jsonNode = new ObjectMapper().valueToTree(jo); jacksonAry = new JacksonJsonValue(jsonNode).asObject().get("num").asArray(); } @Test public void testGet() { assertEquals(i, gsonAry.get(0).asNumber()); assertEquals(l, gsonAry.get(1).asNumber()); assertEquals(d, gsonAry.get(2).asNumber()); assertEquals(bi, gsonAry.get(3).asNumber()); assertEquals(bd, gsonAry.get(4).asNumber()); assertEquals(i, jacksonAry.get(0).asNumber()); assertEquals(l, jacksonAry.get(1).asNumber()); assertEquals(d, jacksonAry.get(2).asNumber()); assertEquals(bi, jacksonAry.get(3).asNumber()); assertEquals(bd, jacksonAry.get(4).asNumber()); } @Test public void testSize() { assertEquals(5, gsonAry.size()); assertEquals(5, jacksonAry.size()); } @Test public void testIsEmpty() { assertFalse(gsonAry.isEmpty()); assertFalse(jacksonAry.isEmpty()); gsonAry = new GsonJsonCore().parse("[]").asArray(); jacksonAry = new JacksonJsonCore().parse("[]").asArray(); assertTrue(gsonAry.isEmpty()); assertTrue(jacksonAry.isEmpty()); } @Test public void testToList() { List<Object> num = new ArrayList<>(); num.addAll(Arrays.asList(i, l, d, bi, bd)); assertEquals(num, gsonAry.toList()); assertEquals(num, gsonAry.toList()); } }
4fc77452f94779aac7b92123be6e520445763b85
{ "blob_id": "4fc77452f94779aac7b92123be6e520445763b85", "branch_name": "refs/heads/master", "committer_date": "2020-12-25T07:32:20", "content_id": "414b73aab7b149fa0384564fbd7d2cc17d1ab9e8", "detected_licenses": [ "Apache-2.0" ], "directory_id": "49089a4d72068d5683a1ea11b61f32d21319d312", "extension": "java", "filename": "JsonArrayBaseTest.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": 3600, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/test/java/com/github/wnameless/json/base/JsonArrayBaseTest.java", "provenance": "stack-edu-0023.json.gz:793893", "repo_name": "chaohaizhen/json-base", "revision_date": "2020-12-25T07:32:20", "revision_id": "6edf22ed4bd86c17b8dea12e62f423ab8858b54e", "snapshot_id": "1ff67ef9806ba74773c05c4debb90b7df3bd2b44", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/chaohaizhen/json-base/6edf22ed4bd86c17b8dea12e62f423ab8858b54e/src/test/java/com/github/wnameless/json/base/JsonArrayBaseTest.java", "visit_date": "2023-02-04T11:09:24.909198", "added": "2024-11-18T21:41:54.450417+00:00", "created": "2020-12-25T07:32:20", "int_score": 2, "score": 2.296875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0041.json.gz" }
(function() { window.App = { Views: {}, Models: {}, Collecions: {}, Router: {} }; //шаблончик window.template = function(id) { return _.template( $('#' + id).html() ); }; App.Router = Backbone.Router.extend({ routers: { '' : 'index', 'read' : 'read' }, index: function() { console.log('Running'); }, read: function() { console.log('Royt'); } }); new App.Router(); Backbone.history.start(); })();
a28bf3948509fd646aa8af5d51e4b4000912b37c
{ "blob_id": "a28bf3948509fd646aa8af5d51e4b4000912b37c", "branch_name": "refs/heads/master", "committer_date": "2016-12-06T14:54:39", "content_id": "9573190b50f5c4f89b24707569fab8849af9e037", "detected_licenses": [ "MIT" ], "directory_id": "5c6fb5cb4c905234d24a8f962b6f050a5d2ee85f", "extension": "js", "filename": "mainmm17.js", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 72440327, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 442, "license": "MIT", "license_type": "permissive", "path": "/mainmm17.js", "provenance": "stack-edu-0044.json.gz:268223", "repo_name": "Lndqw12/BackBoneJs", "revision_date": "2016-12-06T14:54:39", "revision_id": "481c0fc64eb96579aa0686198984de45ebbbf833", "snapshot_id": "cf5647b3f96683320bb9b250eb55a425e254a37c", "src_encoding": "WINDOWS-1251", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Lndqw12/BackBoneJs/481c0fc64eb96579aa0686198984de45ebbbf833/mainmm17.js", "visit_date": "2021-01-13T12:46:36.534996", "added": "2024-11-18T20:54:29.014837+00:00", "created": "2016-12-06T14:54:39", "int_score": 2, "score": 2.421875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0062.json.gz" }
--- layout: post title: "Sorting Array by Attribute in ES6" date: 2016-12-03 --- {% highlight javascript %} [ {name: 'Dominika',age: 2}, {name: 'Lilia', age: 31}, {name: 'Andrei', age: 32}, {name: 'Jan', age: 6} ].sort((a, b) => a.age - b.age) /* will print [ { name: 'Dominika', age: 2 }, { name: 'Jan', age: 6 }, { name: 'Lilia', age: 31 }, { name: 'Andrei', age: 32 } ] */ {% endhighlight %} ### Why? - [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) - [Implicit return in consise function body](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions#Function_body)
78f94cb7a67b9b14af1657f20c5c7a9b2bd9417e
{ "blob_id": "78f94cb7a67b9b14af1657f20c5c7a9b2bd9417e", "branch_name": "refs/heads/master", "committer_date": "2016-12-04T21:37:04", "content_id": "b694b1d62dd0052d6893e659955a1f428bc7bca5", "detected_licenses": [ "MIT" ], "directory_id": "e86441d1d706fa0cf2e8f6891bfc4f383efdc1af", "extension": "md", "filename": "2016-12-03-sort-arrays.md", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 11861837, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 694, "license": "MIT", "license_type": "permissive", "path": "/_posts/2016-12-03-sort-arrays.md", "provenance": "stack-edu-markdown-0001.json.gz:10674", "repo_name": "miktam/miktam.github.io", "revision_date": "2016-12-04T21:37:04", "revision_id": "6d9e117876dd443aa61dab4f1d55d85ffd9670e5", "snapshot_id": "1311cf35c697bc64b4a265434283ce0fe09f72ba", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/miktam/miktam.github.io/6d9e117876dd443aa61dab4f1d55d85ffd9670e5/_posts/2016-12-03-sort-arrays.md", "visit_date": "2021-01-02T22:17:05.931440", "added": "2024-11-18T21:31:25.732133+00:00", "created": "2016-12-04T21:37:04", "int_score": 3, "score": 2.796875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0001.json.gz" }
<?php namespace App\Http\Controllers\Space; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use App\EventLog; class EventLogController extends \App\Http\Controllers\Controller { /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('auth'); $this->middleware('verified'); } /** * Show the application dashboard. */ public function index(Request $request) { $eventLogs = EventLog::paginate(100); if( !isset( $request->page ) ){ // 最後のページ(=最新のログ)をデフォルトにする return redirect('/space/event-logs?page='.urlencode($eventLogs->lastPage())); } return view( 'space.event-logs.index', array( 'eventLogs' => $eventLogs, ) ); } }
292f9163dd6d9e2f62715a5cf4686477c6d770c3
{ "blob_id": "292f9163dd6d9e2f62715a5cf4686477c6d770c3", "branch_name": "refs/heads/main", "committer_date": "2022-06-25T11:33:04", "content_id": "e7ef46f8de61c7e6eb7e2244edfa90284f50adc7", "detected_licenses": [ "MIT" ], "directory_id": "d47750b4004df60c48d089c37791de63fd2efb65", "extension": "php", "filename": "EventLogController.php", "fork_events_count": 3, "gha_created_at": "2018-09-10T11:56:33", "gha_event_created_at": "2022-12-10T17:32:14", "gha_language": "PHP", "gha_license_id": null, "github_id": 148147962, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 792, "license": "MIT", "license_type": "permissive", "path": "/app/Http/Controllers/Space/EventLogController.php", "provenance": "stack-edu-0051.json.gz:440319", "repo_name": "pickles2/app-burdock", "revision_date": "2022-06-25T11:33:04", "revision_id": "1fffd3bc75a1b0943aaa02ecee6dd06836facf55", "snapshot_id": "85ad284f1cc585d5170ef821217f3abeee0d7a4d", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/pickles2/app-burdock/1fffd3bc75a1b0943aaa02ecee6dd06836facf55/app/Http/Controllers/Space/EventLogController.php", "visit_date": "2022-12-14T02:29:28.490788", "added": "2024-11-19T03:30:58.819782+00:00", "created": "2022-06-25T11:33:04", "int_score": 2, "score": 2.484375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0069.json.gz" }
# Introduction These are some dirty tricks for some interactive Scheme calculations. **Conventions:** We indicate a mathematical constant by prepending a colon to the identifier. So, for example, `:pi` refers to the mathematical constant approximately 3.141, `:e` refers to Euler's constant, `:golden-ratio` refers to...well, you get the idea. ## Infinities We will declare infinity as a constant. Specifically, there are 4 of interest (plus-or-minus infinity, and plus-or-minus imaginary infinity): ```scheme (define :+inf.0 (/ 1.0 0.0)) (define :-inf.0 (/ -1.0 0.0)) (define :+inf.i (/ +i 0.0)) (define :-inf.i (/ -i 0.0)) (define (complex-number? z) (and (number? z) (not (real? z)))) (define (real-infinite? x) (and (flo:flonum? x) (not (flo:finite? x)))) (define (infinite? z) (if (complex-number? z) (or (real-infinite? (real-part z)) (real-infinite? (imag-part z))) (real-infinite? z))) (define (finite? z) (not (infinite? z))) ``` It's mildly cavalier to treat infinity like a number, but meh the nervous programmer can rest assured we can always use Stereographic projection to embed the complex numbers into a compact space and work from there. (It's a triviality!) One disadvantage is that we cannot say `(= x :+inf.0)` for example, Scheme will throw a fit. Instead, we can test indirectly for finiteness. ## Floating Point Equality We can't always use `(= a b)` to test equality for floating point numbers `a` and `b`. Instead, following Donald Knuth (as in his *TAOCP*, vol 2, third ed., pp 233-235), we say `(float= a b)` if and only if `(<= (abs (- a b)) (* tol (abs a)))` and `(<= (abs (- a b)) (* tol (abs b)))`. Usually `tol` is machine epsilon. We see these two conditions hold if the absolute difference is less than `(* tol (min (abs a) (abs b)))`. This is our definition! ```scheme (define (float= a b) (<= (/ (abs (- a b)) (/ (+ 1.0 (min (abs a) (abs b))) 2)) 1e-16)) ``` ## Continued Fractions I took a more general approach than SICP, using Generalized continued fractions explicitly (SICP uses them implicitly and it is mildly confusing). ```scheme (define (inc x) (+ 1 x)) ;; wikipedia's notation for a generalized continued fraction (define (generalized-cont-frac a b k) (define (recur i) (if (> i k) 0 (/ (a i) (+ (b i) (recur (inc i)))))) (recur 1)) ;; a continued fraction is a generalized continued fraction with a=1 (define (cont-frac b k) (generalized-cont-frac (lambda (i) 1) b k)) ``` Great, so lets have some fun with this. There's a quick way to compute _e_ (Euler's constant): ```scheme (define (euler-cont-frac-term k) (if (= k 1) 1 (* 2 (- (* 2 k) 1)))) (define (euler-e k) (+ 1.0 (* 2.0 (cont-frac euler-cont-frac-term k)))) ;; (euler-e 7) => 2.7182818284590455 (define :e (euler-e 10)) ``` ### Golden Ratio The famous continued fraction for the Golden ratio is quite simple [1; 1, 1, 1, ...]. ```scheme (define (phi k) (+ 1 (* 1.0 (cont-frac (lambda (i) 1) k)))) ;; (phi 36) => 1.618033988749894 (define :golden-ratio (/ (1 + (sqrt 5)) 2)) ``` We have asserts to see how good `(phi k)` is at approximating `:golden-ratio`. ### ArcTangent Function and other Inverse Trigonometric Functions The inverse tangent function ("arc-tangent" function) can be computed using continued fractions as well. There are two different ways to do it. Euler gives us one approach: ```scheme (define (euler-arctan z k) (generalized-cont-frac (lambda (j) (if (= j 1) z (square (* z (- (* 2 j) 3))))) (lambda (j) (if (= j 1) 1 (- (- (* 2 j) 1) (* (- (* 2 j) 3) (square z))))) k)) ;; see, e.g., http://en.wikipedia.org/wiki/Computing_%CF%80#Other_classical_formulae (define :pi (+ (* 20 (euler-arctan (/ 1 7) 45)) (* 8 (euler-arctan (/ 3 79) 45)))) (define :2pi (* 2 :pi)) (define :pi/4 (+ (* 5 (euler-arctan (/ 1 7) 45)) (* 2 (euler-arctan (/ 3 79) 45)))) (define :pi/2 (* :pi/4 2)) ``` We use various identities with the arctangent function to "reduce the range". ```scheme (define (real-arctan x) (cond ((infinite? x) (* (if (positive? x) 1 -1) :pi/2)) ((> (abs x) 10) (- :pi/2 (real-arctan (/ 1 x)))) ((> (abs x) 0.9) (* 2 (euler-arctan (/ x (inc (sqrt (inc (square x))))) 25))) (else (euler-arctan x 25)))) ;; holder for more general arctangent function (define (arctan x) (real-arctan x)) ``` Observe we have to use `(eqv? x :+inf.0)` to check if the number is infinite or not. Now, we can use the arctangent to compute the arc-sine and arc-cosine functions. ```scheme (define (arccot x) (arctan (/ 1 x))) (define (arcsin x) (* 2 (arctan (/ x (inc (sqrt (- 1 (square x)))))))) (define (arccsc x) (arcsin (/ 1 x))) (define (arccos x) (- :pi/2 (arcsin x))) (define (arcsec x) (arccos (/ 1 x))) ``` ### Tangent and other Trigonometric Functions We can compute special functions as continued fractions, for example: ```scheme (define (tan-cf x k) (generalized-cont-frac (lambda (i) (if (= 1 i) x (- (square x)))) (lambda (i) (- (* 2 i) 1)) k)) ``` We can consider sine as a continued fraction, then use the identity `(= (cos x) (sin (- (/ :pi 2) x)))` to compute cosine. The problem with this approach is the sine continued fraction is...well, quite bizarre, and it's hard to handle range reduction. What we do instead is: consider the Taylor series. This is a common approach, decrease by multiples of pi, then plug it into the Taylor series. It works for "small-er" values, but for say "huge `x`"...we have unavoidable problems. We implicitly put the truncated Taylor series in [Horner form](http://en.wikipedia.org/wiki/Horner%27s_method). ```scheme ;; need 8 terms to get machine precision after range-reduction (define (sine-taylor-series x) (define (iter k result) (if (= 0 k) (* x result) (iter (- k 1) (+ 1 (* (/ (- (square x)) (* (* 2 k) (inc (* 2 k)))) result))))) (iter 20 1)) (define (sine-range-reduce x) (truncate (+ (/ x :pi) (/ 1 2)))) (define (sin x) ((lambda (n) (* (if (even? n) 1 -1) (sine-taylor-series (- x (* :pi n))))) (sine-range-reduce x))) (define (cos x) (sin (- :pi/2 x))) (define (csc x) (/ 1 (sin x))) (define (sec x) (/ 1 (cos x))) (define (cot x) (/ 1 (tan x))) ``` We do a crude form of range reduction when computing sine, it could (and should) be improved in the future. # Exponentiation Exponentiation occurs quite frequently in mathematics, so we should probably implement it. We note the identity `b^(-n)=(1/b)^n` is implemented, but the following implementation works if and only if `n` is an integer. ```scheme (define (even? n) (= (remainder n 2) 0)) (define (fast-expt b n) (cond ((infinite? n) (if (negative? n) 0 :+inf.0)) ((= n 0) 1) ((< n 0) (fast-expt (/ 1 b) (- n)))) (else (* (if (even? n) 1 b) (fast-expt (* b b) (quotient n 2)))))) ``` What do we do for fractional `n`? ## Exponential Function We use Euler's constant as the base, then use the natural logarithm to modify the exponent. We introduce the exponential function as a continued fraction (see, e.g., [wikipedia](https://en.wikipedia.org/wiki/Exponential_function#Continued_fractions_for_ex)): ```scheme (define (euler-exp-a z k) (if (= 1 k) (* 2 z) (square z))) (define (euler-exp-b z k) (+ 2 (if (= 1 k) (- z) (* (- k 1) 4)))) (define (exp-cf z k) (+ 1.0 (generalized-cont-frac (lambda (j) (euler-exp-a z j)) (lambda (j) (euler-exp-b z j)) k))) ``` We can combine the continued fraction and the "old-fashioned power" function to get a better exponential function: ```scheme (define (exp z) (* (fast-expt :e (truncate z)) (exp-cf (- z (truncate z)) 8))) (assert (= (exp-cf 1 8) :e)) (assert (= (exp 1) :e)) ``` Well, really, this is partially true. It's true for *real* `z`. To implement the exponential function for *complex* `z`, we would have ```scheme (define (real-exp z) (* (fast-expt :e (truncate z)) (exp-cf (- z (truncate z)) 8))) (define (exp z) (if (and (number? z) (not (real? z))) (* (real-exp (real-part z)) (+ (cos (imag-part z)) (* +i (sin (imag-part z))))) (real-exp z))) ``` ## Hyperbolic Trigonometric Functions We can easily implement hyperbolic trigonometric functions now that we have the exponential: ```scheme (define (sinh x) (/ (- (exp x) (exp (- x))) 2)) (define (csch x) (/ 1 (sinh x))) (define (cosh x) (/ (+ (exp x) (exp (- x))) 2)) (define (sech x) (/ (cosh x))) (define (tanh x) (/ (sinh x) (cosh x))) (define (coth x) (/ (cosh x) (sinh x))) ``` ## Logarithms We use Newton's method for calculating the natural logarithm, but with some precautions: namely, we have a "counter limit" (we iterate at most 53 times): ```scheme (define (newtons-method f deriv guess n) ((lambda (iterate) (if (or (> n 53) (float= (- guess iterate) guess)) (- guess iterate) (newtons-method f deriv (- guess iterate) (inc n)))) (/ (f guess) (deriv guess)))) ``` Then we just use this to figure out the natural logarithm, since `(exp (ln x))` is identical with `x`. So given `c`, we compute its natural logarithm by finding the root to the function `(lambda (x) (- (exp x) c))`. We do some simplifications, namely, we precompute `ln 1` is zero, and we recursively factor out multiples of 10 until we get a "small enough number". c) :+inf.0) ((= c 0) :-inf.0) ((= c 1) 0) ((> c 10) (+ (approx-real-ln (/ c 10)) :ln-10)) ((> c :e) (+ (approx-real-ln (remainder c :e)) (quotient c :e))) (else (ln-iterate c)))) (define (real-ln z) ((lambda (y) (+ y (ln-iterate (/ c (exp y))))) (approx-real-ln z))) (define (ln z) (if (complex-number? z) (+ (real-ln (magnitude z)) (* +i (angle z))) (real-ln z))) ``` We can use the law of logarithms to implement logarithms in other bases, e.g., ```scheme (define :ln-2 (ln 2)) ;; base-2 logarithm (define (lg x) (/ (ln x) :ln-2)) ;; base-10 logarithm (define (log x) (/ (ln x) :ln-10)) ``` ### Inverse Trig Functions Redux We had a temporary placeholder for `arctan`. Now that we have the logarithm function defined for, well, all values, then we can compute the arc-tangent function for complex values. ```scheme (define (arctan z) (if (complex-number? z) (* (/ +i 2) (ln (/ (- 1 (* +i z)) (+ 1 (* +i z))))) (real-arctan z))) ``` We can also consider the inverse hyperbolic trigonometric functions: ```scheme (define (arccosh x) (ln (+ x (sqrt (inc (square x)))))) (define (arcsinh x) (ln (+ x (sqrt (- (square x) 1))))) (define (arctanh x) (/ (ln (/ (+ 1 x) (- 1 x))) 2)) ``` # Square Roots We can use Newton's method to quickly implement the squareroot, since it's essentially the root to the problem `(identical? (sqrt x) (- (square z) x))`. So we have: ```scheme (define (real-sqrt x) (cond ((negative? x) (* +i (real-sqrt (abs x)))) ((> x 100) (* 10 (real-sqrt (/ x 100)))) (else (newtons-method (lambda (t) (- (square t) x)) (lambda (t) (* 2 t)) (/ (inc x) 2) 0)))) (define (sqrt x) (if (complex-number? x) (* (real-sqrt (magnitude x)) (exp (* +i (angle x) (/ 1 2)))) (real-sqrt x))) ``` This is actually more precise than if we use floating point arithmetic. For example, `(sqrt 2)` gives us `886731088897/627013566048` -- we should note `(- (square (sqrt 2)) 2)` is about `-2.5e-24`. Similarly, `(- (square (sqrt 3)) 3)` gives us about `-6e-18`. This is beyond machine precision! # Factorials and Friends We have the run-of-the-mill factorial function: ```scheme (define (factorial n) (fact-iter 1 1 n)) (define (fact-iter product counter max-count) (if (> counter max-count) product (fact-iter (* counter product) (inc counter) max-count))) ``` This is actually horribly inefficient for large `n`. This allows us to write the binomial coefficient: ```scheme (define (choose n k) (if (> k n) 0 (/ (factorial n) (* (factorial k) (factorial (- n k)))))) ``` ### Stirling Numbers We can now compute Stirling numbers. We introduce the `sum` function: ```scheme (define (sum term a next b) (define (iter a result) (if (> a b) result (iter (next a) (+ (term a) result)))) (iter a 0)) ``` Then we can construct Stirling numbers of the second kind: ```scheme (define (stirling-s2 n k) (cond ((> k n) 0) ((zero? k) (if (zero? n) 1 0)) ((= k 1) 1) ((= n k) 1) (else (sum (lambda (j) (/ (* (if (even? (- k j)) 1 -1) (fast-expt j (- n 1))) (* (factorial (- j 1)) (factorial (- k j))))) 1 inc k)))) ```
8dbe1c968b7e35e28be7585dae0ef663922b3a57
{ "blob_id": "8dbe1c968b7e35e28be7585dae0ef663922b3a57", "branch_name": "refs/heads/master", "committer_date": "2014-02-09T17:27:54", "content_id": "3e42374f464f31b6857e89b0d66ee2aff2c738ae", "detected_licenses": [ "MIT" ], "directory_id": "46a26f8b026f5b7036bebd9d0baaa6edf18bfe12", "extension": "md", "filename": "doc.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": 13833, "license": "MIT", "license_type": "permissive", "path": "/doc/doc.md", "provenance": "stack-edu-markdown-0004.json.gz:45269", "repo_name": "pqnelson/calculator", "revision_date": "2014-02-09T17:27:54", "revision_id": "d8fd94703dcbe7917dbcc140fd0f5271093379c4", "snapshot_id": "4d8be428e2efc45bb40c0f3f8f193806a6049449", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/pqnelson/calculator/d8fd94703dcbe7917dbcc140fd0f5271093379c4/doc/doc.md", "visit_date": "2016-09-05T21:42:41.524941", "added": "2024-11-19T03:43:37.530409+00:00", "created": "2014-02-09T17:27:54", "int_score": 4, "score": 3.921875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0004.json.gz" }
<?php namespace App\Http\Controllers\page; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Mail; use App\Mail\Transmision; use App\Mail\Trabajo; use App\Mail\Pago; use App\Mail\Consulta; use App\Mail\Contacto; use App\Email; class FormController extends Controller { public $secret = "6LeFv6IUAAAAAPY4fMwTKKJ957JoVkMoaANobzvm"; public function index(Request $request, $seccion) { $datosRequest = $request->all(); unset($datosRequest["_method"]); unset($datosRequest["_token"]); if($seccion == "trabaje") return self::$seccion($request, $datosRequest, $request->file('curriculum')); else return self::$seccion($datosRequest); /** * ATENCIÓN AL CLIENTE: atencionalcliente@ventor.com.ar * INFORMACIÓN DE PAGOS: cuentascorrientes@ventor.com.ar * CONSULTA GENERAL: atencionalcliente@ventor.com.ar * TRABAJE CON NOSOTROS: recursoshumanos@ventor.com.ar * CONTACTO: */ } public function transmision($data) { $email = Email::where("formulario","atencion")->first(); Mail::to('corzo.pabloariel@gmail.com')->send(new Transmision($data)); Mail::to($email["email"])->send(new Transmision($data)); if (count(Mail::failures()) > 0) return back()->withErrors(['mssg' => "Ha ocurrido un error al enviar el correo"]); else return back()->withSuccess(['mssg' => "Correo enviado correctamente"]); } public function pagos($data) { $email = Email::where("formulario","pagos")->first(); if(empty($data["g-recaptcha-response"])) return back()->withInput($data)->withErrors(['mssg' => "Captcha no seleccionado"]); if(!isset($data["terminos"])) return back()->withInput($data)->withErrors(['mssg' => "Acepte los términos y condiciones"]); Mail::to('corzo.pabloariel@gmail.com')->send(new Pago($data)); Mail::to($email["email"])->send(new Pago($data)); if (count(Mail::failures()) > 0) return back()->withErrors(['mssg' => "Ha ocurrido un error al enviar el correo"]); else return back()->withSuccess(['mssg' => "Correo enviado correctamente"]); } public function consulta($data) { $email = Email::where("formulario","consulta")->first(); if(empty($data["g-recaptcha-response"])) return back()->withInput($data)->withErrors(['mssg' => "Captcha no seleccionado"]); if(!isset($data["terminos"])) return back()->withInput($data)->withErrors(['mssg' => "Acepte los términos y condiciones"]); Mail::to('corzo.pabloariel@gmail.com')->send(new Consulta($data)); Mail::to($email["email"])->send(new Consulta($data)); if (count(Mail::failures()) > 0) return back()->withErrors(['mssg' => "Ha ocurrido un error al enviar el correo"]); else return back()->withSuccess(['mssg' => "Correo enviado correctamente"]); } public function trabaje($request, $data, $archivo) { //dd($archivo); $email = Email::where("formulario","trabaje")->first(); //Mail::to($mandar)->send(new Contacto($data)); $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$this->secret}&response={$data["g-recaptcha-response"]}&remoteip=".$_SERVER['REMOTE_ADDR']); $response = json_decode($response, true); //if($response["success"] == false) //return back()->withErrors(['mssg' => "Ha ocurrido un error de captcha"]); Mail::to('corzo.pabloariel@gmail.com')->send(new Trabajo($data, $archivo)); Mail::to('ventor@ventor.com.ar')->send(new Trabajo($data, $archivo)); Mail::to($email["email"])->send(new Trabajo($data, $archivo)); if (count(Mail::failures()) > 0) return back()->withErrors(['mssg' => "Ha ocurrido un error al enviar el correo"]); else return back()->withSuccess(['mssg' => "Correo enviado correctamente"]); } public function contacto($data) { $mandar = $data["mandar"]; $email = Email::where("formulario","contacto")->first(); if(empty($data["g-recaptcha-response"])) return back()->withInput($data)->withErrors(['mssg' => "Captcha no seleccionado"]); if(!isset($data["terminos"])) return back()->withInput($data)->withErrors(['mssg' => "Acepte los términos y condiciones"]); Mail::to('corzo.pabloariel@gmail.com')->send(new Contacto($data)); Mail::to($mandar)->send(new Contacto($data)); if (count(Mail::failures()) > 0) return back()->withErrors(['mssg' => "Ha ocurrido un error al enviar el correo"]); else return back()->withSuccess(['mssg' => "Correo enviado correctamente"]); } }
7b2ca3420fd7a8df565910ac426605487006e6f0
{ "blob_id": "7b2ca3420fd7a8df565910ac426605487006e6f0", "branch_name": "refs/heads/master", "committer_date": "2020-01-06T19:12:56", "content_id": "f4f8bb5f47387fc62b39d2c09ec135908c16766f", "detected_licenses": [ "MIT" ], "directory_id": "2d79910a97aead8a408b424a33e153c7f1282b33", "extension": "php", "filename": "FormController.php", "fork_events_count": 0, "gha_created_at": "2019-05-06T12:10:52", "gha_event_created_at": "2022-03-26T00:42:00", "gha_language": "TSQL", "gha_license_id": null, "github_id": 185189628, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 5018, "license": "MIT", "license_type": "permissive", "path": "/app/Http/Controllers/page/FormController.php", "provenance": "stack-edu-0048.json.gz:876609", "repo_name": "corzopabloariel/ventor", "revision_date": "2020-01-06T19:12:56", "revision_id": "f5c02ddfbfce0eef4fc95b8334b13751e3d94762", "snapshot_id": "4d91166ed559c848bde3b94ed2bc70066177c01e", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/corzopabloariel/ventor/f5c02ddfbfce0eef4fc95b8334b13751e3d94762/app/Http/Controllers/page/FormController.php", "visit_date": "2022-05-07T20:22:34.281436", "added": "2024-11-19T02:55:32.022683+00:00", "created": "2020-01-06T19:12:56", "int_score": 2, "score": 2.1875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0066.json.gz" }
function calcularPrecionConDescuento(precio,cupon) { var precio = document.getElementById("InputPrecio"); const valuePrecio = precio.value; var cupon = document.getElementById("InputDescuentoCupon"); const valueDescuentoCupon = cupon.value; const cupons =[ { name:"efectivo", descuento:20 }, { name:"tarjetaCD", descuento:30 }, { name:"tarjeta exito", descuento:50 } ]; const isCouponValueValid = function (cupons){ return cupons.name === valueDescuentoCupon; }; const userCupons = cupons.find(isCouponValueValid); if (!userCupons) { alert("El cupon ingresado no es valido") }else { var descuento = userCupons.descuento; const porcentajeConDescuento = 100 - descuento; const precioConDescuento = (valuePrecio * porcentajeConDescuento) / 100 ; document.getElementById("InputResultado").value="El precio a pagar es: $" + precioConDescuento; } }
93298265af15c1c7f10f08de2e71dc24fb6745b9
{ "blob_id": "93298265af15c1c7f10f08de2e71dc24fb6745b9", "branch_name": "refs/heads/main", "committer_date": "2021-08-23T02:35:35", "content_id": "d6d1cbcb5b1c0e87b4f4f4dc10568db04fb6c0af", "detected_licenses": [ "MIT" ], "directory_id": "af40c53623c31efc82fe5a82c309cb78a4b58612", "extension": "js", "filename": "reto2.js", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 395466311, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 1019, "license": "MIT", "license_type": "permissive", "path": "/Reto2 funciones mas inteligentes/reto2.js", "provenance": "stack-edu-0039.json.gz:392102", "repo_name": "Roarco/Curso-Practico-JavaScript", "revision_date": "2021-08-23T02:35:35", "revision_id": "96860f5965fe6493116d32b066e9cbf65ce4b1e9", "snapshot_id": "d1a9a4175587204b1d1ff7026b5c902329cf2b12", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Roarco/Curso-Practico-JavaScript/96860f5965fe6493116d32b066e9cbf65ce4b1e9/Reto2 funciones mas inteligentes/reto2.js", "visit_date": "2023-07-09T19:10:49.555166", "added": "2024-11-18T23:55:51.694024+00:00", "created": "2021-08-23T02:35:35", "int_score": 3, "score": 2.90625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0057.json.gz" }
/** * Sample React Native App * https://github.com/facebook/react-native * * @format * @flow */ import React, {useState} from 'react'; import {Text, PermissionsAndroid, Button} from 'react-native'; import RNBytes from 'react-native-bytes'; async function requestPermission1() { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, { title: 'RNBytes STORAGE Permission', message: 'RNBytes needs STORAGE permision to hash local files ', buttonPositive: 'OK', }, ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { console.log('Hack away!'); } else { console.log('YOU SHALL NOT HACK!'); } } catch (e) { console.log(e); } } async function requestPermission2() { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, { title: 'RNBytes WRITE Permission', message: 'RNBytes needs STORAGE permision to hash local files ', buttonPositive: 'OK', }, ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { console.log('Hack away!'); } else { console.log('YOU SHALL NOT HACK!'); } } catch (e) { console.log(e); } } const App: () => React$Node = () => { return ( <> <Button title="requestReadPermision" onPress={() => requestPermission1()}> requestReadPermision </Button> <Button title="requestWritePermision" onPress={() => requestPermission2()}> requestWritePermision </Button> <Button title="getFileSize" onPress={() => { RNBytes.getFileLength( '/storage/emulated/0/Download/05. Crown of Amber Canopy.mp3', ) .then(a => console.log(a)) .catch(e => console.log(e)); }}> getFileSize </Button> <Button title="splitFile" onPress={() => RNBytes.getFileLength( '/storage/emulated/0/Download/05. Crown of Amber Canopy.mp3', ) .then(l => RNBytes.readFromAndWriteTo( '/storage/emulated/0/Download/05. Crown of Amber Canopy.mp3', '/storage/emulated/0/Download/spilit13', true, false, 0, l / 3 - 1, ).then(() => RNBytes.readFromAndWriteTo( '/storage/emulated/0/Download/05. Crown of Amber Canopy.mp3', '/storage/emulated/0/Download/spilit23', true, false, l / 3, l - 1, ), ), ) .catch(e => console.log(e)) }> splitFile </Button> <Button title="reAttachFiles" onPress={() => RNBytes.getFileLength('/storage/emulated/0/Download/spilit1') .then(l => RNBytes.readFromAndWriteTo( '/storage/emulated/0/Download/spilit13', '/storage/emulated/0/Download/patched3', true, true, 0, l - 1, ), ) .then(() => RNBytes.getFileLength('/storage/emulated/0/Download/spilit1'), ) .then(l => RNBytes.readFromAndWriteTo( '/storage/emulated/0/Download/spilit23', '/storage/emulated/0/Download/patched3', true, true, 0, l - 1, ), ) .catch(e => console.log(e)) }> splitFile </Button> </> ); }; export default App;
fe26e68334742ca60e87e143d83cdc3d510fafbe
{ "blob_id": "fe26e68334742ca60e87e143d83cdc3d510fafbe", "branch_name": "refs/heads/master", "committer_date": "2020-05-02T18:56:32", "content_id": "887502c5abe3399e849bd502b5be99c8166a0d89", "detected_licenses": [ "Apache-2.0" ], "directory_id": "572548f743313caff0eb1f68029cb61dd2c30473", "extension": "js", "filename": "App.js", "fork_events_count": 1, "gha_created_at": "2020-02-12T09:07:56", "gha_event_created_at": "2023-01-05T07:13:01", "gha_language": "JavaScript", "gha_license_id": "Apache-2.0", "github_id": 239968945, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 3828, "license": "Apache-2.0", "license_type": "permissive", "path": "/example/App.js", "provenance": "stack-edu-0042.json.gz:517944", "repo_name": "Drazail/react-native-bytes", "revision_date": "2020-05-02T18:56:32", "revision_id": "cacdf5dce6e3604baefb3da18460d947c5eac0a2", "snapshot_id": "630db7e3bf95611dd4771b3c4159fb8c7f3ad865", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/Drazail/react-native-bytes/cacdf5dce6e3604baefb3da18460d947c5eac0a2/example/App.js", "visit_date": "2023-01-20T14:55:58.069059", "added": "2024-11-19T02:30:37.941988+00:00", "created": "2020-05-02T18:56:32", "int_score": 3, "score": 2.515625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0060.json.gz" }
#pragma once #ifndef __DEM_L3_QUEST_SYSTEM_H__ #define __DEM_L3_QUEST_SYSTEM_H__ #include "Quest.h" #include <Events/Events.h> #include <db/AttrID.h> // Quest system manages current player (character) tasks and their flow (completion, failure, // opening new tasks etc) //???do CQuest & CTask need refcount or they can be rewritten as simple structs? namespace Attr { DeclareStrID(QuestID); DeclareStrID(TaskID); DeclareInt(QStatus); } namespace Story { #define QuestSys Story::CQuestSystem::Instance() class CQuest; class CQuestSystem: public Core::CRefCounted //???Game::CManager? { DeclareRTTI; DeclareFactory(CQuestSystem); private: static CQuestSystem* Singleton; struct CQuestRec { Ptr<CQuest> Quest; CQuest::EStatus Status; }; nDictionary<CStrID, CQuestRec> Quests; nArray<Ptr<CQuest>> QuestsToDelete; nArray<Ptr<CTask>> TasksToDelete; nArray<nString> DeletedScriptObjects; bool LoadQuest(CStrID QuestID, CStrID* OutStartingTaskID = NULL); bool CloseQuest(CStrID QuestID, CStrID TaskID, bool Success); DECLARE_EVENT_HANDLER(OnLoad, OnLoad); DECLARE_EVENT_HANDLER(OnSave, OnSave); public: CQuestSystem(); ~CQuestSystem(); static CQuestSystem* Instance() { n_assert(Singleton); return Singleton; } void Trigger(); bool StartQuest(CStrID QuestID, CStrID TaskID = CStrID::Empty); bool CompleteQuest(CStrID QuestID, CStrID TaskID = CStrID::Empty); bool FailQuest(CStrID QuestID, CStrID TaskID = CStrID::Empty); CQuest::EStatus GetQuestStatus(CStrID QuestID, CStrID TaskID = CStrID::Empty); // Save, Load }; RegisterFactory(CQuestSystem); inline bool CQuestSystem::CompleteQuest(CStrID QuestID, CStrID TaskID) { n_printf("QuestSys: completed quest %s, task %s\n", QuestID.CStr(), TaskID.CStr()); return CloseQuest(QuestID, TaskID, true); } //--------------------------------------------------------------------- inline bool CQuestSystem::FailQuest(CStrID QuestID, CStrID TaskID) { n_printf("QuestSys: failed quest %s, task %s\n", QuestID.CStr(), TaskID.CStr()); return CloseQuest(QuestID, TaskID, false); } //--------------------------------------------------------------------- } #endif
d4eeefb9f50d7b7cea1e1583e1ba83c5549e652c
{ "blob_id": "d4eeefb9f50d7b7cea1e1583e1ba83c5549e652c", "branch_name": "refs/heads/master", "committer_date": "2012-10-03T23:33:16", "content_id": "f435230b6c1de343038f9eb8a5fbb5cb1b45ca73", "detected_licenses": [ "MIT" ], "directory_id": "c1720c81612dbd512dce413618d3cd246faa0a74", "extension": "h", "filename": "QuestSystem.h", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 35931317, "is_generated": false, "is_vendor": false, "language": "C++", "length_bytes": 2247, "license": "MIT", "license_type": "permissive", "path": "/DEM/Src/L3/Story/Quests/QuestSystem.h", "provenance": "stack-edu-0005.json.gz:374084", "repo_name": "moltenguy1/deusexmachina", "revision_date": "2012-10-03T23:33:16", "revision_id": "134f4ca4087fff791ec30562cb250ccd50b69ee1", "snapshot_id": "307ba62a863034437cd77a6599c191ffe8ae953c", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/moltenguy1/deusexmachina/134f4ca4087fff791ec30562cb250ccd50b69ee1/DEM/Src/L3/Story/Quests/QuestSystem.h", "visit_date": "2021-01-23T21:35:42.122378", "added": "2024-11-18T22:51:33.340313+00:00", "created": "2012-10-03T23:33:16", "int_score": 3, "score": 2.625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0023.json.gz" }
package lk.nsbm.onlinefoodorderingsystem.entity; import javax.persistence.*; import java.util.List; @Entity public class Orders { @Id private String oid; private String orderDate; @ManyToMany(cascade = CascadeType.ALL) private List<OrderDetail> orderDetails; @ManyToOne(cascade = CascadeType.ALL) private User user; @OneToOne private Restaurant restaurant; public Orders(String oid, String orderDate, List<OrderDetail> orderDetails, User user, Restaurant restaurant) { this.restaurant = restaurant; this.setOid(oid); this.setOrderDate(orderDate); this.setOrderDetails(orderDetails); this.setUser(user); } public Orders() { } public String getOid() { return oid; } public void setOid(String oid) { this.oid = oid; } public String getOrderDate() { return orderDate; } public void setOrderDate(String orderDate) { this.orderDate = orderDate; } public List<OrderDetail> getOrderDetails() { return orderDetails; } public void setOrderDetails(List<OrderDetail> orderDetails) { this.orderDetails = orderDetails; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public Restaurant getRestaurant() { return restaurant; } public void setRestaurant(Restaurant restaurant) { this.restaurant = restaurant; } @Override public String toString() { return "Orders{" + "oid=" + oid + ", orderDate='" + orderDate + '\'' + ", orderDetails=" + orderDetails + ", user=" + user + '}'; } }
b9ce10015a5092fae78da39e3e9a4ff9a3324d13
{ "blob_id": "b9ce10015a5092fae78da39e3e9a4ff9a3324d13", "branch_name": "refs/heads/master", "committer_date": "2019-03-19T07:48:37", "content_id": "216dd5ac0cddcae61afb710a8e3c65fea0be567a", "detected_licenses": [ "Apache-2.0" ], "directory_id": "d450f6a0b2061557e60425006b0c049dc7651948", "extension": "java", "filename": "Orders.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 176454099, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 1777, "license": "Apache-2.0", "license_type": "permissive", "path": "/src/main/java/lk/nsbm/onlinefoodorderingsystem/entity/Orders.java", "provenance": "stack-edu-0022.json.gz:126128", "repo_name": "Hasindu-Jayasinghe/food-ordering-system-2", "revision_date": "2019-03-19T07:48:37", "revision_id": "53a6de55548d0749c2172d964818ca80e996320c", "snapshot_id": "2ffdadd8c3ad811e589a137712ce01f1bf73894e", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/Hasindu-Jayasinghe/food-ordering-system-2/53a6de55548d0749c2172d964818ca80e996320c/src/main/java/lk/nsbm/onlinefoodorderingsystem/entity/Orders.java", "visit_date": "2020-04-29T22:38:34.753422", "added": "2024-11-18T22:53:39.885955+00:00", "created": "2019-03-19T07:48:37", "int_score": 2, "score": 2.453125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0040.json.gz" }
package org.mousephenotype.cda.neo4j.entity; import org.neo4j.ogm.annotation.GraphId; import org.neo4j.ogm.annotation.NodeEntity; import org.neo4j.ogm.annotation.Relationship; import java.util.Set; /** * Created by ckchen on 14/03/2017. */ @NodeEntity public class Pipeline { @GraphId Long id; private String pipelineId; private String pipelineStableId; private String pipelineStableKey; private String pipelineName; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getPipelineId() { return pipelineId; } public void setPipelineId(String pipelineId) { this.pipelineId = pipelineId; } public String getPipelineStableId() { return pipelineStableId; } public void setPipelineStableId(String pipelineStableId) { this.pipelineStableId = pipelineStableId; } public String getPipelineStableKey() { return pipelineStableKey; } public void setPipelineStableKey(String pipelineStableKey) { this.pipelineStableKey = pipelineStableKey; } public String getPipelineName() { return pipelineName; } public void setPipelineName(String pipelineName) { this.pipelineName = pipelineName; } @Override public String toString() { return "Pipeline{" + "id=" + id + ", pipelineId='" + pipelineId + '\'' + ", pipelineStableId='" + pipelineStableId + '\'' + ", pipelineStableKey='" + pipelineStableKey + '\'' + ", pipelineName='" + pipelineName + '\'' + '}'; } }
1c314dc34dc597d3dea1987344cb37b3561aacf5
{ "blob_id": "1c314dc34dc597d3dea1987344cb37b3561aacf5", "branch_name": "refs/heads/master", "committer_date": "2017-07-12T13:32:34", "content_id": "4a001e1bbf287db3c05513d32c9d3fe7f0ee94f4", "detected_licenses": [ "Apache-2.0" ], "directory_id": "54dde95a84220f4518bd3b3667c3c535496ccd72", "extension": "java", "filename": "Pipeline.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": 1699, "license": "Apache-2.0", "license_type": "permissive", "path": "/data-model-neo4j/src/main/java/org/mousephenotype/cda/neo4j/entity/Pipeline.java", "provenance": "stack-edu-0025.json.gz:738444", "repo_name": "damiansm/PhenotypeData", "revision_date": "2017-07-12T13:32:34", "revision_id": "e7fd6c61366ef157ef3e8ffbd8a969c727f69ce3", "snapshot_id": "97b7dd3843602783056ff1210a1b9cbfacdc89ae", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/damiansm/PhenotypeData/e7fd6c61366ef157ef3e8ffbd8a969c727f69ce3/data-model-neo4j/src/main/java/org/mousephenotype/cda/neo4j/entity/Pipeline.java", "visit_date": "2020-06-26T11:55:07.533034", "added": "2024-11-18T23:06:35.976135+00:00", "created": "2017-07-12T13:32:34", "int_score": 2, "score": 2.1875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0043.json.gz" }
# main.py -- put your code here! """Animations for use on micropython board, tested on pyboardv11 with stm32f04 chip. Animation code based on rpi_ws281x library from jgarff and with the compilation for micropython from JanBednarik. Questions to programm LED Strips ask me a.hoch90@gmail.com""" from ws2812 import WS2812 import time led_count = 14 #Set number of pixels spi_bus_number = 1 #Connect "X8" MOSI to LED DIN chain = WS2812(spi_bus_number, led_count) data = [] color_val = tuple(x for x in range(led_count)) for colors in color_val: data.append((0,0,0)) def colorWipe(data, color, wait_ms=50): for i in range(led_count): data[i]= (color[0], color[1], color[2]) chain.show(data) time.sleep(wait_ms / 1000.0) def wheel(pos): if pos < 85: return (pos * 3, 255 - pos * 3, 0) elif pos < 170: pos -= 85 return (255 - pos * 3, 0, pos * 3) else: pos -= 170 return (0, pos * 3, 255 - pos * 3) def rainbow(data, wait_ms=2, iterations=1): for j in range(256 * iterations): for i in range(led_count): data[i] = wheel((i + j) & 255) chain.show(data) time.sleep(wait_ms / 1000.0) def rainbowCycle(data, wait_ms=20, iterations=5): for j in range(256 * iterations): for i in range(led_count): data[i] =wheel((int(i * 256 / led_count) + j) & 255) chain.show(data) time.sleep(wait_ms / 1000.0) while True: colorWipe(data, (255, 0, 0)) # Red wipe colorWipe(data, (0, 255, 0)) # Blue wipe colorWipe(data, (0, 0, 255)) # Green wipe colorWipe(data, (0, 0, 0)) # Green wip rainbow(data) rainbowCycle(data)
3792f8d0479ed2ff96e90f5841ded8ee77a6ff13
{ "blob_id": "3792f8d0479ed2ff96e90f5841ded8ee77a6ff13", "branch_name": "refs/heads/master", "committer_date": "2021-01-03T21:34:51", "content_id": "9fb4e8fb83c32a8ce919a9a7a2e20142a37afb38", "detected_licenses": [ "MIT" ], "directory_id": "19b6a552bf641e7cb76d3c51407a15df56bc53bb", "extension": "py", "filename": "strandtest.py", "fork_events_count": 0, "gha_created_at": "2021-01-03T21:27:00", "gha_event_created_at": "2021-01-03T21:33:57", "gha_language": null, "gha_license_id": "MIT", "github_id": 326503862, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1719, "license": "MIT", "license_type": "permissive", "path": "/strandtest.py", "provenance": "stack-edu-0060.json.gz:221130", "repo_name": "control-led/micropython-ws2812", "revision_date": "2021-01-03T21:34:51", "revision_id": "3660a2fc1b5abe481cbdd9210399888cf94f22d8", "snapshot_id": "98460ae3dbb8c1736c6cf7fbef861b60e5427e31", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/control-led/micropython-ws2812/3660a2fc1b5abe481cbdd9210399888cf94f22d8/strandtest.py", "visit_date": "2023-02-06T04:46:16.316543", "added": "2024-11-19T01:38:10.714506+00:00", "created": "2021-01-03T21:34:51", "int_score": 3, "score": 3.25, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0078.json.gz" }
from flask import Flask, jsonify, request from db import * # def get_bin_info(): # conn = open_connection() # with conn.cursor() as cursor: # result = cursor.execute('SELECT * FROM bins;') # bin_items = cursor.fetchall() # bin_json = jsonify(bin_items) # conn.close() # return bin_json # def add_item(item_dict): # conn = open_connection() # with conn.cursor() as cursor: # cursor.execute('INSERT INTO items (timestamp, prediction, binID) VALUES(%s, %s, %s)', (item_dict["timestamp"], item_dict["prediction"], item_dict["binID"])) # conn.commit() # conn.close() app = Flask(__name__) @app.route('/bin', methods=["POST"]) def put_bin(): bdata = request.data conn = open_connection() with conn.cursor() as cursor: cursor.execute("INSERT INTO bin (binID, type, count, capacity, incorrect) VALUES (%s, %s, %s, %s, %s)", (bdata["id"], bdata["type"], bdata["count"], bdata["capacity"], bdata["incorrect"])) @app.route('/item', methods=["POST"]) def put_item(): idata = request.data conn = open_connection() with conn.cursor() as cursor: cursor.execute("INSERT INTO items (binID, prediction, timestamp) VALUES (%s, %s, %s)", (idata["id"], bdata["prediction"], bdata["timestamp"])) cursor.execute("UPDATE bin SET count = count + 1 WHERE binID = (%s)", (idata["id"])) cursor.execute("UPDATE bin SET incorrect = incorrect + 1 WHERE type != (%s)", (idata["prediction"])) # @app.route('/pizza', methods=["GET"]) # def get_data(): # conn = open_connection() # with conn.cursor() as cursor: # cursor.execute("SELECT * FROM items") # items_data = cursor.fetchall() # cursor.execute("SELECT * FROM bins") # bins_data = cursor.fetchall() # print(items_data) # print(bins_data) # items_json = jsonify(items_data) # bins_json = jsonify(bins_data) # bins_json["items"] = {} # for items in items_json: # if items["prediction"] not in bins_json["items"]: # bins_json["items"][items["prediction"]] = 0 # else # bins_json["items"][items["prediction"]] += 1 # bins_json["timeline"] = [(x["timestamp"], x[""])] if __name__ == '__main__': app.run(debug=True)
46f30f11082c1f6ca48ef91737d22834ef0751a9
{ "blob_id": "46f30f11082c1f6ca48ef91737d22834ef0751a9", "branch_name": "refs/heads/main", "committer_date": "2021-09-28T06:28:18", "content_id": "3dbd1b5021565031dd48a31e50c1eba08d3e19e8", "detected_licenses": [ "MIT" ], "directory_id": "b61be4b81d9ecbdd1327f0c316e8191dd1e86077", "extension": "py", "filename": "main.py", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 411153045, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 2387, "license": "MIT", "license_type": "permissive", "path": "/main.py", "provenance": "stack-edu-0065.json.gz:198696", "repo_name": "velvet-market/GreenseerAPI", "revision_date": "2021-09-28T06:28:18", "revision_id": "c4d18a38b0808502316365227edf41b5bf5fdc56", "snapshot_id": "6a224118fc2ee033900b96681ca0f85c74373a46", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/velvet-market/GreenseerAPI/c4d18a38b0808502316365227edf41b5bf5fdc56/main.py", "visit_date": "2023-08-01T05:46:01.484262", "added": "2024-11-18T22:25:56.741285+00:00", "created": "2021-09-28T06:28:18", "int_score": 3, "score": 2.515625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0083.json.gz" }
require 'spec_helper' describe ResponseCounts do it 'finds the first count matching the given month' do response_count_1 = ResponseCount.new("May 2013", 1, 1) response_count_2 = ResponseCount.new("Jun 2013", 1, 1) counts = ResponseCounts.new([response_count_2, response_count_1]) counts.find_by_month("May 2013").should == response_count_1 end it "finds the unique months between two ResponseCounts objects" do response_counts_1 = ResponseCounts.new([ResponseCount.new("May 2013", 1, 1)]) response_counts_2 = ResponseCounts.new([ResponseCount.new("May 2013", 1, 1), ResponseCount.new("June 2013", 1, 1)]) response_counts_1.unique_months_between(response_counts_2).should == ["May 2013", "June 2013"] end it "adds ResponseCount objects to itself using <<" do response_count = ResponseCount.new("May 2013", 1, 1) response_counts = ResponseCounts.new response_counts << response_count response_counts.counts.should include response_count end context "when merging two ResponseCounts objects" do it "creates a ResponseCounts object combining duplicate months" do response_counts_1 = ResponseCounts.new([ResponseCount.new("May 2013", 2, 1)]) response_counts_2 = ResponseCounts.new([ResponseCount.new("May 2013", 1, 5)]) count = response_counts_1.merge(response_counts_2).counts[0] count.month.should == "May 2013" count.incompletes.should == 3 count.completes.should == 6 end it "counts months that are present in the other object that are not present in itself" do response_counts_1 = ResponseCounts.new([ResponseCount.new("May 2013", 2, 1)]) response_counts_2 = ResponseCounts.new([ResponseCount.new("Jan 2013", 1, 5)]) response_counts = response_counts_1.merge(response_counts_2) response_counts.counts.size.should == 2 end it "only counts the other object's months if it is empty'" do response_counts_1 = ResponseCounts.new response_counts_2 = ResponseCounts.new([ResponseCount.new("Jan 2013", 1, 5)]) response_counts = response_counts_1.merge(response_counts_2) response_counts.counts.size.should == 1 end it "only counts its months if the other object is empty'" do response_counts_1 = ResponseCounts.new([ResponseCount.new("Jan 2013", 1, 5)]) response_counts_2 = ResponseCounts.new response_counts = response_counts_1.merge(response_counts_2) response_counts.counts.size.should == 1 end end context "when iterating over the ResponseCount objects" do it "yields all the counts" do response_count_1 = ResponseCount.new("Jan 2013", 1, 5) response_count_2 = ResponseCount.new("Jun 2013", 1, 5) response_counts = ResponseCounts.new([response_count_1, response_count_2]) response_counts.each_in_reverse_chronological_order.to_a.should =~ [response_count_1, response_count_2] end it "yields the elements in reverse chronological order" do response_count_3 = ResponseCount.new("Jan 2013", 1, 5) response_count_2 = ResponseCount.new("Sep 2012", 1, 5) response_count_1 = ResponseCount.new("Jun 2013", 1, 5) response_counts = ResponseCounts.new([response_count_1, response_count_2, response_count_3]) response_counts.each_in_reverse_chronological_order.to_a.should == [response_count_1, response_count_3, response_count_2] end end end
21fac99c052e7ad1d83acc5659127779431ff336
{ "blob_id": "21fac99c052e7ad1d83acc5659127779431ff336", "branch_name": "refs/heads/master", "committer_date": "2016-08-24T12:16:08", "content_id": "b12b80c6488577aef0cb1666b6a9deff75d932f3", "detected_licenses": [ "MIT" ], "directory_id": "9929c79d013a97bfb571c9b801f9a2bb5506144d", "extension": "rb", "filename": "response_counts_spec.rb", "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": "Ruby", "length_bytes": 3408, "license": "MIT", "license_type": "permissive", "path": "/spec/reporters/response_counts_spec.rb", "provenance": "stack-edu-0066.json.gz:436673", "repo_name": "IQ-SCM/ashoka-survey-web", "revision_date": "2016-08-24T12:16:08", "revision_id": "48edecbb637b44bb4f16033668f77df102185be4", "snapshot_id": "a0de0bf958831bee160a18bfe3138ffed13d25ce", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/IQ-SCM/ashoka-survey-web/48edecbb637b44bb4f16033668f77df102185be4/spec/reporters/response_counts_spec.rb", "visit_date": "2023-05-31T04:59:51.915338", "added": "2024-11-19T02:08:53.625353+00:00", "created": "2016-08-24T12:16:08", "int_score": 3, "score": 2.65625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0084.json.gz" }
import os, commands, sys, random def exec_test(t): cmd = './build/nachos-userprog -rs %d -x build/%s' % (random.randint(1, 500), t) sys.stdout.write(cmd) return commands.getstatusoutput(cmd) def show_title(title): print('~=-=-=-=-=-=-=-=-=-= %s =-=-=-=-=-=-=-=-=-=~' % title) def char_count(line): nb = {} for j in range(len(line)): c = line[j] if not c in nb: nb[c] = 0 nb[c] += 1 return nb
7e47d8373a211aa8be44be2b62ff1294f29eb598
{ "blob_id": "7e47d8373a211aa8be44be2b62ff1294f29eb598", "branch_name": "refs/heads/master", "committer_date": "2013-01-19T09:40:01", "content_id": "1df193600a5a541d7f61107264252232388b10fb", "detected_licenses": [ "MIT-Modern-Variant" ], "directory_id": "692e752ad3db3acb1ec949b376e4e6b3d10a6d19", "extension": "py", "filename": "pychos.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": 418, "license": "MIT-Modern-Variant", "license_type": "permissive", "path": "/code/pytest/pychos.py", "provenance": "stack-edu-0064.json.gz:235411", "repo_name": "Dwaaap/ignacio", "revision_date": "2013-01-19T09:40:01", "revision_id": "b139af08f03799a2f66dfec8554f35609e521a35", "snapshot_id": "9afeb2e11586cb4466f63cb62d581a65f4173f75", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Dwaaap/ignacio/b139af08f03799a2f66dfec8554f35609e521a35/code/pytest/pychos.py", "visit_date": "2021-01-16T19:23:11.142666", "added": "2024-11-18T18:47:02.308600+00:00", "created": "2013-01-19T09:40:01", "int_score": 2, "score": 2.4375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0082.json.gz" }
/* Riot 0.9.8, @license MIT, (c) 2014 Moot Inc + contributors */ (function($) { "use strict"; $.observable = function(el) { var callbacks = {}, slice = [].slice; el.on = function(events, fn) { if (typeof fn === "function") { events.replace(/[^\s]+/g, function(name, pos) { (callbacks[name] = callbacks[name] || []).push(fn); fn.typed = pos > 0; }); } return el; }; el.off = function(events) { events.replace(/[^\s]+/g, function(name) { callbacks[name] = []; }); if (events == "*") callbacks = {}; return el; }; // only single event supported el.one = function(name, fn) { if (fn) fn.one = true; return el.on(name, fn); }; el.trigger = function(name) { var args = slice.call(arguments, 1), fns = callbacks[name] || []; for (var i = 0, fn; (fn = fns[i]); ++i) { if (!((fn.one && fn.done) || fn.busy)) { fn.busy = true; fn.apply(el, fn.typed ? [name].concat(args) : args); fn.done = true; fn.busy = false; } } return el; }; return el; }; // Precompiled templates (JavaScript functions) var FN = {}; var ESCAPING_MAP = { "\\": "\\\\", "\n": "\\n", "\r": "\\r", "\u2028": "\\u2028", "\u2029": "\\u2029", "'": "\\'" }; var ENTITIES_MAP = { '&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;' }; // Render a template with data $.render = function(template, data) { if(!template) return ''; FN[template] = FN[template] || new Function("_", "E", "return '" + template .replace( /[\\\n\r\u2028\u2029']/g, function(escape) { return ESCAPING_MAP[escape]; } ).replace( /\{\s*([\.\w]+)\s*\}/g, "'+(function(){try{return(_.$1?(_.$1+'').replace(/[&\"<>]/g,function(e){return E[e];}):(_.$1===0?0:''))}catch(e){return ''}})()+'" )+"'" ); return FN[template](data, ENTITIES_MAP); }; /* Cross browser popstate */ // for browsers only if (typeof top != "object") return; var currentHash, pops = $.observable({}), doc = document; function pop(hash) { if (typeof hash != "string") hash = window.location.hash; if (hash.charAt(0) == '#') hash = hash.substring(1); if (hash != currentHash) pops.trigger("pop", hash); currentHash = hash; } jQuery(window).bind('hashchange', pop); jQuery(pop); // Change the browser hash $.route = function(to) { if (typeof to === "function") return pops.on("pop", to); to = to.substring(to.indexOf("#"), to.length); window.location.hash = to; if (!("onhashchange" in window)) { pop(to); } }; })(typeof top == "object" ? window.$ || (window.$ = {}) : exports);
937c29cf5a8878b3e02be2400f9c4bb6071f3485
{ "blob_id": "937c29cf5a8878b3e02be2400f9c4bb6071f3485", "branch_name": "refs/heads/master", "committer_date": "2014-03-12T17:25:29", "content_id": "ff259d51a3a96e2db190b73023b21af4179dea30", "detected_licenses": [ "MIT" ], "directory_id": "57c870094a1110555ef392484471de1dcbbdf321", "extension": "js", "filename": "riot.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": 2675, "license": "MIT", "license_type": "permissive", "path": "/riot.js", "provenance": "stack-edu-0032.json.gz:369827", "repo_name": "gardentechno/riotjs", "revision_date": "2014-03-12T17:25:29", "revision_id": "7899f0f3b1aad2fc5225e41522eac72640d06d49", "snapshot_id": "48aa42cfdcb2cee5d62bc2e76b2f1559025094d9", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/gardentechno/riotjs/7899f0f3b1aad2fc5225e41522eac72640d06d49/riot.js", "visit_date": "2021-01-18T11:52:52.222893", "added": "2024-11-18T23:22:49.374874+00:00", "created": "2014-03-12T17:25:29", "int_score": 2, "score": 2.484375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0050.json.gz" }
import { filter } from '../filter' import { ignore, IndexError, ValueError } from '../util' import { len } from '../len' import { map } from '../map' import { range } from '../range' import { reversed } from '../reversed' import { sum } from '../sum' import { Collection } from './Collection' import { Reversible, __reversed__ } from './Reversible' export abstract class Sequence<T> implements Reversible<T>, Collection<T> { /** * @throws {IndexError} */ abstract get(index: number): T abstract readonly length: number *[Symbol.iterator]() { try { for (let i = 0; true; i++) { const v = this.get(i) yield v } } catch (e) { ignore(e, IndexError) } } includes(value: T) { for (const v of this) { if (v === value) { return true } } return false } *[__reversed__](): Iterable<T> { for (const i of reversed(range(len(this)))) { yield this.get(i) } } /** * @throws {ValueError} Argument value is not in list. */ index(value: T, start = 0, stop: number | null = null) { if (start !== null && start < 0) { start = Math.max(len(this) + start, 0) } if (stop !== null && stop < 0) { stop += len(this) } for (let i = start; stop === null || i < stop; i++) { try { const v = this.get(i) if (v === value) { return i } } catch (e) { ignore(e, IndexError) } } throw new ValueError(`${value} is not in list`) } count(value: T) { return sum( map( filter(this, (v) => v === value), () => 1, ), ) } }
38c7b043c83339a4a05ed45899dbb4f567b7e53b
{ "blob_id": "38c7b043c83339a4a05ed45899dbb4f567b7e53b", "branch_name": "refs/heads/master", "committer_date": "2021-08-08T12:43:13", "content_id": "8f73f65220afd87c7a830f88f25789e6ee461a34", "detected_licenses": [ "MIT" ], "directory_id": "996c2b69cf56c95379d46b64768cb5726985334b", "extension": "ts", "filename": "Sequence.ts", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 347196699, "is_generated": false, "is_vendor": false, "language": "TypeScript", "length_bytes": 1659, "license": "MIT", "license_type": "permissive", "path": "/src/abs/Sequence.ts", "provenance": "stack-edu-0072.json.gz:958739", "repo_name": "PatrykWalach/generators", "revision_date": "2021-08-08T12:43:13", "revision_id": "d09d8cfbf07cae942a5e523aed8898b69995e0d3", "snapshot_id": "528d44301a7a92f6a44e0fb2108446865f3a1416", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/PatrykWalach/generators/d09d8cfbf07cae942a5e523aed8898b69995e0d3/src/abs/Sequence.ts", "visit_date": "2023-07-07T13:14:33.618980", "added": "2024-11-19T00:54:03.563124+00:00", "created": "2021-08-08T12:43:13", "int_score": 3, "score": 3.453125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0090.json.gz" }
/** * Created by : UbaidUllah * Project Name : BlockAPT * Product Name : PhpStorm * Date : 5/18/2018 9:30 AM * File Name : */ // white var app = angular.module('IPAttacks', []).constant('url', []); app.controller('Controller', function ($scope, $http, url){ $scope.url = [ userStatus, createIpAttackBackup, ]; $scope.deviceCheck = function deviceCheck($user_id ,$status) { // check via API call if the Device is active or Not $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $http({ method: 'get', url: $scope.url[0], params: { "_token": "{{ csrf_token() }}",user_id: $user_id , status:$status} }).success(function (response) { if (response) { window.location.replace(response); } }); }; $scope.createIpBackup = function createIpBackup($id,$user_meta_days) { // check via API call if the Device is active or Not $('#warning_msg').text('IP Backup feature will take backup of data for ' +$user_meta_days+ ' days and store back-up in an XML file and clean-up database'); $('#warning_to_scan_ips').modal(); $('.continueWarningScan').click(function (e) { e.preventDefault(); $('#warning_to_scan_ips').modal('hide'); $http({ method: 'Get', url: $scope.url[1], params: {user_id: $id} }).success(function (response) { // console.log(response); var html = ''; html += '<div class="alert alert-success fade in"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>'+response.message+'</div>'; $('.backup_message').show(html); // $scope.backup_message = '<div class="alert alert-success fade in"><button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>DB Data base created successfullllly</div>'; window.location.replace(response); }); }); }; }); app.filter('trustAsHtml', ['$sce', function ($sce) { return function (text) { $sce.trustAsHtml(text); }; }]);
fa3836561910849c0b326deb1f8c1c7d992efab8
{ "blob_id": "fa3836561910849c0b326deb1f8c1c7d992efab8", "branch_name": "refs/heads/master", "committer_date": "2021-04-19T16:55:23", "content_id": "f6c7b917d0b6345388ca8e9b99567f6e969e93e2", "detected_licenses": [ "MIT" ], "directory_id": "ede5d8389f79aa748cc2cb8a1f9959a14b8dd886", "extension": "js", "filename": "ip_attacks_management.js", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 359533397, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 2377, "license": "MIT", "license_type": "permissive", "path": "/public/assets/js/ip_attacks_management.js", "provenance": "stack-edu-0042.json.gz:753130", "repo_name": "ubaidpal/resume", "revision_date": "2021-04-19T16:55:23", "revision_id": "b7a72eb4463e61cc35f2b0db519088fffa552004", "snapshot_id": "6755de8a03dfb23b040f8185581e36f272bfc791", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/ubaidpal/resume/b7a72eb4463e61cc35f2b0db519088fffa552004/public/assets/js/ip_attacks_management.js", "visit_date": "2023-04-08T17:03:08.056673", "added": "2024-11-19T01:40:19.622310+00:00", "created": "2021-04-19T16:55:23", "int_score": 2, "score": 2.15625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0060.json.gz" }
'use strict'; const RED = new Color(255, 0, 0); const GREEN = new Color(0, 255, 0); const BLUE = new Color(0, 0, 255); const WHITE = new Color(255, 255, 255); class ContourerManager{ constructor(drawFunc){ this.viewport = new ScalableViewportManager( new Vector(0, 0), 0.01 ); this.zoomSensitivity = 0.3; this.contourSpacing = 1.0; } changeDrawFunc(drawFunc, includeSrc, isAnimated = false){ const createFieldKernel = coord => { const fieldFunc = `vec2 cPos = (vec2(threadId) * uScale) + uPos; vec2 res; ` + drawFunc.trim() + '\n' + //`gl_FragData[0] = vec4( // res, // 0.0, 0.0 //); `gl_FragData[0] = packFloat(res.` + coord + `); `; return this.gpgpuManager.createKernel( fieldFunc, [], this.dims, [ { type: 'float', name: 'uScale' }, { type: 'vec2', name: 'uPos' } ].concat(isAnimated ? [ { type: 'float', name: 'time' } ] : []), 1, GPGPUManager.PACK_FLOAT_INCLUDE + includeSrc.trim() + '\n\n' ); }; this.fieldKernelX = createFieldKernel('x'); this.fieldKernelY = createFieldKernel('y'); this.viewport.scale = 10.0 / this.dims.width; this.viewport.pos = new Vector(-this.dims.width, -this.dims.height).divide(2.0).multiply(this.viewport.scale); this.contourSpacing = 1.0; this.isAnimated = isAnimated; } useCanvas(canvas){ this.ctx = GPGPUManager.getCanvasContext(canvas); this.gpgpuManager = new GPGPUManager(this.ctx, false); this.dims = getCanvasDims(this.ctx); this.plotKernel = this.gpgpuManager.createGraphicalKernel( ContourerManager.plotFunc, ['uFieldX', 'uFieldY'], this.dims, [ { type: 'float', name: 'uContourSpacing' } ], GPGPUManager.PACK_FLOAT_INCLUDE + ContourerManager.FIELD_CHECK_INCLUDE ); } destroyContext(){ this.ctx.canvas.width = 1; this.ctx.canvas.height = 1; } changeZoom(changeAmount, zoomPoint = new Vector(this.dims.width / 2, this.dims.height / 2)){ this.viewport.scaleAtPoint( -changeAmount * this.zoomSensitivity, zoomPoint ); } changeContourSpacing(changeAmount){ this.contourSpacing *= Math.exp(changeAmount * this.zoomSensitivity); } translate(translateAmount){ this.viewport.translate(translateAmount); } drawContours(time = 0){ const uniformAssignments = { uScale: this.viewport.scale, uPos: this.viewport.pos.toArray() }; if(this.isAnimated){ uniformAssignments['time'] = time; } const fieldResultX = this.fieldKernelX.run([], this.dims, uniformAssignments, false); const fieldResultY = this.fieldKernelY.run([], this.dims, uniformAssignments, false); this.plotKernel.run([fieldResultX.textures[0], fieldResultY.textures[0]], this.dims, { uContourSpacing: this.contourSpacing }); fieldResultX.dispose(); fieldResultY.dispose(); } }; ContourerManager.plotFunc = `ivec2 lineIndex = ivec2(floor(vec2( unpackFloat(texture2D(uFieldX, vCoord)), unpackFloat(texture2D(uFieldY, vCoord)) ) / uContourSpacing)); vec2 cmpField = vec2(lineIndex) * uContourSpacing; ivec2 drawData = ivec2(greaterThanEqual( fieldCheck(threadId, ivec2(0, 1), cmpField) + fieldCheck(threadId, ivec2(1, 0), cmpField) + fieldCheck(threadId, ivec2(0, -1), cmpField) + fieldCheck(threadId, ivec2(-1, 0), cmpField), ivec2(1))); if(all(equal(drawData, ivec2(0)))){ gl_FragData[0] = vec4(1.0, 1.0, 1.0, 1.0); } else{ vec2 isAxis = vec2(equal(lineIndex, ivec2(0))); vec2 lineColor = vec2(drawData) * (1.0 - 0.5 * isAxis); gl_FragData[0] = vec4(lineColor.x, 0.5 * dot(vec2(drawData), isAxis), lineColor.y, 1.0); } `; ContourerManager.FIELD_CHECK_INCLUDE = `vec2 getField(ivec2 pos){ return vec2( unpackFloat(arrGet(uFieldX, pos)), unpackFloat(arrGet(uFieldY, pos)) ); } ivec2 fieldCheck(ivec2 cPos, ivec2 dir, vec2 cmpField){ ivec2 oPos = cPos + dir; if(all(greaterThanEqual(oPos, ivec2(0))) && all(lessThan(oPos, uDims))){ return ivec2(lessThan(getField(oPos), cmpField)); } else return ivec2(0); } `; class ContourerAnimationManager{ constructor(manager, numFrames = 1000){ this.manager = manager; this.isAnimating = false; this.numFrames = numFrames; this.currentFrame = 0; this.onStopCallback = null; this.animationLoop = this.animationLoop.bind(this); } start(startFrame = 0, onDraw = null){ this.currentFrame = startFrame; this.isAnimating = true; this.onDraw = onDraw; window.requestAnimationFrame(this.animationLoop); } animationLoop(timestamp){ if(this.isAnimating){ this.manager.drawContours(this.currentFrame / this.numFrames); if(this.onDraw != null){ this.onDraw(this.currentFrame); } this.currentFrame = (this.currentFrame + 1) % this.numFrames; window.requestAnimationFrame(this.animationLoop); } else{ if(this.onStopCallback != null){ this.onStopCallback(); } } } stop(onStopCallback = null){ if(this.isAnimating){ this.isAnimating = false; this.onStopCallback = onStopCallback; } else{ if(onStopCallback != null){ onStopCallback(); } } } }; function init(){ const manager = new ContourerManager(); initRender(manager); }
979dc3c46536fd4631efc99fb8dd4b2d229ddb8a
{ "blob_id": "979dc3c46536fd4631efc99fb8dd4b2d229ddb8a", "branch_name": "refs/heads/master", "committer_date": "2017-09-24T19:55:19", "content_id": "3518513adfad4cb84db32c5f57337ee7126f7ab1", "detected_licenses": [ "MIT" ], "directory_id": "108f9d74d705469856f48e6186088be94bc1a541", "extension": "js", "filename": "contourer.js", "fork_events_count": 1, "gha_created_at": "2016-06-24T14:49:22", "gha_event_created_at": "2016-07-09T10:56:25", "gha_language": "JavaScript", "gha_license_id": null, "github_id": 61891453, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 6089, "license": "MIT", "license_type": "permissive", "path": "/src/contourer.js", "provenance": "stack-edu-0045.json.gz:125917", "repo_name": "krawthekrow/contourer", "revision_date": "2017-09-24T19:55:19", "revision_id": "ba7007c80075e96edde5b3f56ad53f2caeafa3f6", "snapshot_id": "016f32e09099c5e5ce5942d00ee3fd3c42252c5c", "src_encoding": "UTF-8", "star_events_count": 6, "url": "https://raw.githubusercontent.com/krawthekrow/contourer/ba7007c80075e96edde5b3f56ad53f2caeafa3f6/src/contourer.js", "visit_date": "2020-04-09T17:35:19.450979", "added": "2024-11-19T00:41:39.751057+00:00", "created": "2017-09-24T19:55:19", "int_score": 2, "score": 2.46875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0063.json.gz" }
<?PHP include ("cfg.php"); session_start(); if($_SESSION['isLogin'] == 0) { header("location: index"); } ?> <?php if(isset($_POST['delete_account'])){ $get_record = $_POST['recorded']; $result = $db->prepare("DELETE FROM account WHERE account_id = ?"); $result->execute([$get_record]); unset($_POST); header("location: ".$_SERVER['PHP_SELF']); } if(isset($_POST['addAccount'])){ $userid = htmlentities($_POST['usr'], ENT_QUOTES); $userpas = sha1($_POST['pwd']); $usersname = htmlentities($_POST['acname'], ENT_QUOTES); $userposition = htmlentities($_POST['actype'], ENT_QUOTES); $result = $db->prepare("INSERT INTO account (account_id, password, accountName, position) VALUES (?,?,?,?)"); $result->execute([$userid, $userpas, $usersname, $userposition]); unset($_POST); header("location: ".$_SERVER['PHP_SELF']); } ?> <!DOCTYPE html> <html lang="en"> <head> <link rel="shortcut icon" href="favicon.ico"/> <link rel="stylesheet" href="bootswatch/solar/bootstrap.min.css"> <script src="bootstrap-3.3.7-dist/js/jquery.min.js"></script> <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script> <meta charset="utf8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Accounts</title> <script> $(document).ready(function(){ $('#delAccount').on('show.bs.modal', function (e) { var rowid = $(e.relatedTarget).data('id'); $.ajax({ cache: false, type : 'post', url : 'delete_account.php', //Here you will fetch records data : 'rowid='+ rowid, //Pass $id success : function(data){ $('.edit-data').html(data);//Show fetched data from database } }); }); }); $(document).ready(function(){ $('.dropdown-toggle').dropdown() }); </script> </head> <body> <div class="modal fade" id="addAccount" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Add User Account</h4> <form method="post" action=""> </div> <div class="modal-body"> <table class="table borderless"> <tr> <td><label for="usr">User ID: </label></td> <td><input type="text" class="form-control" id="usr" name="usr" placeholder="Enter user account"></td> </tr> <tr> <td><label for="pwd">Password:</label></td> <td><input type="password" class="form-control" id="pwd" name="pwd" placeholder="Enter password"></td> </tr> <tr> <td><label for="name">Account Name / Nickname:</label></td> <td><input type="text" class="form-control" id="name" name="acname" placeholder="John" required></td> </tr> <?php $result = $db->prepare("SELECT count(*) as total FROM account WHERE position = ?"); $result->execute(["Admin Account"]); foreach($result as $row){ $abled = $row['total']; if($abled == "2"){ echo '<tr>'; echo '<td><label for="actype">Account Type:</label></td>'; echo '<td><select name="actype" id="actype" class="form-control">'; echo '<option value="Guest" selected>Guest</option>'; echo '</select>'; echo '</td>'; echo '</tr>'; } else{ echo '<tr>'; echo '<td><label for="actype">Account Type:</label></td>'; echo '<td><select name="actype" id="actype" class="form-control">'; echo '<option value="Admin Account">Admin</option>'; echo '<option value="Guest" selected>Guest</option>'; echo '</select>'; echo '</td>'; echo '</tr>'; } } ?> </table> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" name="addAccount">Add Account</button> </form> </div> </div> </div> </div> <div class="modal" id="delAccount" role="dialog"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Delete User Account</h4> </div> <form action="" method="POST"> <div class="modal-body"> <div class="edit-data"></div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="submit" name="delete_account" class="btn btn-danger">Confirm</button> </div> </form> </div> </div> </div> <nav class="navbar navbar-default navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="home">RAO SYSTEM <?PHP echo $_SESSION['budget']; ?> </a> </div> <ul class="nav navbar-nav"> <li><a class="dropdown-toggle" data-toggle="dropdown" href="home">Home <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="add_year">Budget Year</a></li> <li><a href="aipMMO">AIP</a></li> <li><a href="heads">Department Heads List</a></li> <li><a href="export_all_ps">RAO <?PHP echo $_SESSION['budget']; ?> </a></li> </ul> </li> <li><a class="dropdown-toggle" data-toggle="dropdown" href="#">Registry Allotment and Obligations (RAO) <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="personal_services_mmo_all">Personal Services</a></li> <li><a href="mooe_mmo_all">Maint. And Other Operating Expenses</a></li> <li><a href="co_mmo_all">Capital Outlay</a></li> <li><a href="rao20">20&#37; EDF</a></li> <li><a href="none-office">Non - Office</a></li> <li><a href="gad">5% Gender and Development (GAD)</a></li> <li><a href="continuing_all">Continuing Program</a></li> <li><a href="sef">Special Eduction Fund (SEF)</a></li> <li><a href="mdr">5% Municipal Disaster Risk</a></li> <li><a href="pwds">1% Senior Citizens & Persons With Disabilities</a></li> <li><a href="1iralcpc">1% IRA &amp; LCPC</a></li> </ul> </li> <li><a class="dropdown-toggle" data-toggle="dropdown" href="#">Reports <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="gen_january">SAAO</a></li> <li><a href="saaob">SAAOB</a></li> </ul> </li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="#" class="btn" data-toggle="modal" data-target="#addAccount"><span class="glyphicon glyphicon-plus"></span></a></li> <li><a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-user"></span>&nbsp;<span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="#" style="color:gray; pointer-events: none; border-bottom: 1px solid #ddd" tabindex="-1"><?PHP echo $_SESSION['isLoginName']; ?></a></li> <li><a href="accounts">Accounts</a></li> <li><a href="log">Audit Log</a></li> <li><a href="logmeOut">Log Out</a></li> </ul> </div> </nav> <div class="container"> <div style="margin-top:70px;"> <table class="table table-condensed table-hover table-striped"> <thead> <tr> <th>Account ID</th> <th>Account Name</th> <th>Account Type</th> <th></th> </tr> </thead> <?PHP # Perform database query $query = "SELECT * FROM `account` WHERE account_id != ? ORDER BY `account_id` ASC"; $result = $db->prepare($query); $result->execute(["root"]); foreach($result as $row) { echo '<tr>'; echo '<td>'.$row['account_id'].'</td>'; echo '<td>'.$row['accountName'].'</td>'; echo '<td>'.$row['position'].'</td>'; echo '<td><button type="submit" class="btn btn-danger btn-xs" name="btn_delete" data-id="'.$row['account_id'].'" data-toggle="modal" data-target="#delAccount"><span class="glyphicon glyphicon-trash"></span></button>'; echo '</tr>'; } ?> </table> </div> </div> </body> </html>
d87cf8ae712c747c5768c8799faa3d75790d97f8
{ "blob_id": "d87cf8ae712c747c5768c8799faa3d75790d97f8", "branch_name": "refs/heads/master", "committer_date": "2018-01-28T06:01:20", "content_id": "40423f2ee0965b2434152129b13befa7097d6ee6", "detected_licenses": [ "MIT" ], "directory_id": "f2b76a80017130eed113ccd169b6aefbcf67ddf8", "extension": "php", "filename": "accounts.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 119224092, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 8568, "license": "MIT", "license_type": "permissive", "path": "/Budget/accounts.php", "provenance": "stack-edu-0050.json.gz:567900", "repo_name": "cloudsky21/rao", "revision_date": "2018-01-28T06:01:20", "revision_id": "ac012b41957e3e0fe0aa29d339def1b896990161", "snapshot_id": "cf6a5feb65b38201934512333c98bf6595ce98ca", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/cloudsky21/rao/ac012b41957e3e0fe0aa29d339def1b896990161/Budget/accounts.php", "visit_date": "2021-09-05T13:33:29.945153", "added": "2024-11-19T01:45:22.174411+00:00", "created": "2018-01-28T06:01:20", "int_score": 2, "score": 2.34375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0068.json.gz" }
package itbit import ( "bytes" "errors" "fmt" "log" "net/url" "strconv" "time" "github.com/thrasher-/gocryptotrader/common" "github.com/thrasher-/gocryptotrader/config" "github.com/thrasher-/gocryptotrader/exchanges" "github.com/thrasher-/gocryptotrader/exchanges/ticker" ) const ( ITBIT_API_URL = "https://api.itbit.com/v1" ITBIT_API_VERSION = "1" ) type ItBit struct { exchange.Base } func (i *ItBit) SetDefaults() { i.Name = "ITBIT" i.Enabled = false i.MakerFee = -0.10 i.TakerFee = 0.50 i.Verbose = false i.Websocket = false i.RESTPollingDelay = 10 i.RequestCurrencyPairFormat.Delimiter = "" i.RequestCurrencyPairFormat.Uppercase = true i.ConfigCurrencyPairFormat.Delimiter = "" i.ConfigCurrencyPairFormat.Uppercase = true i.AssetTypes = []string{ticker.Spot} } func (i *ItBit) Setup(exch config.ExchangeConfig) { if !exch.Enabled { i.SetEnabled(false) } else { i.Enabled = true i.AuthenticatedAPISupport = exch.AuthenticatedAPISupport i.SetAPIKeys(exch.APIKey, exch.APISecret, exch.ClientID, false) i.RESTPollingDelay = exch.RESTPollingDelay i.Verbose = exch.Verbose i.Websocket = exch.Websocket i.BaseCurrencies = common.SplitStrings(exch.BaseCurrencies, ",") i.AvailablePairs = common.SplitStrings(exch.AvailablePairs, ",") i.EnabledPairs = common.SplitStrings(exch.EnabledPairs, ",") err := i.SetCurrencyPairFormat() if err != nil { log.Fatal(err) } err = i.SetAssetTypes() if err != nil { log.Fatal(err) } } } func (i *ItBit) GetFee(maker bool) float64 { if maker { return i.MakerFee } return i.TakerFee } func (i *ItBit) GetTicker(currency string) (Ticker, error) { path := ITBIT_API_URL + "/markets/" + currency + "/ticker" var itbitTicker Ticker err := common.SendHTTPGetRequest(path, true, &itbitTicker) if err != nil { return Ticker{}, err } return itbitTicker, nil } func (i *ItBit) GetOrderbook(currency string) (OrderbookResponse, error) { response := OrderbookResponse{} path := ITBIT_API_URL + "/markets/" + currency + "/order_book" err := common.SendHTTPGetRequest(path, true, &response) if err != nil { return OrderbookResponse{}, err } return response, nil } func (i *ItBit) GetTradeHistory(currency, timestamp string) bool { req := "/trades?since=" + timestamp err := common.SendHTTPGetRequest(ITBIT_API_URL+"markets/"+currency+req, true, nil) if err != nil { log.Println(err) return false } return true } func (i *ItBit) GetWallets(params url.Values) { params.Set("userId", i.ClientID) path := "/wallets?" + params.Encode() err := i.SendAuthenticatedHTTPRequest("GET", path, nil) if err != nil { log.Println(err) } } func (i *ItBit) CreateWallet(walletName string) { path := "/wallets" params := make(map[string]interface{}) params["userId"] = i.ClientID params["name"] = walletName err := i.SendAuthenticatedHTTPRequest("POST", path, params) if err != nil { log.Println(err) } } func (i *ItBit) GetWallet(walletID string) { path := "/wallets/" + walletID err := i.SendAuthenticatedHTTPRequest("GET", path, nil) if err != nil { log.Println(err) } } func (i *ItBit) GetWalletBalance(walletID, currency string) { path := "/wallets/ " + walletID + "/balances/" + currency err := i.SendAuthenticatedHTTPRequest("GET", path, nil) if err != nil { log.Println(err) } } func (i *ItBit) GetWalletTrades(walletID string, params url.Values) { path := common.EncodeURLValues("/wallets/"+walletID+"/trades", params) err := i.SendAuthenticatedHTTPRequest("GET", path, nil) if err != nil { log.Println(err) } } func (i *ItBit) GetWalletOrders(walletID string, params url.Values) { path := common.EncodeURLValues("/wallets/"+walletID+"/orders", params) err := i.SendAuthenticatedHTTPRequest("GET", path, nil) if err != nil { log.Println(err) } } func (i *ItBit) PlaceWalletOrder(walletID, side, orderType, currency string, amount, price float64, instrument string, clientRef string) { path := "/wallets/" + walletID + "/orders" params := make(map[string]interface{}) params["side"] = side params["type"] = orderType params["currency"] = currency params["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) params["price"] = strconv.FormatFloat(price, 'f', -1, 64) params["instrument"] = instrument if clientRef != "" { params["clientOrderIdentifier"] = clientRef } err := i.SendAuthenticatedHTTPRequest("POST", path, params) if err != nil { log.Println(err) } } func (i *ItBit) GetWalletOrder(walletID, orderID string) { path := "/wallets/" + walletID + "/orders/" + orderID err := i.SendAuthenticatedHTTPRequest("GET", path, nil) if err != nil { log.Println(err) } } func (i *ItBit) CancelWalletOrder(walletID, orderID string) { path := "/wallets/" + walletID + "/orders/" + orderID err := i.SendAuthenticatedHTTPRequest("DELETE", path, nil) if err != nil { log.Println(err) } } func (i *ItBit) PlaceWithdrawalRequest(walletID, currency, address string, amount float64) { path := "/wallets/" + walletID + "/cryptocurrency_withdrawals" params := make(map[string]interface{}) params["currency"] = currency params["amount"] = amount params["address"] = address err := i.SendAuthenticatedHTTPRequest("POST", path, params) if err != nil { log.Println(err) } } func (i *ItBit) GetDepositAddress(walletID, currency string) { path := "/wallets/" + walletID + "/cryptocurrency_deposits" params := make(map[string]interface{}) params["currency"] = currency err := i.SendAuthenticatedHTTPRequest("POST", path, params) if err != nil { log.Println(err) } } func (i *ItBit) WalletTransfer(walletID, sourceWallet, destWallet string, amount float64, currency string) { path := "/wallets/" + walletID + "/wallet_transfers" params := make(map[string]interface{}) params["sourceWalletId"] = sourceWallet params["destinationWalletId"] = destWallet params["amount"] = strconv.FormatFloat(amount, 'f', -1, 64) params["currencyCode"] = currency err := i.SendAuthenticatedHTTPRequest("POST", path, params) if err != nil { log.Println(err) } } func (i *ItBit) SendAuthenticatedHTTPRequest(method string, path string, params map[string]interface{}) (err error) { if !i.AuthenticatedAPISupport { return fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet, i.Name) } if i.Nonce.Get() == 0 { i.Nonce.Set(time.Now().UnixNano()) } else { i.Nonce.Inc() } request := make(map[string]interface{}) url := ITBIT_API_URL + path if params != nil { for key, value := range params { request[key] = value } } PayloadJSON := []byte("") if params != nil { PayloadJSON, err = common.JSONEncode(request) if err != nil { return errors.New("SendAuthenticatedHTTPRequest: Unable to JSON Marshal request") } if i.Verbose { log.Printf("Request JSON: %s\n", PayloadJSON) } } message, err := common.JSONEncode([]string{method, url, string(PayloadJSON), i.Nonce.String(), i.Nonce.String()[0:13]}) if err != nil { log.Println(err) return } hash := common.GetSHA256([]byte(i.Nonce.String() + string(message))) hmac := common.GetHMAC(common.HashSHA512, []byte(url+string(hash)), []byte(i.APISecret)) signature := common.Base64Encode(hmac) headers := make(map[string]string) headers["Authorization"] = i.ClientID + ":" + signature headers["X-Auth-Timestamp"] = i.Nonce.String()[0:13] headers["X-Auth-Nonce"] = i.Nonce.String() headers["Content-Type"] = "application/json" resp, err := common.SendHTTPRequest(method, url, headers, bytes.NewBuffer([]byte(PayloadJSON))) if i.Verbose { log.Printf("Received raw: \n%s\n", resp) } return nil }
2da89e8115fe78a19fda23dff7bc4869aa652bdc
{ "blob_id": "2da89e8115fe78a19fda23dff7bc4869aa652bdc", "branch_name": "refs/heads/master", "committer_date": "2017-09-29T01:21:28", "content_id": "80aec2b0bb2f282b4c0a430bfcdcd61adde4bcc7", "detected_licenses": [ "MIT" ], "directory_id": "e658253fc1088608afe0cd0a7093723da9edda63", "extension": "go", "filename": "itbit.go", "fork_events_count": 0, "gha_created_at": "2017-09-29T09:09:21", "gha_event_created_at": "2017-09-29T09:09:21", "gha_language": null, "gha_license_id": null, "github_id": 105253004, "is_generated": false, "is_vendor": false, "language": "Go", "length_bytes": 7623, "license": "MIT", "license_type": "permissive", "path": "/exchanges/itbit/itbit.go", "provenance": "stack-edu-0016.json.gz:681806", "repo_name": "cawood/gocryptotrader", "revision_date": "2017-09-29T01:21:28", "revision_id": "3240a1657e384b6707c132517159703fbe17115c", "snapshot_id": "77161130f073c4b2d29892f87fe60da21e2f9e85", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/cawood/gocryptotrader/3240a1657e384b6707c132517159703fbe17115c/exchanges/itbit/itbit.go", "visit_date": "2021-07-04T23:35:44.359840", "added": "2024-11-18T19:03:02.345182+00:00", "created": "2017-09-29T01:21:28", "int_score": 2, "score": 2.1875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0034.json.gz" }
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ class Solution { public int[] findFrequentTreeSum(TreeNode root) { Map<Integer, Integer> sums = new HashMap<>(); this.dfs(root, sums); if (sums.size() == 0) { return new int[0]; } int max = sums.entrySet() .stream() .max(Map.Entry.comparingByValue()) .get() .getValue(); return sums.entrySet() .stream() .filter(e -> e.getValue().equals(max)) .map(e -> e.getKey()) .mapToInt(i -> i) .toArray(); } private int dfs(TreeNode root, Map<Integer, Integer> sums) { if (null == root) { return 0; } int sum = root.val + this.dfs(root.left, sums) + this.dfs(root.right, sums); int count = sums.getOrDefault(sum, 0) + 1; sums.put(sum, count); return sum; } }
92a04eead77d4e9966cf89f86196e1a5df02f589
{ "blob_id": "92a04eead77d4e9966cf89f86196e1a5df02f589", "branch_name": "refs/heads/master", "committer_date": "2023-06-02T01:33:59", "content_id": "efe46a5614c5883b16fcc58e1fdd05a158981f27", "detected_licenses": [ "MIT" ], "directory_id": "e4516bc1ef2407c524af95f5b6754b3a3c37b3cc", "extension": "java", "filename": "Most Frequent Subtree Sum.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 3762869, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 1071, "license": "MIT", "license_type": "permissive", "path": "/answers/leetcode/Most Frequent Subtree Sum/Most Frequent Subtree Sum.java", "provenance": "stack-edu-0025.json.gz:117124", "repo_name": "FeiZhan/Algo-Collection", "revision_date": "2023-06-02T01:33:59", "revision_id": "9ecfe00151aa18e24846e318c8ed7bea9af48a57", "snapshot_id": "7102732d61f324ffe5509ee48c5015b2a96cd58d", "src_encoding": "UTF-8", "star_events_count": 4, "url": "https://raw.githubusercontent.com/FeiZhan/Algo-Collection/9ecfe00151aa18e24846e318c8ed7bea9af48a57/answers/leetcode/Most Frequent Subtree Sum/Most Frequent Subtree Sum.java", "visit_date": "2023-06-10T17:36:53.473372", "added": "2024-11-18T21:34:43.685234+00:00", "created": "2023-06-02T01:33:59", "int_score": 3, "score": 3.3125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0043.json.gz" }
#include<iostream> #include<string.h> #include<stdlib.h> using namespace std; class book{ char* title; char* author; char* publisher; float* price; int* stock; public: book(){ title = new char[20]; author = new char[20]; publisher = new char[20]; price = new float; stock = new int; } void feeddata(); void buybook(); void showdata(); void editdata(); int searchh(char[],char[]); }; void book::feeddata(){ cin.ignore(); cout << "\nEnter title name : "; cin.getline(title,20); cout << "Enter author name : "; cin.getline(author,20); cout << "Enter publisher name : "; cin.getline(publisher,20); cout << "Enter Books price : "; cin >> *price; cout << "Enter Books stock : "; cin >> *stock; } int book::searchh(char tbuy[20],char abuy[20]){ if(strcmp(tbuy,title)==0 && strcmp(abuy,author)==0){ return 1; } else{ return 0; } } void book::buybook(){ int copies; cout << "\nHow many copies need to buy : "; cin >> copies; if(copies<=*stock){ *stock=*stock-copies; cout << "Total amount of the bill : " << (*price)*copies; } else cout << "Require amount of books are not in stock"; } void book::showdata(){ cout << "\nDetails of the books : " ; cout << "\nName of the book : " << title; cout << "\nName of the author : " << author; cout << "\nName of the publisher : " << publisher; cout << "\nPrice of the book : " << *price; cout << "\nStock position of the book : " << *stock; } void book::editdata(){ cin.ignore(); cout << "\nEnter title name : "; cin.getline(title,20); cout << "Enter author name : "; cin.getline(author,20); cout << "Enter publisher name : "; cin.getline(publisher,20); cout << "Enter Books price : "; cin >> *price; cout << "Enter Books stock : "; cin >> *stock; } int main(){ book *o_book[20]; int option,countt=0,i=0; char title[20]; char author[20]; while(1){ cout<< "\nMenu : " << "\n1. Add New books" << "\n2. Buy books" << "\n3. Show books" << "\n4. Edit book details" << "\n5. quite"; cout << "\n\nEnter appropriate number : "; cin >> option; switch(option){ case 1 : { o_book[countt] = new book; o_book[countt]->feeddata(); countt++; break; } case 2 :{cin.ignore(); cout << "Enter the name of the book : " ; cin.getline(title,20); cout << "Enter the name of the author : " ; cin.getline(author,20); for(i=0;i<countt;i++){ if(o_book[i]->searchh(title,author)){ o_book[i]->buybook(); break; } } if(i==countt){ cout<<"\nThis Book is Not in Stock"; }break;} case 3 :{cin.ignore(); cout << "Enter the name of the book : " ; cin.getline(title,20); cout << "Enter the name of the author : " ; cin.getline(author,20); for(i=0;i<countt;i++){ if(o_book[i]->searchh(title,author)){ o_book[i]->showdata(); break; } } if(i==countt){ cout<<"\nThis Book is Not in Stock"; }break;} case 4 :{cin.ignore(); cout << "Enter the name of the book : " ; cin.getline(title,20); cout << "Enter the name of the author : " ; cin.getline(author,20); for(i=0;i<countt;i++){ if(o_book[i]->searchh(title,author)){ o_book[i]->editdata(); break; } } if(i==countt){ cout<<"\nThis Book is Not in Stock"; }break;} case 5 :{exit(0);} default : cout << "\nin appropriate input,choose valid option."; } } return 0; }
c2f2fcdbbdca5d594b0337f2f9d05a20f2dc900b
{ "blob_id": "c2f2fcdbbdca5d594b0337f2f9d05a20f2dc900b", "branch_name": "refs/heads/master", "committer_date": "2020-10-29T12:59:52", "content_id": "2cdbc1caa76c036ae7fd458e3c3889ed973fa57a", "detected_licenses": [ "MIT" ], "directory_id": "c0177f6ee9ed5fcd549ce48af2a6b2eab14219f6", "extension": "cpp", "filename": "main2.cpp", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 210374010, "is_generated": false, "is_vendor": false, "language": "C++", "length_bytes": 4394, "license": "MIT", "license_type": "permissive", "path": "/OOP With C++/Chapter 6 'Constructers and Destructors'/programming exercises/6.3 book store/main2.cpp", "provenance": "stack-edu-0008.json.gz:578463", "repo_name": "idesign0/robotics", "revision_date": "2020-10-29T12:59:52", "revision_id": "69a7961a563276fbf021814c0b4577d4c45f3eb8", "snapshot_id": "99d8f9be5690485a0b78120d815521a2617429b5", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/idesign0/robotics/69a7961a563276fbf021814c0b4577d4c45f3eb8/OOP With C++/Chapter 6 'Constructers and Destructors'/programming exercises/6.3 book store/main2.cpp", "visit_date": "2021-07-09T18:26:27.739304", "added": "2024-11-18T21:41:07.036077+00:00", "created": "2020-10-29T12:59:52", "int_score": 3, "score": 3.203125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0026.json.gz" }
package cn.lxw.us; import android.support.v7.app.AppCompatActivity; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ProgressBar; import android.widget.Toast; import cn.jpush.android.api.JPushInterface; /** * Created by Lianxw on 2015/7/31. * */ public class BaseActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); JPushInterface.onResume(this); } @Override protected void onPause() { super.onPause(); JPushInterface.onPause(this); } public void showProgress() { FrameLayout content = (FrameLayout)findViewById(android.R.id.content); if(content.findViewById(R.id.pb_loading)==null) { ProgressBar progressBar = new ProgressBar(this); progressBar.setId(R.id.pb_loading); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; progressBar.setLayoutParams(params); content.addView(progressBar); } } public void hideProgress() { FrameLayout content = (FrameLayout)findViewById(android.R.id.content); View progress = content.findViewById(R.id.pb_loading); if (progress!=null) { content.removeView(progress); } } protected void showToast(CharSequence text) { Toast.makeText(this,text,Toast.LENGTH_SHORT).show(); } }
25661f005f789f2417a2a890af71606779f46457
{ "blob_id": "25661f005f789f2417a2a890af71606779f46457", "branch_name": "refs/heads/master", "committer_date": "2015-11-04T06:00:31", "content_id": "f486230fd19f9d954c840782b7bccd07044d981e", "detected_licenses": [ "MIT" ], "directory_id": "60ab5b97ffc67fd35366939a6ba8f6b7a9a121f4", "extension": "java", "filename": "BaseActivity.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 41086560, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 1640, "license": "MIT", "license_type": "permissive", "path": "/BaseActivity.java", "provenance": "stack-edu-0026.json.gz:772578", "repo_name": "kaixinhupo/android_snippets", "revision_date": "2015-11-04T06:00:31", "revision_id": "fada52b6b5511c35595c201b7932e4ca5cf21184", "snapshot_id": "5965f795f74647209b6e8a155c9476cd6dc8f7bc", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/kaixinhupo/android_snippets/fada52b6b5511c35595c201b7932e4ca5cf21184/BaseActivity.java", "visit_date": "2021-01-19T20:27:34.278268", "added": "2024-11-19T01:44:40.361381+00:00", "created": "2015-11-04T06:00:31", "int_score": 2, "score": 2.125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0044.json.gz" }
package com.springsource.html5expense.services; import com.springsource.html5expense.EligibleCharge; import com.springsource.html5expense.EligibleChargeService; import com.springsource.html5expense.Expense; import com.springsource.html5expense.ExpenseReport; import com.springsource.html5expense.repositories.EligibleChargeRepository; import com.springsource.html5expense.repositories.ExpenseReportRepository; import com.springsource.html5expense.repositories.ExpenseRepository; import com.springsource.html5expense.services.utilities.MongoDbGridFsUtilities; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.inject.Inject; import java.io.ByteArrayInputStream; //import java.io.File; import java.io.InputStream; import java.math.BigDecimal; import java.util.Collection; import java.util.Date; import java.util.List; @Service public class EligibleChargeServiceImpl implements EligibleChargeService { @Inject private ExpenseReportRepository ExpenseReportRepository; @Inject private EligibleChargeRepository eligibleChargeRepository; @Inject private ExpenseRepository expenseRepository; @Inject private MongoDbGridFsUtilities mongoDbGridFsUtilities; private String mongoDbGridFsFileBucket = "expenseReports"; //private File tmpDir = new File(SystemUtils.getUserHome(), "receipts"); public InputStream retrieveReceipt(Long expenseId) { Expense e = expenseRepository.getExpense(expenseId); String fn = fileNameForReceipt(e); return mongoDbGridFsUtilities.read(mongoDbGridFsFileBucket, fn); } @Transactional(readOnly = true) public Collection<EligibleCharge> getEligibleCharges() { return eligibleChargeRepository.getEligibleCharges(); } public EligibleCharge createEligibleCharge(Date date, String merchant, String category, BigDecimal amt) { EligibleCharge charge = new EligibleCharge(date, merchant, category, amt); eligibleChargeRepository.save(charge); return charge; } public void restoreEligibleCharges(List<Long> expenseIds) { for (Long l : expenseIds) { Expense e = expenseRepository.getExpense(l); EligibleCharge eligibleCharge = createEligibleCharge(e.getDate(), e.getMerchant(), e.getCategory(), e.getAmount()); if (eligibleCharge != null) { expenseRepository.delete(e); } } } public String attachReceipt(Long reportId, Long expenseId, String ext, byte[] receiptBytes) { String reportAndExpenseKey = keyForExpenseReceipt(reportId, expenseId); Expense expense = expenseRepository.getExpense(expenseId); ExpenseReport report = ExpenseReportRepository.findById(reportId); report.attachReceipt(expenseId, reportAndExpenseKey, ext); writeExpenseReceiptToDurableMedia(expense, receiptBytes); return reportAndExpenseKey; } public List<EligibleCharge> getEligibleCharges(List<Long> chargeIds) { return eligibleChargeRepository.getEligibleCharges(chargeIds); } private String keyForExpenseReceipt(Long reportId, Long expenseId) { return "receipt-" + reportId + "-" + (expenseId) + ""; } private String fileNameForReceipt(String key, String ext) { return key + "." + ext; } public void removeAddedCharges(List<Long> chargeIds) { eligibleChargeRepository.removeAddedCharges(chargeIds); } /** * Delegates to MongoDB gridfs to persist the receipts themselves. * * @param expense the expense to which the receipt was to be attached * @param receiptBytes the bytes for the receipt image, itself. */ private void writeExpenseReceiptToDurableMedia(Expense expense, byte[] receiptBytes) { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(receiptBytes); String fileNameOfReceipt = fileNameForReceipt(expense); mongoDbGridFsUtilities.write(mongoDbGridFsFileBucket, byteArrayInputStream, fileNameOfReceipt, null); } private String fileNameForReceipt(Expense e) { return fileNameForReceipt(e.getReceipt(), e.getReceiptExtension()); } }
351d7660d4d0271057bda38a003bb17ee2cb54a4
{ "blob_id": "351d7660d4d0271057bda38a003bb17ee2cb54a4", "branch_name": "refs/heads/master", "committer_date": "2012-03-06T06:25:04", "content_id": "12af284d69f594fcec3a12db8143497f4797ef07", "detected_licenses": [ "Apache-2.0" ], "directory_id": "4c21d8e9f45b1a1c756dcdd2481973b9a8cd0db3", "extension": "java", "filename": "EligibleChargeServiceImpl.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 3621006, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 4249, "license": "Apache-2.0", "license_type": "permissive", "path": "/server/api/src/main/java/com/springsource/html5expense/services/EligibleChargeServiceImpl.java", "provenance": "stack-edu-0031.json.gz:502678", "repo_name": "bytor99999/html5expense", "revision_date": "2012-03-06T06:25:04", "revision_id": "b903919565d39ad013e1c54f29758c795f466702", "snapshot_id": "b053dd29fdbbc3570cf2ef656fa5bd729cd3d678", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/bytor99999/html5expense/b903919565d39ad013e1c54f29758c795f466702/server/api/src/main/java/com/springsource/html5expense/services/EligibleChargeServiceImpl.java", "visit_date": "2020-12-01T01:06:16.869485", "added": "2024-11-19T00:36:33.780728+00:00", "created": "2012-03-06T06:25:04", "int_score": 2, "score": 2.0625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0049.json.gz" }
package tech.peterj.coinpamp.services; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import java.io.IOException; import java.util.logging.Logger; @Service public class Scheduler { private static final Logger LOGGER = Logger.getLogger(Scheduler.class.getName()); private final CoinStatsFetcher coinStatsFetcher; public Scheduler(CoinStatsFetcher coinStatsFetcher) { this.coinStatsFetcher = coinStatsFetcher; } @Scheduled(fixedDelay = 300000) // fetch every 5 minutes: fixedDelay = 300000 public void doScheduledUpdate() throws IOException, InterruptedException { LOGGER.info("performing scheduled update ..."); coinStatsFetcher.fetchCoinPriceDataForToday(); } }
4123a9aad8c01f735266cbc5be818607efdb387a
{ "blob_id": "4123a9aad8c01f735266cbc5be818607efdb387a", "branch_name": "refs/heads/main", "committer_date": "2021-08-01T16:26:37", "content_id": "79cf826372941c45b781dde3e78c28d9430a5596", "detected_licenses": [ "MIT" ], "directory_id": "705f1fed11b37f356cc2b5a7d5d9de4ba443aa42", "extension": "java", "filename": "Scheduler.java", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 385987977, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 782, "license": "MIT", "license_type": "permissive", "path": "/src/main/java/tech/peterj/coinpamp/services/Scheduler.java", "provenance": "stack-edu-0023.json.gz:776111", "repo_name": "Sph3ricalPeter/coinpamp-api", "revision_date": "2021-08-01T16:26:37", "revision_id": "63abde5136ef8ddbbf738e28bf36b88a03a05f7e", "snapshot_id": "16445213564ad2775f33995a950c88cb66dd535a", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Sph3ricalPeter/coinpamp-api/63abde5136ef8ddbbf738e28bf36b88a03a05f7e/src/main/java/tech/peterj/coinpamp/services/Scheduler.java", "visit_date": "2023-06-26T11:50:14.142773", "added": "2024-11-19T02:48:27.403289+00:00", "created": "2021-08-01T16:26:37", "int_score": 2, "score": 2.390625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0041.json.gz" }
'use strict'; const chalk = require('chalk'); const redis = require('redis'); const {connectionString} = require('./local_settings.js'); const SENSORS_CHANNEL = 'sensors_data'; const ACTIONS_CHANNEL = 'perform_action'; // The sample connects to a device-specific MQTT endpoint on your IoT Hub. var Mqtt = require('azure-iot-device-mqtt').Mqtt; var DeviceClient = require('azure-iot-device').Client var Message = require('azure-iot-device').Message; var client = DeviceClient.fromConnectionString(connectionString, Mqtt); const sub = redis.createClient() const pub = redis.createClient() function getData(request, response) { function directMethodResponse(err) { if(err) { console.error(chalk.red('An error ocurred when sending a method response:\n' + err.toString())); } else { console.log(chalk.green('Response to method \'' + request.methodName + '\' sent successfully.' )); } } console.log(chalk.green('Direct method payload received:')); console.log(chalk.green(request.payload)); if (!request.payload) { console.log(chalk.red('Invalid payload received')); response.send(400, 'Invalid direct method parameter: ' + request.payload, directMethodResponse); } else { pub.publish(ACTIONS_CHANNEL, JSON.stringify({action: request.payload})); response.send(200, 'Performing action set: ' + request.payload, directMethodResponse); } } // Print results. function printResultFor(op) { return function printResult(err, res) { if (err) console.log(op + ' error: ' + err.toString()); if (res) console.log(op + ' status: ' + res.constructor.name); }; } // Attach a listener to receive new messages as soon as subscribe to a channel. sub.on('message', function(channel, message) { // message is json string in our case so we are going to parse it. var message = new Message(message); console.log('Sending message: ' + message.getData()); // Send the message. client.sendEvent(message, printResultFor('send')); }) // Subscribe to a channel and start handling messages sub.subscribe(SENSORS_CHANNEL) client.onDeviceMethod('PerformAction', getData);
27462ef429a4500404a7497d37c8ba94226522fe
{ "blob_id": "27462ef429a4500404a7497d37c8ba94226522fe", "branch_name": "refs/heads/master", "committer_date": "2018-07-27T08:29:03", "content_id": "d9b140fdfeb5f4b7f4928c8e8fc9896978a737f2", "detected_licenses": [ "MIT" ], "directory_id": "2a734d0a826faae66925738c1459c332c9034739", "extension": "js", "filename": "iot_hub_connection.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": 2128, "license": "MIT", "license_type": "permissive", "path": "/raspberry_pi/iot_hub_connection.js", "provenance": "stack-edu-0043.json.gz:356282", "repo_name": "DennTerentyev/greenBotMessenger", "revision_date": "2018-07-27T08:29:03", "revision_id": "2ff537ef57732cebf72a4176c74adb09338d69e3", "snapshot_id": "c25c943cc210a18c012c2fb4d23115fe9446e584", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/DennTerentyev/greenBotMessenger/2ff537ef57732cebf72a4176c74adb09338d69e3/raspberry_pi/iot_hub_connection.js", "visit_date": "2020-03-27T11:05:38.665387", "added": "2024-11-18T22:54:30.752201+00:00", "created": "2018-07-27T08:29:03", "int_score": 3, "score": 2.640625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0061.json.gz" }
/* * Copyright 2004,2006 The Poderosa Project. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * * $Id: SSHSocket.cs,v 1.6 2011/11/19 04:58:43 kzmi Exp $ */ using System; using System.Text; using System.Net.Sockets; using System.IO; using System.Linq; using System.Diagnostics; using System.Threading; using Granados; using Granados.SSH2; using Granados.IO; using Granados.KeyboardInteractive; using Granados.SSH; using System.Threading.Tasks; namespace Poderosa.Protocols { //SSHの入出力系 internal abstract class SSHConnectionEventReceiverBase : ISSHConnectionEventHandler { protected SSHTerminalConnection _parent; protected ISSHConnection _connection; protected IByteAsyncInputStream _callback; private bool _normalTerminationCalled; public SSHConnectionEventReceiverBase(SSHTerminalConnection parent) { _parent = parent; } //SSHConnection確立時に呼ぶ public void SetSSHConnection(ISSHConnection connection) { _connection = connection; } public ISSHConnection Connection { get { return _connection; } } public virtual void CleanupErrorStatus() { if (_connection != null && _connection.IsOpen) { _connection.Close(); } } public abstract void Close(); public virtual void OnConnectionClosed() { OnNormalTerminationCore(); if (_connection != null && _connection.IsOpen) { _connection.Close(); } } public virtual void OnError(Exception error) { OnAbnormalTerminationCore(error.Message); } //TODO 滅多にないことではあるがこれを拾う先をEXTPで public virtual void OnDebugMessage(bool alwaysDisplay, string message) { Debug.WriteLine(String.Format("SSH debug {0}", message)); } public virtual void OnIgnoreMessage(byte[] data) { Debug.WriteLine(String.Format("SSH ignore {0}[{1}]", data.Length, data[0])); } public virtual void OnUnhandledMessage(byte type, byte[] data) { Debug.WriteLine(String.Format("Unexpected SSH packet type {0}", type)); } protected void OnNormalTerminationCore() { if (_normalTerminationCalled) return; /* NOTE * 正常終了の場合でも、SSHパケットレベルではChannelEOF, ChannelClose, ConnectionCloseがあり、場合によっては複数個が組み合わされることもある。 * 組み合わせの詳細はサーバの実装依存でもあるので、ここでは1回だけ必ず呼ぶということにする。 */ _normalTerminationCalled = true; _parent.CloseBySocket(); try { if (_callback != null) _callback.OnNormalTermination(); } catch (Exception ex) { CloseError(ex); } } protected void OnAbnormalTerminationCore(string msg) { _parent.CloseBySocket(); try { if (_callback != null) _callback.OnAbnormalTermination(msg); } catch (Exception ex) { CloseError(ex); } } //Termination処理の失敗時の処理 private void CloseError(Exception ex) { try { RuntimeUtil.ReportException(ex); CleanupErrorStatus(); } catch (Exception ex2) { RuntimeUtil.ReportException(ex2); } } } internal class SSHSocket : SSHConnectionEventReceiverBase, IPoderosaSocket, ITerminalOutput, IKeyboardInteractiveAuthenticationHandler { private SSHChannelHandler _channelHandler; private ByteDataFragment _data; private MemoryStream _buffer = new MemoryStream(); private KeyboardInteractiveAuthHanlder _keyboardInteractiveAuthHanlder; public SSHSocket(SSHTerminalConnection parent) : base(parent) { _data = new ByteDataFragment(); } public void RepeatAsyncRead(IByteAsyncInputStream cb) { _callback = cb; if (_channelHandler != null) { _channelHandler.SetReceptionHandler(cb); } } public override void CleanupErrorStatus() { if (_channelHandler != null) _channelHandler.Operator.Close(); base.CleanupErrorStatus(); } public void OpenShell() { var channelHandler = _connection.OpenShell( channelOperator => { var handler = new SSHChannelHandler(channelOperator, OnNormalTerminationCore, OnAbnormalTerminationCore); if (_callback != null) { handler.SetReceptionHandler(_callback); } return handler; } ); bool isReady = channelHandler.Operator.WaitReady(); if (!isReady) { ForceDisposed(); throw new Exception(PEnv.Strings.GetString("Message.SSHSocket.FailedToStartShell")); } _channelHandler = channelHandler; } public void OpenKeyboardInteractiveShell() { _channelHandler = new SSHChannelHandler(new NullSSHChannel(), OnNormalTerminationCore, OnAbnormalTerminationCore); if (_callback != null) { _channelHandler.SetReceptionHandler(_callback); } } public override void Close() { ForceDisposed(); } public void ForceDisposed() { try { if (_connection != null && _connection.IsOpen) { _connection.Disconnect(DisconnectionReasonCode.ByApplication, "bye"); } } catch(Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); } } public void Transmit(ByteDataFragment data) { Transmit(data.Buffer, data.Offset, data.Length); } public void Transmit(byte[] buf, int offset, int length) { if (_keyboardInteractiveAuthHanlder != null) { // intercept input _keyboardInteractiveAuthHanlder.OnData(buf, offset, length); return; } if (_channelHandler != null) { _channelHandler.Operator.Send(new DataFragment(buf, offset, length)); } } //以下、ITerminalOutput public void Resize(int width, int height) { if (!_parent.IsClosed && _channelHandler != null) _channelHandler.Operator.ResizeTerminal((uint)width, (uint)height, 0, 0); } public void SendBreak() { if (_parent.SSHLoginParameter.Method == SSHProtocol.SSH1) throw new NotSupportedException(); else if (_channelHandler != null) { _channelHandler.Operator.SendBreak(500); } } public void SendKeepAliveData() { if (!_parent.IsClosed) { // Note: // Disconnecting or Closing socket may happen before Send() is called. // In such case, SocketException or ObjectDisposedException will be thrown in Send(). // We just ignore the exceptions. try { _connection.SendIgnorableData("keep alive"); } catch (SocketException) { } catch (ObjectDisposedException) { } } } public void AreYouThere() { throw new NotSupportedException(); } public bool Available { get { return _connection.SocketStatusReader.DataAvailable; } } #region IKeyboardInteractiveAuthenticationHandler public string[] KeyboardInteractiveAuthenticationPrompt(string[] prompts, bool[] echoes) { if (_keyboardInteractiveAuthHanlder != null) { return _keyboardInteractiveAuthHanlder.KeyboardInteractiveAuthenticationPrompt(prompts, echoes); } else { return prompts.Select(s => "").ToArray(); } } public void OnKeyboardInteractiveAuthenticationStarted() { _keyboardInteractiveAuthHanlder = new KeyboardInteractiveAuthHanlder( (data) => { if (_channelHandler != null) { _channelHandler.OnData(new DataFragment(data, 0, data.Length)); } }); } public void OnKeyboardInteractiveAuthenticationCompleted(bool success, Exception error) { _keyboardInteractiveAuthHanlder = null; try { if (!success) { ForceDisposed(); throw new Exception(PEnv.Strings.GetString("Message.SSHSocket.AuthenticationFailed")); } OpenShell(); } catch (Exception e) { // FIXME: // the message will not be displayed... OnAbnormalTerminationCore(e.Message); } } #endregion } internal class SSHChannelHandler : ISSHChannelEventHandler { private readonly ISSHChannel _channelOperator; private readonly Action _onNormalTermination; private readonly Action<string> _onAbnormalTermination; private MemoryStream _buffer = new MemoryStream(); private readonly ByteDataFragment _dataFragment = new ByteDataFragment(); private IByteAsyncInputStream _output; private readonly object _outputSync = new object(); public SSHChannelHandler(ISSHChannel channelOperator, Action onNormalTermination, Action<string> onAbnormalTermination) { _channelOperator = channelOperator; _onNormalTermination = onNormalTermination; _onAbnormalTermination = onAbnormalTermination; } public ISSHChannel Operator { get { return _channelOperator; } } public void SetReceptionHandler(IByteAsyncInputStream output) { lock (_outputSync) { if (_output != null) { return; } _output = output; if (_buffer != null && _buffer.Length > 0) { byte[] bytes = _buffer.ToArray(); _buffer.Dispose(); _buffer = null; _dataFragment.Set(bytes, 0, bytes.Length); _output.OnReception(_dataFragment); } } } public void OnEstablished(DataFragment data) { } public void OnReady() { } public void OnData(DataFragment data) { lock (_outputSync) { if (_output == null) { if (_buffer != null) { _buffer.Write(data.Data, data.Offset, data.Length); } return; } _dataFragment.Set(data.Data, data.Offset, data.Length); _output.OnReception(_dataFragment); } } public void OnExtendedData(uint type, DataFragment data) { } public void OnClosing(bool byServer) { } public void OnClosed(bool byServer) { _onNormalTermination(); } public void OnEOF() { _onNormalTermination(); } public void OnRequestFailed() { } public void OnError(Exception error) { // FIXME: In this case, something message should be displayed for the user. // OnAbnormalTerminationCore() doesn't show the message. _onAbnormalTermination(error.Message); } public void OnUnhandledPacket(byte packetType, DataFragment data) { } public void OnConnectionLost() { } public void Dispose() { if (_buffer != null) { _buffer.Dispose(); _buffer = null; } } } /// <summary> /// Dummy channel object during keyboard-interactive authentication. /// </summary> internal class NullSSHChannel : ISSHChannel { public uint LocalChannel { get { throw new NotImplementedException(); } } public uint RemoteChannel { get { throw new NotImplementedException(); } } public ChannelType ChannelType { get { throw new NotImplementedException(); } } public string ChannelTypeString { get { throw new NotImplementedException(); } } public bool IsOpen { get { return true; } } public bool IsReady { get { return true; } } public int MaxChannelDatagramSize { get { return 1024; } } public void ResizeTerminal(uint width, uint height, uint pixelWidth, uint pixelHeight) { } public bool WaitReady() { return true; } public void Send(DataFragment data) { } public void SendEOF() { } public bool SendBreak(int breakLength) { return true; } public void Close() { } } /// <summary> /// Keyboard-interactive authentication support for <see cref="SSHSocket"/>. /// </summary> internal class KeyboardInteractiveAuthHanlder { private bool _echoing = true; private readonly MemoryStream _inputBuffer = new MemoryStream(); private readonly object _inputSync = new object(); private readonly Action<byte[]> _output; /// <summary> /// Constructor /// </summary> /// <param name="output">a method to output data to the terminal</param> public KeyboardInteractiveAuthHanlder(Action<byte[]> output) { _output = output; } /// <summary> /// Show prompt lines and input texts. /// </summary> /// <param name="prompts"></param> /// <param name="echoes"></param> /// <returns></returns> public string[] KeyboardInteractiveAuthenticationPrompt(string[] prompts, bool[] echoes) { Encoding encoding = (Encoding)Encoding.UTF8.Clone(); // TODO: encoding.EncoderFallback = EncoderFallback.ReplacementFallback; string[] inputs = new string[prompts.Length]; for (int i = 0; i < prompts.Length; ++i) { bool echo = (i < echoes.Length) ? echoes[i] : true; byte[] promptBytes = encoding.GetBytes(prompts[i]); // echo prompt text byte[] lineBytes; lock (_inputSync) { _output(promptBytes); _echoing = echo; _inputBuffer.SetLength(0); Monitor.Wait(_inputSync); _echoing = true; lineBytes = _inputBuffer.ToArray(); } string line = encoding.GetString(lineBytes); inputs[i] = line; } return inputs; } /// <summary> /// Process user input. /// </summary> public void OnData(byte[] data, int offset, int length) { int endIndex = offset + length; int currentIndex = offset; while (currentIndex < endIndex) { lock (_inputSync) { int startIndex = currentIndex; bool newLine = false; for (; currentIndex < endIndex; ++currentIndex) { byte b = data[currentIndex]; if (b == 13 || b == 10) { //CR/LF newLine = true; break; } _inputBuffer.WriteByte(b); } // flush if (_echoing && currentIndex > startIndex) { _output(GetBytes(data, startIndex, currentIndex - startIndex)); } if (newLine) { currentIndex++; _output(new byte[] { 13, 10 }); // CRLF // notify Monitor.PulseAll(_inputSync); } } } } private byte[] GetBytes(byte[] data, int offset, int length) { byte[] buf = new byte[length]; if (length > 0) { Buffer.BlockCopy(data, offset, buf, 0, length); } return buf; } } }
827b8d041012067143ad042a378c63a0c47a0195
{ "blob_id": "827b8d041012067143ad042a378c63a0c47a0195", "branch_name": "refs/heads/master", "committer_date": "2017-01-17T15:41:34", "content_id": "f0fa9347770614d72b1ae7bec255ec2e9297e221", "detected_licenses": [ "Apache-2.0" ], "directory_id": "372203ccc7afc6426cd181d7ddb840365d72c9bc", "extension": "cs", "filename": "SSHSocket.cs", "fork_events_count": 1, "gha_created_at": "2017-03-16T10:51:57", "gha_event_created_at": "2017-03-16T10:51:57", "gha_language": null, "gha_license_id": null, "github_id": 85185341, "is_generated": false, "is_vendor": false, "language": "C#", "length_bytes": 17609, "license": "Apache-2.0", "license_type": "permissive", "path": "/Protocols/SSHSocket.cs", "provenance": "stack-edu-0010.json.gz:526444", "repo_name": "hanamiche/poderosa", "revision_date": "2017-01-17T15:41:34", "revision_id": "18ed32e22ed5ea958b4f6a61658b2b140b768a0b", "snapshot_id": "0ee19b3e9d45c4e3217dfb8b6129621ab3de5fcd", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/hanamiche/poderosa/18ed32e22ed5ea958b4f6a61658b2b140b768a0b/Protocols/SSHSocket.cs", "visit_date": "2021-01-22T19:15:08.146295", "added": "2024-11-19T01:35:06.435546+00:00", "created": "2017-01-17T15:41:34", "int_score": 2, "score": 2.0625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0028.json.gz" }
import selectNext from './select-next'; const enterHandler = (e, formOptions, activeStep, findCurrentStep, handleNext, handleSubmit) => { if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey) { const isNotButton = e.target.type !== 'button'; if (isNotButton) { e.preventDefault(); const schemaNextStep = findCurrentStep(activeStep).nextStep; const hasCustomButtons = findCurrentStep(activeStep).buttons; let nextStep; if (schemaNextStep) { nextStep = selectNext(schemaNextStep, formOptions.getState); } const canContinue = formOptions.valid && !formOptions.getState().validating; if (canContinue && nextStep && !hasCustomButtons) { handleNext(nextStep, formOptions.getRegisteredFields); } else if (canContinue && !schemaNextStep && !hasCustomButtons) { handleSubmit(); } } } }; export default enterHandler;
2e7129969f537ffc206ede7d328ba5a8241e0067
{ "blob_id": "2e7129969f537ffc206ede7d328ba5a8241e0067", "branch_name": "refs/heads/master", "committer_date": "2023-08-31T07:12:30", "content_id": "5b92cf42b32eb79c8610e72a29818b5cfb73dae5", "detected_licenses": [ "Apache-2.0" ], "directory_id": "c534a49a872ae2ff89a0d04ad38d6b7baa3a97f5", "extension": "js", "filename": "enter-handler.js", "fork_events_count": 83, "gha_created_at": "2019-04-02T07:18:00", "gha_event_created_at": "2023-09-14T09:27:12", "gha_language": "JavaScript", "gha_license_id": "Apache-2.0", "github_id": 179020919, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 912, "license": "Apache-2.0", "license_type": "permissive", "path": "/packages/common/src/wizard/enter-handler.js", "provenance": "stack-edu-0033.json.gz:361620", "repo_name": "data-driven-forms/react-forms", "revision_date": "2023-08-31T07:12:30", "revision_id": "10a82a218034f97a22a3e973723236af668fd51d", "snapshot_id": "5112b585e0f5a29cadf4ae66beaa65042389d156", "src_encoding": "UTF-8", "star_events_count": 275, "url": "https://raw.githubusercontent.com/data-driven-forms/react-forms/10a82a218034f97a22a3e973723236af668fd51d/packages/common/src/wizard/enter-handler.js", "visit_date": "2023-08-31T21:28:54.903139", "added": "2024-11-18T22:29:11.593809+00:00", "created": "2023-08-31T07:12:30", "int_score": 2, "score": 2.296875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0051.json.gz" }
/* * Open Source Physics software is free software as described near the bottom of this code file. * * For additional information and documentation on Open Source Physics please see: * <http://www.opensourcephysics.org/> */ package org.opensourcephysics.display.axes; import java.awt.event.MouseEvent; import org.opensourcephysics.display.DrawingPanel; import org.opensourcephysics.display.InteractivePanel; /** * Builds a coordinate string from a mouse event for an axis type. */ public class PolarCoordinateStringBuilder extends CoordinateStringBuilder { protected String rLabel = "r="; //$NON-NLS-1$ protected String phiLabel = " phi="; //$NON-NLS-1$ protected double sin = 0, cos = 1; /** * Constructor PolarCoordinateStringBuilder */ public PolarCoordinateStringBuilder() { this("r=", " phi="); //$NON-NLS-1$ //$NON-NLS-2$ } /** * Constructor PolarCoordinateStringBuilder * @param rLabel * @param phiLabel * @param phiZero */ public PolarCoordinateStringBuilder(String rLabel, String phiLabel, double phiZero) { this(rLabel, phiLabel); sin = -Math.sin(phiZero); cos = Math.cos(phiZero); } /** * Constructor PolarCoordinateStringBuilder * @param rLabel * @param phiLabel */ public PolarCoordinateStringBuilder(String rLabel, String phiLabel) { this.rLabel = rLabel; this.phiLabel = phiLabel; } public void setCoordinateLabels(String rLabel, String phiLabel) { this.rLabel = rLabel; this.phiLabel = phiLabel; } /** * Converts a the pixel coordinates in a mouse event into world coordinates and * return these coordinates in a string. * * @param e the mouse event * @return the coordinate string */ public String getCoordinateString(DrawingPanel panel, MouseEvent e) { double x = panel.pixToX(e.getPoint().x); double y = panel.pixToY(e.getPoint().y); if((panel instanceof InteractivePanel)&&((InteractivePanel) panel).getCurrentDraggable()!=null) { x = ((InteractivePanel) panel).getCurrentDraggable().getX(); y = ((InteractivePanel) panel).getCurrentDraggable().getY(); } double r = Math.sqrt(x*x+y*y); String msg; if((r>100)||(r<0.01)) { msg = rLabel+scientificFormat.format((float) r); } else { msg = rLabel+decimalFormat.format((float) r); } msg += phiLabel+decimalFormat.format(180*(float) Math.atan2(x*sin+y*cos, x*cos-y*sin)/Math.PI); return msg; } } /* * Open Source Physics software is free software; you can redistribute * it and/or modify it under the terms of the GNU General Public License (GPL) as * published by the Free Software Foundation; either version 2 of the License, * or(at your option) any later version. * Code that uses any portion of the code in the org.opensourcephysics package * or any subpackage (subdirectory) of this package must must also be be released * under the GNU GPL license. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA * or view the license online at http://www.gnu.org/copyleft/gpl.html * * Copyright (c) 2007 The Open Source Physics project * http://www.opensourcephysics.org */
a7de28ec4f4c210036d298a45ab11aaaca222655
{ "blob_id": "a7de28ec4f4c210036d298a45ab11aaaca222655", "branch_name": "refs/heads/master", "committer_date": "2019-07-12T10:08:07", "content_id": "4a748e5c1c0b5eb4b1557086284389c5d61cad4b", "detected_licenses": [ "MIT" ], "directory_id": "3abd77888f87b9a874ee9964593e60e01a9e20fb", "extension": "java", "filename": "PolarCoordinateStringBuilder.java", "fork_events_count": 1, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 1663824, "is_generated": false, "is_vendor": false, "language": "Java", "length_bytes": 3574, "license": "MIT", "license_type": "permissive", "path": "/sim/EJS/OSP_core/src/org/opensourcephysics/display/axes/PolarCoordinateStringBuilder.java", "provenance": "stack-edu-0029.json.gz:470754", "repo_name": "joakimbits/Quflow-and-Perfeco-tools", "revision_date": "2019-07-12T10:08:07", "revision_id": "70af4320ead955d22183cd78616c129a730a9d9c", "snapshot_id": "7149dec3226c939cff10e8dbb6603fd4e936add0", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/joakimbits/Quflow-and-Perfeco-tools/70af4320ead955d22183cd78616c129a730a9d9c/sim/EJS/OSP_core/src/org/opensourcephysics/display/axes/PolarCoordinateStringBuilder.java", "visit_date": "2021-01-17T14:02:08.396445", "added": "2024-11-18T21:49:51.896352+00:00", "created": "2019-07-12T10:08:07", "int_score": 3, "score": 2.640625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0047.json.gz" }
<?php /** * Created by Edo Frenkel * http://www.lightapps.co.il * Date: 09/04/14 */ // important - don't remove set_time_limit(0); // DropPHP - A simple Dropbox client that works without cURL. require_once("lib/DropboxClient.php"); $config = array( // Define a username && password - without the correct username & password you can't start the process (which is a good thing!) "username" => "USER_NAME", "password" => "PASSWORD", // Define Dropbox app data "dropboxAppKey" => "DROPBOX_APP_KEY", "dropboxAppSecret" => "DROPBOX_APP_SECRET", // Define your tinyPNG api key "tinyPNGApiKey" => "TINYPNG_API_KEY", // the folder structure of the current project on your server // for example if your your project root is in: SERVER_ROOT/test/tinydrop/ // you should define: "/test/tinydrop/" "serverPath" => "SERVER_PATH", // the path to Dropbox folder // for example if your folder is in: c:\dropbox\project\Assets\SpriteCollection\COLLECTION_NAME // define: project/Assets/SpriteCollection/ "dropboxPath" => "DROPBOX_PATH", // the end of the Dropbox folder - optional, if there's no need leave it empty - "" // if we'll take the last example: c:\dropbox\project\Assets\SpriteCollection\COLLECTION_NAME Data\ // define: " Data/" "dropboxPathEnd" => "DROPBOX_PATH_END", // the name convension of the image // keep the same name convention to your atlases or change the script "imageName" => "IMAGE_NAME" ); /* * Here you will insert your folders names as they appear in the Dropbox folder * if you want insted to define image names change the script... * I use 2dToolkit so the name convention is Bla/Bla/{$Name} Data/atlas0.png * but you can change it as you like of course */ $name = array( "Folder1", "Folder2", "Folder3" // ... ); // do not change $warning = ""; $message = ""; $error = ""; // init Dropbox API $dropbox = new DropboxClient(array( 'app_key' => $config["dropboxAppKey"], 'app_secret' => $config["dropboxAppSecret"], 'app_full_access' => true, ), 'en'); $access_token = load_token("access"); if (!empty($access_token)) { $dropbox->SetAccessToken($access_token); } elseif (!empty($_GET['auth_callback'])) // are we coming from Dropbox's auth page? { // then load our previosly created request token $request_token = load_token($_GET['oauth_token']); if (empty($request_token)) die('Request token not found!'); // get & store access token, the request token is not needed anymore $access_token = $dropbox->GetAccessToken($request_token); store_token($access_token, "access"); delete_token($_GET['oauth_token']); } // checks if access token is required if (!$dropbox->IsAuthorized()) { // redirect user to Dropbox auth page $return_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . "?auth_callback=1"; $auth_url = $dropbox->BuildAuthorizeUrl($return_url); $request_token = $dropbox->GetRequestToken(); store_token($request_token, $request_token['t']); die("Authentication required. <a href='$auth_url'>Click here.</a>"); } // if the form submited if (isset($_POST["startProcess"])) { // if the password is correct if ($_POST['password'] == $config["password"] && $_POST['username'] == $config["username"]) { /* * Start the process */ // first make sure that all the folder exist for ($i = 0; $i < sizeof($name); $i++) { if ($_POST["folder" . $i] == "on") { try { $folder = $dropbox->GetMetadata($config["dropboxPath"] . $name[$i] . $config["dropboxPathEnd"]); } catch (Exception $e) { $error .= $e->getMessage() . "<br/>"; } } } if ($error == "") { // loop over the Folders for ($i = 0; $i < sizeof($name); $i++) { // if checkbox is on start process if ($_POST["folder" . $i] == "on") { $imageAlreadyCompressed = false; // display progress when loading... echo "<div class=\"process\">"; echo "<pre>"; echo "<img src=\"images/ajax-loader.gif\" border=\"0\" /> Process " . $name[$i] . "...\n"; echo "</pre>"; echo "</div>"; $message .= "<strong>" . $name[$i] . "</strong><br/>"; // check if folder images exist if (!file_exists("images")) { mkdir("images", 0777); $message .= "The directory: images, was successfully created.<br/>"; } // check if folder $name[$i] exist if (!file_exists("images/" . $name[$i])) { mkdir("images/" . $name[$i], 0777); $message .= "Created directory: " . $name[$i] . ", to store temp files.<br/>"; } // check if file size the same as the file on server... if (file_exists("images/" . $name[$i] . "/tempNew.png")) { $fileSizeServer = filesize("images/" . $name[$i] . "/tempNew.png"); $fileSizeDropbox = $dropbox->GetMetadata($config["dropboxPath"] . $name[$i] . $config["dropboxPathEnd"] . $config["imageName"] . ".png"); if ($fileSizeServer == $fileSizeDropbox->bytes) { $imageAlreadyCompressed= true; } } if (!$imageAlreadyCompressed) { $download = $dropbox->DownloadFile($config["dropboxPath"] . $name[$i] . $config["dropboxPathEnd"] . $config["imageName"] . ".png", "images/" . $name[$i] . "/tempOrg.png", 0); $message .= "Fetch the file: <br/>" . $download->path . "<br/>"; $message .= "The original file size: " . $download->size . "<br/>"; if (actionTiny($name[$i])) { $upload = $dropbox->UploadFile("images/" . $name[$i] . "/tempNew.png", $config["dropboxPath"] . $name[$i] . $config["dropboxPathEnd"] . $config["imageName"] . ".png"); $message .= "After compression file size: " . $upload->size . "<br/>"; // calculate compression rate if (strpos($download->size,'MB') !== false) { $sizeOrg = str_replace(" MB", "", $download->size); $sizeOrg = $sizeOrg / 0.0009765625; } else { $sizeOrg = str_replace(" KB", "", $download->size); } if (strpos($upload->size,'MB') !== false) { $sizeNew = str_replace(" MB", "", $upload->size); $sizeNew = $sizeNew / 0.0009765625; } else { $sizeNew = str_replace(" KB", "", $upload->size); } $sizeOrg = str_replace(" KB", "", $download->size); $sizeNew = str_replace(" KB", "", $upload->size); $compression = (100 - (((float)$sizeNew / (float)$sizeOrg) * 100)); $compression = number_format($compression, 2, '.', ''); $message .= "Compression ratio of: " . $compression . "%<br/>"; // dlete temp files if (unlink('images/' . $name[$i] . '/tempOrg.png')) { // unlink('images/' . $name[$i] . '/tempNew.png')) { $message .= "Delete original temp file...<br/><br/>"; } $message .= $name[$i] . " upadated at Dropbox!"; $message .= "<br/><hr/>"; } } else { $message .= $name[$i] . " Already compressed...<br/><br/>"; } } } } } else { $warning = "Username || Password Incorrect!"; } } function actionTiny($folderName) { global $config; global $message; require_once('lib/TinyPNG.php'); // define TinyPNG api key $api = new TinyPNG($config["tinyPNGApiKey"]); if ($api->shrink($_SERVER['DOCUMENT_ROOT'] . $config["serverPath"] . 'images/' . $folderName . '/tempOrg.png')) { $result = $api->getResultJson(); $outputPath = $result->output->url; $image = $_SERVER['DOCUMENT_ROOT'] . $config["serverPath"] . 'images/' . $folderName . '/tempNew.png'; if (file_put_contents($image, file_get_contents($outputPath))) { return true; } else { $message .= "Mmm...There was a problem WRITING the file<br/>"; return false; } } else { $message .= "Mmm...There was a problem to READING the file<br/>"; return false; } } function store_token($token, $name) { // create tokens folder if not exist if (!file_exists("tokens")) { mkdir("tokens", 0777); } if (!file_put_contents("tokens/$name.token", serialize($token))) die('<br />Could not store token! <b>Make sure that the directory `tokens` exists and is writable!</b>'); } function load_token($name) { if (!file_exists("tokens/$name.token")) return null; return @unserialize(@file_get_contents("tokens/$name.token")); } function delete_token($name) { @unlink("tokens/$name.token"); } ?>
11654e87effc9268750be8124d38b5aa99674ecc
{ "blob_id": "11654e87effc9268750be8124d38b5aa99674ecc", "branch_name": "refs/heads/master", "committer_date": "2014-04-10T20:00:27", "content_id": "660f779587fd9307a31cd28827e140a5f3cce3d7", "detected_licenses": [ "MIT" ], "directory_id": "1aad85ded5e2226929a57168fa8f8f2c812f3820", "extension": "php", "filename": "tinydrop.php", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 18633170, "is_generated": false, "is_vendor": false, "language": "PHP", "length_bytes": 9849, "license": "MIT", "license_type": "permissive", "path": "/tinydrop.php", "provenance": "stack-edu-0050.json.gz:691563", "repo_name": "EdoFrenkel/TinyDrop", "revision_date": "2014-04-10T20:00:27", "revision_id": "a1e3a3a38bd39b533734b959c3beb38066e47703", "snapshot_id": "3bf81498948d1f5b4e0d4750e90e2dd2fb6cefba", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/EdoFrenkel/TinyDrop/a1e3a3a38bd39b533734b959c3beb38066e47703/tinydrop.php", "visit_date": "2020-04-26T01:47:35.395664", "added": "2024-11-19T03:21:24.723680+00:00", "created": "2014-04-10T20:00:27", "int_score": 3, "score": 2.671875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0068.json.gz" }
#include <glib.h> #include <enlightenment/enlightenment.h> #include "../engine/imh/imh.h" static void _print_row(const ETable *table, ERow *row); static void _print_primary_key_value(gpointer primary_key_value, gpointer convert_func); static void _print_data_value(gpointer data_value, gpointer unused); /* * This code shows the basic usage of Enlightenment. * It uses a simple in-memory engine (like MEMORY or HEAP in MySQL). * * I wanted to keep this code as simple as possible, so it does not cover topics such as multithreading, parallel IO and sharding. * Please don't use this code in performance critical situations; the calls to EEngine are performing blocking IO! * * Here you can see rows being inserted into a Table and then being retrieved from it. * * The table we'll be creating has three columns: UserID (int64), UserDeaths (int16), UserScore (int16), with UserID being the only primary key. */ int main(E_UNUSED int argc, E_UNUSED gchar **argv) { g_autoptr(GError) error = NULL; g_autoptr(ETable) table = NULL; g_autoptr(GPtrArray) primary_columns = g_ptr_array_new(); g_autoptr(GPtrArray) data_columns = g_ptr_array_new(); g_autoptr(EPrimaryColumn) column_userid = NULL; g_autoptr(EDataColumn) column_userdeaths = NULL, column_userscore = NULL; const EEngine *engine = NULL; table = e_table_new(); column_userid = e_primary_column_new_s64("UserID"); column_userdeaths = e_data_column_new("UserDeaths", 16); column_userscore = e_data_column_new("UserScore", 16); g_ptr_array_add(primary_columns, column_userid); g_ptr_array_add(data_columns, column_userdeaths); g_ptr_array_add(data_columns, column_userscore); if (!e_table_init(table, "User", primary_columns, data_columns, &error)) { g_error("Error while initializing table: %s", error->message); } engine = e_imh_new(table, &error); if (!engine) { g_error("Error while initializing engine: %s", error->message); } // If you're not using autoptr, you can free the ERows and their // associated GPtrArrays and data after the row has been created by the engine. g_autoptr(ERow) row = NULL; g_autoptr(GPtrArray) primary_key_values = g_ptr_array_new(); g_autoptr(GPtrArray) data_values = g_ptr_array_new(); guint64 userId = 420; guint16 userDeaths = 6, userScore = 100; g_ptr_array_add(primary_key_values, &userId); g_ptr_array_add(data_values, &userDeaths); g_ptr_array_add(data_values, &userScore); row = e_row_new(primary_key_values, data_values); // Insert row with UserID=420, UserDeaths=6, UserScore=100 if (!engine->row_create_func(table, row, engine->func_data, &error)) { g_error("Error while creating a row: %s", error->message); } userId = 700; userDeaths = 1; userScore = 60; // Insert row with UserID=700, UserDeaths=1, UserScore=60 if (!engine->row_create_func(table, row, engine->func_data, &error)) { g_error("Error while creating a row: %s", error->message); } ERow **rows = NULL; if (!engine->row_list_func(table, &rows, engine->func_data, &error)) { g_error("Error while creating a row: %s", error->message); } for (int i = 0; rows[i]; i++) { _print_row(table, rows[i]); } return EXIT_SUCCESS; } static void _print_row(const ETable *table, ERow *row) { g_print("Row with %d primary key values and %d data values\n", row->primary_key_values->len, row->data_values->len); g_ptr_array_foreach(row->primary_key_values, _print_primary_key_value, g_ptr_array_index(e_table_get_primary_columns(table), 0)); g_ptr_array_foreach(row->data_values, _print_data_value, NULL); } static void _print_primary_key_value(gpointer primary_key_value, gpointer primary_column) { // TODO print actual key value met behulp van de convert functie in EPrimaryColumn EPrimaryColumn *column = E_PRIMARY_COLUMN(primary_column); g_print("Primary key value pointing to %p, actual value %lu\n", primary_key_value, *(guint64 *) column->revert_func((guint64) primary_key_value, column->revert_func_data)); } static void _print_data_value(gpointer data_value, E_UNUSED gpointer unused) { g_print("Data value pointing to %p, actual value %d\n", data_value, *(guint16 *)data_value); }
7a00240d25d11bc202eb7b8b990992c5c0c39f58
{ "blob_id": "7a00240d25d11bc202eb7b8b990992c5c0c39f58", "branch_name": "refs/heads/master", "committer_date": "2020-09-26T17:54:55", "content_id": "0936d854dd5256fc5696137ed89841dce13943a9", "detected_licenses": [ "BSD-2-Clause-Views" ], "directory_id": "c8b2aaa1dd6c7b9a520592ba1200b002d8eebf3c", "extension": "c", "filename": "example-2.c", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 286139176, "is_generated": false, "is_vendor": false, "language": "C", "length_bytes": 4755, "license": "BSD-2-Clause-Views", "license_type": "permissive", "path": "/example/example-2.c", "provenance": "stack-edu-0000.json.gz:441785", "repo_name": "hypothermic/enlightenment", "revision_date": "2020-09-26T17:54:55", "revision_id": "eae15838ca16e7f02213a1cf23cc30581ae2bfd6", "snapshot_id": "b08beede62126af31b03e0b842903d7e84cab55c", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/hypothermic/enlightenment/eae15838ca16e7f02213a1cf23cc30581ae2bfd6/example/example-2.c", "visit_date": "2022-12-17T03:49:35.762008", "added": "2024-11-18T20:48:36.801744+00:00", "created": "2020-09-26T17:54:55", "int_score": 3, "score": 2.765625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0018.json.gz" }
/* Package mcgoweb provides a micro web framework. Designed to be easily embeddedable in a go application and provide an easy and powerful to create both REST apis and management consoles. Example using middleware and a handler generator package main import ( "log" "github.com/dmcgowan/mcgoweb" ) func LogMiddleware(handler mcgoweb.RequestHandler, context *mcgoweb.RequestContext) { log.Println("Starting Request:", context.Request.URL.Path) handler(context) log.Println("Finished Request:", context.Request.URL.Path) } func TestHandler() *mcgoweb.Handler { handler := mcgoweb.NewHandler("/files/<filepath:path>", mcgoweb.HTTP_GET) handler.AddMiddleware(LogMiddleware) handler.RequestHandler = func(context *mcgoweb.RequestContext) { filepath,_ := context.RequestVars["filepath"] log.Printf("Getting file \"%s\"\n", filepath) // Do something fun and interesting here } return handler } func main() { app := mcgoweb.NewHTTPApplication("Sample App", "/", "0.0.0.0:7070") app.Register(TestHandler) app.Run() } */ package mcgoweb
83787bc22e0caa2f7fb122768edbc36835a612bc
{ "blob_id": "83787bc22e0caa2f7fb122768edbc36835a612bc", "branch_name": "refs/heads/master", "committer_date": "2012-07-23T07:43:43", "content_id": "8d5c21666a0dddeb548c4e26037ede9472f90805", "detected_licenses": [ "MIT" ], "directory_id": "f9bf496ffe17263845fb61a6dfe65a456fedae1c", "extension": "go", "filename": "doc.go", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 4605292, "is_generated": false, "is_vendor": false, "language": "Go", "length_bytes": 1084, "license": "MIT", "license_type": "permissive", "path": "/doc.go", "provenance": "stack-edu-0018.json.gz:513642", "repo_name": "dmcgowan/mcgoweb", "revision_date": "2012-07-23T07:43:43", "revision_id": "a003a1543971a7cae13f821dce1aec5dc02a0cb9", "snapshot_id": "18126f954cc3dee41cf734e408dfa3ebd9df1ff1", "src_encoding": "UTF-8", "star_events_count": 1, "url": "https://raw.githubusercontent.com/dmcgowan/mcgoweb/a003a1543971a7cae13f821dce1aec5dc02a0cb9/doc.go", "visit_date": "2021-01-22T06:49:42.117896", "added": "2024-11-18T19:51:13.686491+00:00", "created": "2012-07-23T07:43:43", "int_score": 3, "score": 2.703125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0036.json.gz" }
function() { clearTimeout(timer); start(); equal(get(wycats, 'isLoaded'), true, "subsequent requests for records are returned asynchronously"); equal(get(wycats, 'height'), 65, "subsequent requested records contain correct information"); }
923b9f116de7bc571040e871fac4d7430cc867c5
{ "blob_id": "923b9f116de7bc571040e871fac4d7430cc867c5", "branch_name": "refs/heads/main", "committer_date": "2022-10-18T10:08:50", "content_id": "51b5ce8c73fe1f4697ebcb621c41458ba6784f60", "detected_licenses": [ "MIT" ], "directory_id": "1a1e21c86d26e545d911a3948b66fe7baeb3bdbb", "extension": "js", "filename": "737c8f77801057b30b150d7f08e82c312ff5f53e_1_1.js", "fork_events_count": 0, "gha_created_at": null, "gha_event_created_at": null, "gha_language": null, "gha_license_id": null, "github_id": 448797879, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 268, "license": "MIT", "license_type": "permissive", "path": "/input/50-100/after/737c8f77801057b30b150d7f08e82c312ff5f53e_1_1.js", "provenance": "stack-edu-0037.json.gz:192325", "repo_name": "AAI-USZ/FixJS", "revision_date": "2022-10-18T10:08:50", "revision_id": "0f7b4a2445340e147fdb7aef00fbe6230397501f", "snapshot_id": "59db2b15d78e3eaadc72f7f046908e0ee0d4e0fc", "src_encoding": "UTF-8", "star_events_count": 2, "url": "https://raw.githubusercontent.com/AAI-USZ/FixJS/0f7b4a2445340e147fdb7aef00fbe6230397501f/input/50-100/after/737c8f77801057b30b150d7f08e82c312ff5f53e_1_1.js", "visit_date": "2023-04-17T15:26:29.043233", "added": "2024-11-18T23:11:45.735825+00:00", "created": "2022-10-18T10:08:50", "int_score": 2, "score": 2.234375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0055.json.gz" }
/* * @Author: whyour * @Github: https://github.com/whyour * @Date: 2020-11-23 11:30:44 * @LastEditors: whyour * @LastEditTime: 2020-11-30 13:18:48 quanx: [task_local] 0 18 * * * https://raw.githubusercontent.com/whyour/hundun/master/quanx/donate-step.js, tag=捐步数, enabled=true loon: [Script] cron "0 18 * * *" script-path=https://raw.githubusercontent.com/whyour/hundun/master/quanx/donate-step.js, tag=捐步数 surge: [Script] 捐步数 = type=cron,cronexp=0 18 * * *,timeout=60,script-path=https://raw.githubusercontent.com/whyour/hundun/master/quanx/donate-step.js, * **/ const $ = new compatibility(); const donate = "alipays://platformapi/startapp?appId=10000009&url=/www/stepDonate.htm?chInfo=antsports&sourceName=antsports"; $.notify("支付宝", "", "捐步数啦", donate); $done(); function compatibility() { _isQuanX = typeof $task != "undefined"; _isLoon = typeof $loon != "undefined"; _isSurge = typeof $httpClient != "undefined" && !_isLoon; this.read = (key) => { if (_isQuanX) return $prefs.valueForKey(key); if (_isLoon) return $persistentStore.read(key); }; this.notify = (title, subtitle, message, url) => { if (_isLoon) $notification.post(title, subtitle, message, url); if (_isQuanX) $notify(title, subtitle, message, { "open-url": url }); if (_isSurge) $notification.post(title, subtitle, message, { url: url }); }; }
fe17f79200991e89d7f45d459248df63bb298f96
{ "blob_id": "fe17f79200991e89d7f45d459248df63bb298f96", "branch_name": "refs/heads/master", "committer_date": "2021-03-28T10:16:08", "content_id": "d958c84f785eadf4a8c607e99c845810dda4977b", "detected_licenses": [ "MIT" ], "directory_id": "68b4821baaaff734bfad3731dbc4a379017cf6d8", "extension": "js", "filename": "donate-step.js", "fork_events_count": 0, "gha_created_at": "2021-02-20T16:40:44", "gha_event_created_at": "2021-03-13T11:13:24", "gha_language": "JavaScript", "gha_license_id": "MIT", "github_id": 340702207, "is_generated": false, "is_vendor": false, "language": "JavaScript", "length_bytes": 1418, "license": "MIT", "license_type": "permissive", "path": "/quanx/donate-step.js", "provenance": "stack-edu-0038.json.gz:533081", "repo_name": "MyGhost233/hundun", "revision_date": "2021-03-28T10:16:08", "revision_id": "902054f86c6a66d4edb61898e0c357ae94f178ab", "snapshot_id": "799e293d0f0a147aa84236c339cfe8404c943d8b", "src_encoding": "UTF-8", "star_events_count": 13, "url": "https://raw.githubusercontent.com/MyGhost233/hundun/902054f86c6a66d4edb61898e0c357ae94f178ab/quanx/donate-step.js", "visit_date": "2023-04-03T15:52:50.787602", "added": "2024-11-18T22:47:08.514088+00:00", "created": "2021-03-28T10:16:08", "int_score": 2, "score": 2.09375, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0056.json.gz" }
Extension to PostgreSQL 9.5 for Zenhub Charts ============================================= This image is an extension to the official _postgres_ image which creates an empty database at first boot for Zenhub Charts. ## Prerequisites * [Docker](https://www.docker.com/) v1.5.0 or up * Internet access * A Unix shell (Cygwin might work but is not tested) ## Building the image The image is built as part of `docker-compose up` in the project root. Extending the PostgreSQL image is described in the section [How to extend this image](https://registry.hub.docker.com/_/postgres/) of the PostgreSQL Docker Hub page.
5baa036d7dc7a9ef3dbf3a5c3ab36ab81492ecb6
{ "blob_id": "5baa036d7dc7a9ef3dbf3a5c3ab36ab81492ecb6", "branch_name": "refs/heads/master", "committer_date": "2020-03-01T21:59:57", "content_id": "7540b1dd9817a455a68c7556a70e9f94c595cccd", "detected_licenses": [ "MIT" ], "directory_id": "103256d78a84b597429065e7b1e1000ba22317d6", "extension": "md", "filename": "README.md", "fork_events_count": 0, "gha_created_at": "2020-03-01T19:14:05", "gha_event_created_at": "2020-03-01T19:14:06", "gha_language": null, "gha_license_id": "MIT", "github_id": 244208408, "is_generated": false, "is_vendor": false, "language": "Markdown", "length_bytes": 620, "license": "MIT", "license_type": "permissive", "path": "/zenhub_metrics/db/README.md", "provenance": "stack-edu-markdown-0007.json.gz:267547", "repo_name": "seizadi/docker-images", "revision_date": "2020-03-01T21:59:57", "revision_id": "9204af313e63444d0c9766a9860ad1c47a9afde5", "snapshot_id": "b283437c31c6618a07bcea003ade8129ecf767a0", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/seizadi/docker-images/9204af313e63444d0c9766a9860ad1c47a9afde5/zenhub_metrics/db/README.md", "visit_date": "2021-02-08T23:10:45.731541", "added": "2024-11-18T21:51:06.085123+00:00", "created": "2020-03-01T21:59:57", "int_score": 3, "score": 2.96875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0007.json.gz" }
package nl.nl2312.rxcupboard2; import io.reactivex.functions.Consumer; public abstract class OnDatabaseChange<T> implements Consumer<DatabaseChange<T>> { public void onUpdate(T entity) {} public void onInsert(T entity) {} public void onDelete(T entity) {} @Override public void accept(DatabaseChange<T> databaseChange) throws Exception { if (databaseChange instanceof DatabaseChange.DatabaseUpdate) { onUpdate(databaseChange.entity()); } else if (databaseChange instanceof DatabaseChange.DatabaseInsert) { onInsert(databaseChange.entity()); } else if (databaseChange instanceof DatabaseChange.DatabaseDelete) { onDelete(databaseChange.entity()); } } }
49d4dc129f8d1bdc989b75f70cd708aa8fafa922
{ "blob_id": "49d4dc129f8d1bdc989b75f70cd708aa8fafa922", "branch_name": "refs/heads/master", "committer_date": "2017-01-12T21:08:48", "content_id": "542696fd8a2f406f531e890be2b5f7a6a3db74e9", "detected_licenses": [ "Apache-2.0" ], "directory_id": "e3432aa7ee1f9633543ef0dddb6dad7c954d1c03", "extension": "java", "filename": "OnDatabaseChange.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": 751, "license": "Apache-2.0", "license_type": "permissive", "path": "/library/src/main/java/nl/nl2312/rxcupboard2/OnDatabaseChange.java", "provenance": "stack-edu-0020.json.gz:175734", "repo_name": "wangtaoahu/erickok-RxCupboard", "revision_date": "2017-01-12T21:08:48", "revision_id": "2c75d880d7aae6d7b86538345b9daa3e438697e8", "snapshot_id": "f8e69826ada57e1db0fcd1b366afd6095e1233a5", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/wangtaoahu/erickok-RxCupboard/2c75d880d7aae6d7b86538345b9daa3e438697e8/library/src/main/java/nl/nl2312/rxcupboard2/OnDatabaseChange.java", "visit_date": "2018-02-08T08:16:43.956358", "added": "2024-11-18T20:54:36.714319+00:00", "created": "2017-01-12T21:08:48", "int_score": 3, "score": 2.546875, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0038.json.gz" }
import numpy as np import cv2 as cv img = {} img['orig'] = cv.imread('lion.jpg', cv.IMREAD_COLOR) height, width, channels = img['orig'].shape img_lower_x2 = cv.resize(img['orig'], (width // 2 + width % 2, height // 2 + height % 2), interpolation=cv.INTER_AREA) img_lower_x4 = cv.resize(img['orig'], None, fx=0.25, fy=0.25, interpolation=cv.INTER_AREA) kernel = np.ones((5, 5), np.float32) / 25 kernel_clear = np.ones((3, 3), np.float32) * (-1) kernel_clear[1, 1]=9; img['canny'] = cv.Canny(img_lower_x2, 100, 200) img['canny'] = cv.cvtColor(img['canny'], cv.COLOR_GRAY2BGR) img['avg'] = cv.filter2D(img_lower_x4, -1, kernel) #cv.blur(img, (5, 5)) img['gauss'] = cv.GaussianBlur(img_lower_x4, (5,5), 0) img['clear'] = cv.filter2D(img_lower_x4, -1, kernel_clear) img['rand'] = np.random.randint(255, size=img_lower_x4.shape, dtype=np.uint8) half_height = height // 2 + height % 2 quarter_height = height // 4 quarter_width = width // 4 res = np.zeros((height, width + width // 2, channels), dtype=np.uint8) res[0:height, 0:width] = img['orig'] res[0:half_height, width:] = img['canny'] res[half_height:half_height + quarter_height, width:width + quarter_width] = img['avg'] res[half_height:half_height + quarter_height, width + quarter_width:] = img['gauss'] res[half_height + quarter_height:, width:width + quarter_width] = img['clear'] res[half_height + quarter_height:, width + quarter_width:] = img['rand'] cv.imwrite('result.jpg', res)
d1a3bfb7935421a240900489fc1482fd3877ebc8
{ "blob_id": "d1a3bfb7935421a240900489fc1482fd3877ebc8", "branch_name": "refs/heads/master", "committer_date": "2020-09-10T18:03:12", "content_id": "fa9d6220bee99676048deab30b49d1f936de6241", "detected_licenses": [ "Apache-2.0" ], "directory_id": "f40bb2d14e4f8a8b8bc3d4175934bae56aca5726", "extension": "py", "filename": "image_transformer.py", "fork_events_count": 0, "gha_created_at": "2020-03-15T21:30:18", "gha_event_created_at": "2020-04-21T12:08:39", "gha_language": "Jupyter Notebook", "gha_license_id": "Apache-2.0", "github_id": 247555011, "is_generated": false, "is_vendor": false, "language": "Python", "length_bytes": 1449, "license": "Apache-2.0", "license_type": "permissive", "path": "/assignment_3/image_transformer/image_transformer.py", "provenance": "stack-edu-0064.json.gz:205340", "repo_name": "KanashinDmitry/python_basic_programming", "revision_date": "2020-09-10T18:03:12", "revision_id": "72f6bb6cfb8f905857acec59cc13a20f3c18dabf", "snapshot_id": "67aa468574b1575caacd4764107809381cd13f3b", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/KanashinDmitry/python_basic_programming/72f6bb6cfb8f905857acec59cc13a20f3c18dabf/assignment_3/image_transformer/image_transformer.py", "visit_date": "2021-03-24T18:00:47.083635", "added": "2024-11-18T21:33:36.471929+00:00", "created": "2020-09-10T18:03:12", "int_score": 3, "score": 2.625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0082.json.gz" }
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; /** * functions.php * * Author : metheno * Date : 2017/02/11 * Version : * Description: */ require_once("lib/PluginCheck.php"); require_once("lib/PostRenderer.php"); require_once("lib/UACheck.php"); function themeConfig($form) { $enableMathJax = new Typecho_Widget_Helper_Form_Element_Radio('enableMathJax', array('1' => _t('开启'), '0' => _t('关闭')), '0', _t('MathJax 支持'), _t('默认为关闭。<br/>单行:<code>$...$</code>;<br/>多行:<code>$$...$$</code>。')); $form->addInput($enableMathJax); $donateQRLink = new Typecho_Widget_Helper_Form_Element_Text('donateQRLink', NULL, NULL, _t('赞赏二维码'), _t('在文章页内插入一个用于打赏的二维码。')); $form->addInput($donateQRLink); $beianNumber = new Typecho_Widget_Helper_Form_Element_Text('beianNumber', NULL, NULL, _t('备案号'), _t('如果已经备案,请填写备案号。')); $form->addInput($beianNumber); $additionalJS = new Typecho_Widget_Helper_Form_Element_Textarea('additionalJS', NULL, NULL, _t('JS 代码'), _t('填写其他 JS 代码。不需要加 <code>script</code> 标签。')); $form->addInput($additionalJS); } function prev_post($archive) { $db = Typecho_Db::get(); $content = $db->fetchRow($db->select() ->from('table.contents') ->where('table.contents.created < ?', $archive->created) ->where('table.contents.status = ?', 'publish') ->where('table.contents.type = ?', $archive->type) ->where('table.contents.password IS NULL') ->order('table.contents.created', Typecho_Db::SORT_DESC) ->limit(1)); if ($content) { $content = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($content); echo '<a class="prev" href="' . $content['permalink'] . '" rel="prev"><span>上一篇</span><br/>' . $content['title'] . '</a>'; } else { echo "<a class=\"prev\"><span>\xf0\x9F\x98\xb6</span><br/>没有更多了</a>"; } } function next_post($archive) { $db = Typecho_Db::get(); $content = $db->fetchRow($db->select() ->from('table.contents') ->where('table.contents.created > ? AND table.contents.created < ?', $archive->created, Helper::options()->gmtTime) ->where('table.contents.status = ?', 'publish') ->where('table.contents.type = ?', $archive->type) ->where('table.contents.password IS NULL') ->order('table.contents.created', Typecho_Db::SORT_ASC) ->limit(1)); if ($content) { $content = Typecho_Widget::widget('Widget_Abstract_Contents')->filter($content); echo '<a class="next" href="' . $content['permalink'] . '" rel="next"><span>下一篇</span><br/>' . $content['title'] . '</a>'; } else { echo "<a class=\"next\"><span>\xf0\x9F\x98\xb6</span><br/>没有更多了</a>"; } }
b7d006f36751684fd784fa8185e9dd4d41921d68
{ "blob_id": "b7d006f36751684fd784fa8185e9dd4d41921d68", "branch_name": "refs/heads/master", "committer_date": "2020-07-03T12:51:29", "content_id": "cd2a43d08243ad242daba47d3eb3c179eaa4e4dd", "detected_licenses": [ "Apache-2.0" ], "directory_id": "8748a292aa875e0bcb19b11a1274fd76c7f57763", "extension": "php", "filename": "functions.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": 3291, "license": "Apache-2.0", "license_type": "permissive", "path": "/functions.php", "provenance": "stack-edu-0051.json.gz:88982", "repo_name": "doswo/kibou_lite", "revision_date": "2020-07-03T12:51:29", "revision_id": "bec08ed9e0e3654dd72a18779850930db262d345", "snapshot_id": "6f96b11c58a33c5a3c1aedc4ac5bf216bdcb7832", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/doswo/kibou_lite/bec08ed9e0e3654dd72a18779850930db262d345/functions.php", "visit_date": "2022-11-12T17:51:25.854127", "added": "2024-11-18T23:10:15.581241+00:00", "created": "2020-07-03T12:51:29", "int_score": 2, "score": 2.265625, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0069.json.gz" }
package model import ( "time" ) type Workflow struct { ID uint `gorm:"primary_key" json:"id"` Name string `gorm:"not null" json:"name"` Definition string `gorm:"type:json;not null" json:"definition"` User *User `gorm:"not null" json:"user"` UserID uint `gorm:"not null" json:"-"` CreatedAt *time.Time `json:"-"` UpdatedAt *time.Time `json:"-"` jobDef *JobDef `gorm:"-"` } func (workflow *Workflow) GetJobDef() *JobDef { if workflow.jobDef != nil { return workflow.jobDef } workflow.jobDef = GetJobDefFromString(workflow.Definition) return workflow.jobDef }
6fc149d5778a7bf2b077096c2042ca15d007a06f
{ "blob_id": "6fc149d5778a7bf2b077096c2042ca15d007a06f", "branch_name": "refs/heads/master", "committer_date": "2019-09-04T16:32:55", "content_id": "01f41166655814136b764554235c9b6c74e632b7", "detected_licenses": [ "Apache-2.0" ], "directory_id": "97f446ee68f1367e7ebbc2b08197fd75773ae615", "extension": "go", "filename": "workflow.go", "fork_events_count": 0, "gha_created_at": "2017-12-04T07:00:02", "gha_event_created_at": "2019-11-01T13:26:45", "gha_language": "Go", "gha_license_id": "Apache-2.0", "github_id": 113007071, "is_generated": false, "is_vendor": false, "language": "Go", "length_bytes": 628, "license": "Apache-2.0", "license_type": "permissive", "path": "/model/workflow.go", "provenance": "stack-edu-0018.json.gz:656", "repo_name": "Attsun1031/jobnetes", "revision_date": "2019-09-04T16:32:55", "revision_id": "0de2bea9439739ebbf47b3c31eddba49c3cb4aa3", "snapshot_id": "02a1333cbc411ff135cbb935a81894bc4c5f9cf1", "src_encoding": "UTF-8", "star_events_count": 0, "url": "https://raw.githubusercontent.com/Attsun1031/jobnetes/0de2bea9439739ebbf47b3c31eddba49c3cb4aa3/model/workflow.go", "visit_date": "2021-05-06T11:56:57.250701", "added": "2024-11-18T18:49:26.871109+00:00", "created": "2019-09-04T16:32:55", "int_score": 2, "score": 2.203125, "source": "stackv2", "file_path": "/project/aip-craffel/gsa/data/stack_edu/stack-edu-0036.json.gz" }