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 android.net.TrafficStats; | |
import android.app.ActivityManager; | |
import android.content.pm.PackageManager; | |
private void getServiceTraffic() { | |
PackageManager pm = getPackageManager(); | |
ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); | |
List<ActivityManager.RunningServiceInfo> runningServices = am.getRunningServices(Integer.MAX_VALUE); | |
for (ActivityManager.RunningServiceInfo service : runningServices) { |
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 android.util.Log; | |
import java.io.BufferedInputStream; | |
import java.io.BufferedReader; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
private void sendHTTPRequest() { |
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 android.util.Log; | |
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
private void executeCommand() { | |
String inputLine; | |
String output = ""; | |
Process process = Runtime.getRuntime().exec("cat /proc/net/xt_qtaguid/stats"); | |
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream())); | |
while ((inputLine = in.readLine()) != null) { |
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
function sendHTTP | |
{ | |
param( $uri, $message ) | |
$postData = "{" | |
$postData += "`"message`":`""+$message+"`"," | |
$postData += "`"name`":`"ryan`"" | |
$postData += "}" | |
$request = [System.Net.WebRequest]::Create($uri) | |
$request.Method = "POST" | |
$request.Timeout = 5000 |
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
# http://askubuntu.com/questions/75852/how-do-i-see-which-ports-are-open | |
netstat -ntlp | grep 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
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
# @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ | |
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ | |
# IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! | |
# Someone could be eavesdropping on you right now (man-in-the-middle attack)! | |
# It is also possible that a host key has just been changed. | |
# The fingerprint for the RSA key sent by the remote host is | |
# f0:6f:50:f0:13:96:32:67:99:79:14:59:b6:32:16:16. | |
# Please contact your system administrator. | |
# Add correct host key in /Users/ryan/.ssh/known_hosts to get rid of this 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
# Ubuntu box with 2 NICs | |
# eth0 = WAN | |
# eth1 = LAN | |
# OR | |
# eth0 = larger network | |
# eth1 = smaller network | |
# Setup and install | |
sudo apt-get install iptables-persistent |
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
// This is an incomplete example but has the gist of it | |
successCB = (blob) => { | |
let objectURL = URL.createObjectURL(blob); | |
let a = document.createElement("a"); | |
a.href = objectURL; | |
a.download = 'MyPDF'; | |
document.body.appendChild(a); | |
a.click(); | |
setTimeout(()=>{a.remove()}, 1000); |
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
# Works fine on ubuntu 14.04. Gave me issues on 16.04. | |
sudo apt-get update -y | |
sudo apt-get upgrade -y | |
sudo add-apt-repository ppa:vbernat/haproxy-1.6 | |
sudo apt-get dist-upgrade -y | |
sudo apt-get install haproxy -y | |
# Edit the haproxy config | |
sudo nano /etc/haproxy/haproxy.cfg |
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
// This example uses ReactJS but can be substituted for something else. Uses html2canvas and FileSaver. | |
// This example saves a leaflet map | |
saveMap = () => { | |
let mapNode = ReactDOM.findDOMNode(this.refs.leafletMap) | |
html2canvas(mapNode, { | |
useCORS: true, | |
onrendered: (canvas) => { | |
canvas.toBlob((blob) => { | |
FileSaver.saveAs(blob, "MyMap.png"); |
OlderNewer