This file contains 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 insertionSort(list) { | |
for (var g = 0; g < list.length; g++) { | |
for (var i = list.length - 1; i > g; i--) { | |
if (list[i] < list[i - 1]) { | |
var tmp = list[i]; | |
list[i] = list[i - 1]; | |
list[i - 1] = tmp; | |
} | |
} | |
} |
This file contains 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
/** | |
* Soundex in JavaScript | |
* | |
* @example | |
* // returns 'H416' | |
* soundex('Heilbronn'); | |
* | |
* @example | |
* // returns 'L222' | |
* soundex('Lissajous'); |
This file contains 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 bubbleSort(array) { | |
var swapped; | |
for (var i = 0; i < array.length - 1; i++) { | |
if (array[i] > array[i + 1]) { | |
var tmp = array[i + 1]; | |
array[i + 1] = array[i]; | |
array[i] = tmp; | |
swapped = true; | |
} |
This file contains 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
/** | |
* Longest Common Substring in JavaScript | |
* | |
* This is the brute-force solution. | |
* | |
* @param {String} s1 | |
* @param {String} s2 | |
* @return {String} r1 | |
*/ |
This file contains 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
/** | |
* @author Vidul Nikolaev Petrov | |
* @summary helper methods for PKI / AES usage, based on the JS Forge crypto library. | |
*/ | |
function s8Crypto(bits) { | |
var hexToBytes = forge.util.hexToBytes, | |
bytesToHex = forge.util.bytesToHex; | |
this.pki = {}; |
This file contains 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
[alias] | |
# add task | |
a = "!f() { \ | |
if [[ -f .dummy ]]; then \ | |
git rm -f .dummy; \ | |
else \ | |
touch .dummy; \ | |
git add .dummy; \ | |
fi; \ |
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script> | |
/* | |
CryptoJS v3.1.2 | |
code.google.com/p/crypto-js | |
(c) 2009-2013 by Jeff Mott. All rights reserved. | |
code.google.com/p/crypto-js/wiki/License |
This file contains 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 checkBalance(s) { | |
if (s.length % 2 !== 0) return false; | |
if (s.length === 0) return true; | |
var pairs = ['[]', '()', '{}'], | |
r0 = s.split(pairs[0]), | |
r1 = s.split(pairs[1]), | |
r2 = s.split(pairs[2]); |
This file contains 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 string = 'string', | |
stringIndex = function () { | |
string[0]; | |
}, | |
stringSlice = function () { | |
string.slice(0, 1); | |
}, | |
stringSubstring = function () { | |
string.substring(0, 1); | |
}; |
This file contains 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
#include <stdio.h> | |
/* | |
The conversion from `int` to `char` in this sequence is not to guaranteed to work on all systems. | |
See more in the comments of the accepted answer: http://stackoverflow.com/questions/21196926 | |
*/ | |
int main() { | |
int i; | |
int e = 0; | |
char numbers[11]; | |
char alpha_capital[27]; |