This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mainFunction = function(callback) { | |
| //Did something | |
| console.log("In Main Function"); | |
| callback(); | |
| } | |
| var callbackFunction = function() { | |
| console.log('Variable: ' + this.variable); | |
| console.log("In Callback Function"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mysql = require('mysql'); | |
| var con = mysql.createConnection({ | |
| host: "localhost", | |
| user: "root", | |
| password: "root", | |
| database: "Employee" | |
| }); | |
| con.connect(function (err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const cassandra = require('cassandra-driver'); | |
| const client = new cassandra.Client({contactPoints: ['127.0.0.1'], keyspace: 'movie_lens'}); | |
| const bignum = require('bignum'); | |
| //Finding minimum and maximum token range in a Cassandra table | |
| client.execute('select MIN(token(movie_id)), MAX(token(movie_id)) from movies;', | |
| function(err, result) { | |
| let minToken = result.rows[0]['system.min(system.token(movie_id))']; | |
| let maxToken = result.rows[0]['system.max(system.token(movie_id))']; | |
| console.log("Minimum token: " + minToken); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gym | |
| env = gym.make('CartPole-v1') | |
| env.reset() | |
| for step_index in range(1000): | |
| env.render() | |
| action = env.action_space.sample() | |
| observation, reward, done, info = env.step(action) | |
| print("Step {}:".format(step_index)) | |
| print("action: {}".format(action)) | |
| print("observation: {}".format(observation)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def model_data_preparation(): | |
| training_data = [] | |
| accepted_scores = [] | |
| for game_index in range(intial_games): | |
| score = 0 | |
| game_memory = [] | |
| previous_observation = [] | |
| for step_index in range(goal_steps): | |
| action = random.randrange(0, 2) | |
| observation, reward, done, info = env.step(action) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scores = [] | |
| choices = [] | |
| for each_game in range(100): | |
| score = 0 | |
| prev_obs = [] | |
| for step_index in range(goal_steps): | |
| env.render() | |
| if len(prev_obs)==0: | |
| action = random.randrange(0,2) | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def model_data_preparation(): | |
| training_data = [] | |
| accepted_scores = [] | |
| for game_index in range(intial_games): | |
| score = 0 | |
| game_memory = [] | |
| previous_observation = [] | |
| for step_index in range(goal_steps): | |
| action = random.randrange(0, 3) | |
| observation, reward, done, info = env.step(action) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const readline = require('readline'); | |
| const redisClient = require('redis').createClient(); | |
| const userInteractor = readline.createInterface({ | |
| input: process.stdin, | |
| output: process.stdout | |
| }); | |
| var initiateUserInteraction = async function() { | |
| while(true) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const async = require('async'); | |
| var processQueue = function (message, callback) { | |
| setTimeout(function() { | |
| console.log(`Task ${message} completed`); | |
| callback(); | |
| }, 500); | |
| } | |
| var queue = async.queue(processQueue, 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const async = require('async'); | |
| //Code for processing the task | |
| var processQueue = function (message, callback) { | |
| setTimeout(function() { | |
| console.log(`Task ${message} completed`); | |
| callback(); | |
| }, 500); | |
| } |