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
const sumArray = (a) => { | |
if ( typeof a == 'undefined' || !a || a.length < 2 ) { return 0; } | |
a.sort((a,b) => a - b).splice(0, 1) | |
a.splice(a.length - 1, 1); | |
if ( a.length < 3 ) { return 0; } | |
return a.reduce((a,b) => a+b); | |
}; |
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
const arrange = (str) => { | |
let words = str.split(' '), i = 0; | |
for (; i < words.length - 1; i++) { | |
if ( | |
(0 === i % 2 && words[i].length > words[i + 1].length) || | |
(1 === i % 2 && words[i].length < words[i + 1].length) | |
) { | |
let tmp = words[i]; | |
words[i] = words[i + 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
#!/bin/ruby | |
class BubbleSort | |
def initialize(unsorted_array) | |
@array = unsorted_array | |
@swaps = 0 | |
end | |
def sort | |
@array.each_with_index do |val, key| |
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
#!/bin/ruby | |
require "test/unit" | |
class GridMap | |
CARDINAL="NESW" | |
def initialize(directions) | |
@face = 'N' | |
@pointing = 0 |
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
#!/bin/ruby | |
class Trie | |
@@root | |
def initialize | |
@@root = TrieNode.new | |
end | |
def add_word(word) |
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
<?php | |
class Trie { | |
private $_root; | |
public function __construct() { | |
$this->_root = new TrieNode(); | |
} | |
public function add($word) { |
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
##################################################### | |
# | |
# Provided by the Magento Support Center | |
# http://magentosupport.help/knowledgebase/configuring-nginx-to-work-with-magento-advanced/ | |
# | |
# Your Magento Tutorial specialists | |
# | |
server { | |
listen *:8080; | |
server_name fanatik.redrokk.com www.fanatikbike.com fanatikbike.com; |
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
#!/usr/bin/env bash | |
function get_process_description { | |
local __page=$(MANWIDTH=200 man "$@" 2>&1 | col -bx) | |
local __desc=$(echo "$__page" | pcregrep -M -o2 '(DESCRIPTION)\n(.*)' | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba') | |
if [[ -z "$__desc" ]]; then | |
return 2 | |
else |
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
#!/usr/local/bin/bash | |
total=0.000 | |
ttfbs=() | |
for i in `seq 1 5` | |
do | |
ttfb=$(curl -s -o /dev/null -w "%{time_starttransfer}" "$1") | |
total=$(scale=3;echo "$total+$ttfb" | bc) | |
done |
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
#!/bin/bash | |
echo "Commencing Vocativ Base Setup as user: $USER" | |
cd /srv/www/ | |
echo "Setting permissions..." | |
sudo touch /var/log/php5-fpm.log | |
echo "Copying vagrant ssh settings to root..." |