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
from pyspark.sql import SparkSession | |
# The important thing that seems to be often omitted in the docs is the | |
# spark.jars.packages option. | |
# Be sure to change the value to reflect your particular version of the spark-mongo connector you are using | |
spark = SparkSession \ | |
.builder \ | |
.appName("pysparktestapp") \ | |
.config("spark.mongodb.input.uri", "mongodb://127.0.0.1/<database>.<collection>") \ |
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
namespace DisconnectAsyncTaskExtension | |
{ | |
static class DisconnectAsyncTaskExtension | |
{ | |
public static Task<SocketAsyncEventArgs> DisconnectAsyncTask(this Socket that, SocketAsyncEventArgs disconnectArgs) | |
{ | |
TaskCompletionSource<SocketAsyncEventArgs> tcs = new TaskCompletionSource<SocketAsyncEventArgs>(); | |
disconnectArgs.Completed += (object sender, SocketAsyncEventArgs completedArgs) => { | |
try |
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 { readFileSync } from 'fs'; | |
const expenses = readFileSync('input.txt').toString('utf8').split('\n').map(n => parseInt(n)); | |
const threeNumberSumIndices = (numbers: number[], targetSum: number) : [number, number, number] | null=> { | |
let first, second, third; | |
for (let i = 0; i < numbers.length; i++) { | |
first = numbers[i]; | |
for (let j = i + 1; j < numbers.length; j++) { | |
second = numbers[j]; |
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 { readFileSync } from 'fs'; | |
type PasswordPolicy = { | |
[key: string]: any | |
} | |
type OcurrencePasswordPolicy = { | |
[key: string]: { min: number, max: number } | |
} | |
type PositionPasswordPolicy = { | |
[key: string]: number[] |
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 { readFileSync } from 'fs'; | |
const map = readFileSync('input.txt').toString('utf8').split('\n'); | |
const patternWidth = map[0].length; | |
const countTreesInSlope = (right: number, down: number) => { | |
let totalTrees = 0; | |
let y= 0; | |
for (let x = 0; x < map.length; x = x + down) { | |
const line = map[x]; |
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 { readFileSync } from 'fs'; | |
import * as jf from 'joiful'; | |
class Passport { | |
@jf.string().required() | |
public byr = ''; | |
@jf.string().required() | |
public iyr = ''; | |
@jf.string().required() | |
public eyr = ''; |
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 { readFileSync } from 'fs'; | |
const findRowNumber = (address: string, lowerBoundary: number, upperBoundary: number): number => { | |
if (!address.length) { | |
return lowerBoundary; | |
} | |
const remainingAddress = address.slice(1); | |
const distance = ((upperBoundary - lowerBoundary) / 2); | |
if (address[0] === 'F' || address[0] === 'L') { |