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
public class ExceptionUtil { | |
public interface MayThrow<R>{ | |
public R method() throws Exception; | |
} | |
public static <T> T tryBlock(MayThrow<T> throwing) { | |
try{ | |
T obj = throwing.method(); | |
return obj; | |
} catch(Exception e) { |
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
Double number = ExceptionUtil.tryBlock(() -> Double.valueOf(numberAsString)) |
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 java.util.Optional; | |
public class ExceptionUtil { | |
public interface MayThrow<R>{ | |
public R method() throws Exception; | |
} | |
public static <T> T tryBlock(MayThrow<T> throwing) { | |
try{ | |
T obj = throwing.method(); |
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
DATABASES = { | |
'default': { | |
'ENGINE': 'mysql.connector.django', | |
'NAME': '****', | |
'USER': '****', | |
'PASSWORD': '****', | |
'HOST': '****', | |
'PORT': '****', | |
'OPTIONS': { | |
"use_pure": True |
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
methodThatReturnsAPromise().then(result => { | |
handleResult(result) | |
}).catch(err => { | |
handleAnyExceptions(err) | |
}) |
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
try { | |
var result = await methodThatReturnsAPromise() | |
handleResult(result) | |
} catch (err) { | |
handleAnyExceptions(err) | |
} |
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
var err, result | |
[err, result] = await methodThatReturnsAPromise().then(res => [null, res], error => [error]).catch(error => {err = error}) | |
if(err != null) { | |
handleAnyExceptions(err) | |
} else if(result != null) { | |
handleResult(result) | |
} |
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
lsof -i:$1 | awk '{print $2}' | grep -v -e "PID" | sort -u > temp.txt | |
pids=`cat temp.txt` | |
rm temp.txt | |
echo "The ids: $pids" | |
for id in $pids; do | |
echo "killing $id"; | |
kill -9 $id; | |
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
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME | |
Code\x20H 6181 tielman 52u IPv6 0x570f09f514ea1165 0t0 TCP *:52639 (LISTEN) |
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
appInsights = require("applicationinsights"); | |
let exceptionTrack = appInsights.defaultClient.trackException; | |
appInsights.defaultClient.trackException = function myExceptionTracker(telemetry) { | |
let exception = telemetry.exception | |
//How to test for a Promise | |
if (Promise.resolve(exception) == exception) { | |
exception.then(res => { | |
telemetry.exception = res; | |
exceptionTrack.call(appInsights.defaultClient, telemetry); |
OlderNewer