Skip to content

Instantly share code, notes, and snippets.

@dantheman213
dantheman213 / HttpGetRequestSyncWithHeaders.cs
Created July 31, 2015 00:43
C# HTTP GET request synchronous with additional header example
using (var client = new HttpClient())
{
var request = new HttpRequestMessage()
{
RequestUri = new Uri("http://google.com/"),
Method = HttpMethod.Get
};
request.Headers.Add("Content-Type", "application/json; charset=utf-8");
var response = client.SendAsync(request).Result;
@dantheman213
dantheman213 / tomcat.conf
Created September 14, 2015 16:31
Tomcat 8 upstart configuration file
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid tomcat
setgid tomcat
@dantheman213
dantheman213 / New_Tomcat_Server.md
Last active September 14, 2015 17:35
new tomcat server installation commands for ubuntu

Setting up Tomcat on fresh Ubuntu Server

  • add-apt-repository ppa:webupd8team/java

  • apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db

  • add-apt-repository 'deb http://ftp.utexas.edu/mariadb/repo/10.1/ubuntu trusty main'

  • apt-get update; apt-get upgrade

  • apt-get install screen whois git npm nodejs-legacy nodejs oracle-java8-installer software-properties-common mariadb-server

  • groupadd tomcat

  • useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat

@dantheman213
dantheman213 / AppPath.java
Last active November 2, 2015 22:54
Java Get Full Application Path Cross Platform
public class AppPath {
public String getAppPath() {
URL url;
String extURL;
Class anyClass = this.getClass();
try {
url = anyClass.getProtectionDomain().getCodeSource().getLocation();
@dantheman213
dantheman213 / git_latest.sh
Last active December 10, 2015 18:30
Execute this one-liner in your primary directory for git projects to get latest codebase
for k in `ls`; do echo "Getting latest for $k"; cd $k; git fetch; git pull; cd ..; done
@dantheman213
dantheman213 / center_element.css
Created December 11, 2015 22:40
HTML5 - center any element
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
@dantheman213
dantheman213 / Vagrantfile
Last active December 15, 2015 04:06
vagrant setup script for development server
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 21, host: 2121
@dantheman213
dantheman213 / legacy_browser_support.html
Created December 22, 2015 19:13
enable ie legacy features
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
<![endif]-->
@dantheman213
dantheman213 / jquery.outerhtml.js
Created December 23, 2015 22:44
jquery outerhtml
(function($){
var div;
$.fn.outerHTML = function() {
var elem = this[0],
tmp;
return !elem ? null
: typeof ( tmp = elem.outerHTML ) === 'string' ? tmp
: ( div = div || $('<div/>') ).html( this.eq(0).clone() ).html();
@dantheman213
dantheman213 / self_signed_ssl.sh
Created December 27, 2015 17:19
Create self-signed SSL certificate
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout site.key -out site.crt