Skip to content

Instantly share code, notes, and snippets.

const $new_object$ = $array$.reduce(($accumulator$, $current_value$) => {
$END$
return $accumulator$;
}, $initial_value$);
@xthecapx
xthecapx / .alias.sh
Last active November 19, 2018 21:16
# ----------------------
# Git Aliases
# ----------------------
alias g='git'
alias ga='git add'
alias gaa='git add .'
alias gaaa='git add --all'
alias gau='git add --update'
alias gb='git branch'
alias gbd='git branch --delete '
export PROMPT_COMMAND=
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PURPLE="\[\033[0;35m\]"
export PS1="\[\033[38;5;6m\][\w]\[$(tput sgr0)\]\[\033[38;5;15m\]\\$\[$(tput sgr0)\]\[\033[38;5;6m\]:\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\] $GREEN\$(parse_git_branch)\n $NO_COLOUR"
function parse_git_branch () {
@xthecapx
xthecapx / countingValleys.js
Last active March 2, 2019 16:18
Hackerrank: Counting Valleys
function countingValleys(n, s) {
let valleys = 0;
let mountain = 0;
let lvl = 0;
if (n === 1) {
return 1;
}
if (n === 0) {
@xthecapx
xthecapx / classVsInstance.js
Created March 2, 2019 17:33
Hackerrank Day 4: Class vs. Instance
function Person(initialAge) {
// Add some more code to run some checks on initialAge
if (initialAge < 0) {
console.log("Age is not valid, setting age to 0.");
this.age = 0;
} else {
this.age = initialAge;
}
@xthecapx
xthecapx / processData.js
Created March 5, 2019 01:48
Hackerrank: Day 6: Let's Review
function processData(input) {
//Enter your code here
const words = input.split('\n');
let output = '';
words.slice(1, words.length).forEach(word => {
let odd = '';
let even = '';
word.split('').forEach((input, index) => {
@xthecapx
xthecapx / minimumBribes.js
Created March 5, 2019 01:50
Hackerrank: New Year Chaos
function minimumBribes(q) {
let counter = 0;
let currentPosition = q.length - 1;
let log = '';
let bribes;
while (currentPosition >= 0) {
const current = q[currentPosition];
const orderPosition = currentPosition + 1;
@xthecapx
xthecapx / reverseStringRecursion.js
Created March 6, 2019 02:23
Reverse string with recursion
/** Task
/* Given an array, , of integers, print 's elements in reverse order as a single line of space-separated numbers.
**/
function main() {
const n = parseInt(readLine(), 10);
const arr = readLine().split(' ').map(arrTemp => parseInt(arrTemp, 10));
function reverseArray(toBeReversed) {
var reversed = [];
<MyHair color="blue">
My Head
</MyHair>
React.createElement(
MyHair,
{color: 'blue'},
'My Head'
)