Skip to content

Instantly share code, notes, and snippets.

dantheman213 / Great GNU Screen config
Last active Mar 13, 2020
GNU Screen configuration file that helps to optimize your experience
View Great GNU Screen config
# GNU Screen
# Preferred Configuration File
# Turn off start up message
startup_message "off"
# Allow bold colors
attrcolor b ".I"
# Tell screen how to set colors. AB = background, AF=foreground
dantheman213 / file.m
Created Jul 24, 2015
Recursively list all dirs and files in a iOS app's documents directory
View file.m
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *bundleURL = [[NSBundle mainBundle] bundleURL];
NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtURL:bundleURL
includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey]
errorHandler:^BOOL(NSURL *url, NSError *error)
NSLog(@"[Error] %@ (%@)", error, url);
dantheman213 / HttpGetRequestSync.cs
Created Jul 30, 2015
C# HTTP GET request synchronous example
View HttpGetRequestSync.cs
using System.Net.Http;
using (var client = new HttpClient())
var url = "";
var response = client.GetAsync(url).Result;
if (response.IsSuccessStatusCode)
// by calling .Result you are performing a synchronous call
dantheman213 / HttpGetRequestSyncWithHeaders.cs
Created Jul 31, 2015
C# HTTP GET request synchronous with additional header example
View HttpGetRequestSyncWithHeaders.cs
using (var client = new HttpClient())
var request = new HttpRequestMessage()
RequestUri = new Uri(""),
Method = HttpMethod.Get
request.Headers.Add("Content-Type", "application/json; charset=utf-8");
var response = client.SendAsync(request).Result;

Git Cheatsheet

This cheatsheet is to assist anyone new with Git with becoming familiar with common scenarious.


Reset single file back to last checkout

git checkout HEAD -- my-file.txt
dantheman213 / tomcat.conf
Created Sep 14, 2015
Tomcat 8 upstart configuration file
View tomcat.conf
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn limit 10 5
setuid tomcat
setgid tomcat
dantheman213 /
Last active Sep 14, 2015
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:// 0xcbcb082a1bb943db

  • add-apt-repository 'deb 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 /
Last active Nov 2, 2015
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 /
Last active Dec 10, 2015
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 / center_element.css
Created Dec 11, 2015
HTML5 - center any element
View center_element.css
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);