Skip to content

Instantly share code, notes, and snippets.

Tyler Austin tyler-austin

  • Amazon Web Services
  • Virginia
Block or report user

Report or block tyler-austin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tyler-austin
tyler-austin / numberOfCharInString.js
Created Mar 25, 2019
[JavaScript] Number of Occurances of a Character in a String
View numberOfCharInString.js
const numberOfCharInString = (c, s) => {
let [count, index] = [0, 0];
while (true) {
index = s.indexOf(c, index);
if (index >= 0) {
++count;
++index;
} else break;
}
return count;
@tyler-austin
tyler-austin / JSZip-images.js
Last active Aug 30, 2018
JSZip Open image files
View JSZip-images.js
// https://github.com/Stuk/jszip/issues/399
JSZip.loadAsync(data).then(function (zip) {
var re = /(.jpg|.png|.gif|.ps|.jpeg)$/;
var promises = Object.keys(zip.files).filter(function (fileName) {
// don't consider non image files
return re.test(fileName.toLowerCase());
}).map(function (fileName) {
var file = zip.files[fileName];
return file.async("blob").then(function (blob) {
View cSharp.py
# https://www.tutorialspoint.com/csharp/index.htm
# https://www.dotnetperls.com/
@tyler-austin
tyler-austin / grass-viewshed.py
Last active Apr 14, 2018
Grass Viewshed calculation
View grass-viewshed.py
import grass.script as grass
grass.run_command('r.viewshed',
input='standard.dem',
output='viewshed',
coordinate=[observer_x, observer_y],
obs_elev=1.75,
tgt_elev=0.0,
memory=4098,
overwrite=True,
View previous-next-extent.html
<!DOCTYPE html>
<html>
<head>
<title>Previous/Next Extent</title>
<meta charset="utf-8">
<link rel="stylesheet" href="//js.arcgis.com/3.21/esri/css/esri.css">
<style>
html, body {
margin: 0; padding: 0;
width: 100%; height: 100%;
@tyler-austin
tyler-austin / README.md
Created Jun 21, 2017
Code Fights - differentSymbolsNaive
View README.md

Given a string, find the number of different characters in it.

Example

For s = "cabca", the output should be
differentSymbolsNaive(s) = 3.

There are 3 different characters a, b and c.

Input/Output

@tyler-austin
tyler-austin / README.md
Created Jun 21, 2017
Code Fights - firstDigit
View README.md

Find the leftmost digit that occurs in a given string.

Example

  • For inputString = "var_1__Int", the output should be
    firstDigit(inputString) = '1';
  • For inputString = "q2q-q", the output should be
    firstDigit(inputString) = '2';
  • For inputString = "0ss", the output should be
    firstDigit(inputString) = '0'.
@tyler-austin
tyler-austin / README.md
Created Jun 21, 2017
Code Fights - extractEachKth
View README.md

Given array of integers, remove each kth element from it.

Example

For inputArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and k = 3, the output should be
extractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10].

Input/Output

  • [time limit] 4000ms (py3)
@tyler-austin
tyler-austin / README.md
Created Jun 21, 2017
Code Fights - stringsRearrangement
View README.md

Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character.

Example

  • For inputArray = ["aba", "bbb", "bab"], the output should be
    stringsRearrangement(inputArray) = false;

    All rearrangements don't satisfy the description condition.

  • For inputArray = ["ab", "bb", "aa"], the output should be

@tyler-austin
tyler-austin / README.md
Created Jun 19, 2017
Code Fights - absoluteValuesSumMinimization
View README.md

Given a sorted array of integers a, find such an integer x that the value of

abs(a[0] - x) + abs(a[1] - x) + ... + abs(a[a.length - 1] - x)

is the smallest possible (here abs denotes the absolute value). If there are several possible answers, output the smallest one.

Example

For a = [2, 4, 7], the output should be

You can’t perform that action at this time.