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 convert(char): | |
return { | |
'M': 1000, | |
'D': 500, | |
'C': 100, | |
'L': 50, | |
'X': 10, | |
'V': 5, | |
'I': 1 | |
}.get(char) |
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 Cocoa | |
func mergeSort(_ array: [Int]) -> [Int] { | |
guard array.count > 1 else { return array } | |
let middleIndex = array.count / 2 | |
let leftArray = mergeSort(Array(array[0..<middleIndex])) | |
let rightArray = mergeSort(Array(array[middleIndex..<array.count])) | |
return merge(leftPile: leftArray, rightPile: rightArray) | |
} |
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
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-31-generic x86_64) | |
* Documentation: https://help.ubuntu.com | |
* Management: https://landscape.canonical.com | |
* Support: https://ubuntu.com/advantage | |
100 packages can be updated. | |
47 updates are security updates. | |
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
function foo() { | |
function boom() { | |
Write('Boom'); | |
}; | |
function bar () { | |
function baz() { | |
boom(); // Fails here, "boom" can't be found | |
}; |
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
function newEnv () { | |
function Foo () { | |
Write('Hello World'); | |
}; | |
var f = { | |
Foo: Foo | |
} | |
return f; |
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
Platform.Load('Core', '1.0'); | |
function moo (foo, bar) {}; | |
Write(moo.length); // You'll get a .NET error if you do this, weirdly enough. |
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
define('foo', function () { | |
function Foo () { | |
Write('Hello World'); | |
}; | |
return Foo; | |
}) | |
require(['foo'], function (Foo) { | |
// Foo is undefined on Salesforce |
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
// There is no String.substr on Salesforce. This uses String.substring instead. | |
// substring's arguments are different, so this just converts substr args to | |
// their substring equivalents. | |
function substrShim (str, start, len) { | |
if (len <= 0) | |
return ''; | |
if (start < 0) | |
start = str.length + start; |
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
#!/usr/bin/env bash | |
seq 1 100 | \ | |
xargs -Ix -n1 echo "x + ((x % 3 == 0) + ((x % 5) == 0) * 2) * 1000" | \ | |
bc | \ | |
xargs -n1 printf "%04d\n" | \ | |
sed 's/^1.*/Fizz/' | \ | |
sed 's/^2.*/Buzz/' | \ | |
sed 's/^3.*/FizzBuzz/' | \ | |
sed 's/^0*//' |
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
#!/usr/bin/env bash | |
# Where input.txt is: | |
# a>b | |
# b>c | |
# c>d | |
# d>e | |
paste -d '>' <(< input.txt | cut -d'>' -f2 | tac) <(< input.txt | cut -d'>' -f1 | tac) |