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 | |
host=8.8.8.8 | |
while : | |
do | |
echo "Pinging $host" | |
ping_result=$(ping $host -c 1 -n -q | egrep "[0-9]+% packet loss" -o | sed 's/% packet loss//g') | |
if [[ ! $ping_result ]]; then | |
clear | |
date | |
echo -en "\n\n$host could not be reached" |
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
if (/^\/.+/.test(window.location.pathname)) { | |
if (!/^(\/#)/.test(window.location.pathname)) { | |
console.error("Invalid URL: " + window.location); | |
window.location = '/#' + window.location.pathname; | |
} | |
} |
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 ruby | |
for i in 0..100 | |
if i % 15 == 0 | |
print " fizzbuzz " | |
elsif i % 5 == 0 | |
print " buzz " | |
elsif i % 3 == 0 | |
print " fizz " | |
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/bin/env ruby | |
require 'trollop' | |
opts = Trollop::options do | |
banner <<-EOS | |
Reverses a string. | |
Usage: | |
ruby reverse.rb [options] | |
Options: |
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
def exception2msg(e): | |
""" DIE python DIE! Which one works: | |
to_unicode(e.value); unicode(e); str(e); | |
Call this so you don't have to care. """ | |
# ... some stuff |
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 | |
# I renamed Markdown.pl to markdown for simpler typing. | |
function to_markdown() { | |
local src="${1}" | |
if [ -z "${src}" ]; then | |
echo "no source" | |
return | |
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
import re | |
def memoize(f): | |
class memodict(dict): | |
def __init__(self, f): | |
self.f = f | |
def __call__(self, *args): | |
return self[args] | |
def __missing__(self, key): | |
ret = self[key] = self.f(*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
// Import required java libraries | |
import java.io.*; | |
import javax.servlet.*; | |
import javax.servlet.http.*; | |
// Extend HttpServlet class | |
public class HelloWorld extends HttpServlet { | |
private String message; |
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
<servlet> | |
<servlet-name>HelloWorld</servlet-name> | |
<servlet-class>HelloWorld</servlet-class> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>HelloWorld</servlet-name> | |
<url-pattern>/HelloWorld</url-pattern> | |
</servlet-mapping> |
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 <iostream> | |
#include <fstream> | |
#include <exception> | |
#include <vector> | |
int main(const int argc, const char** argv) { | |
const int UNSET = -1; | |
const int BEGINNING = 0; | |
const std::string DELIMITER = " "; |
OlderNewer