Skip to content

Instantly share code, notes, and snippets.

@mmyjona
mmyjona / gist:3917268
Created October 19, 2012 10:03
ping with python popen
##mmyjona2012-10-19 18:02:38
from subprocess import *
import subprocess
import re
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
output = Popen(["ping", "-n", "3", "baidu.com"],startupinfo=startupinfo, stdout=PIPE).communicate()[0]
regex = re.compile(r"from\s(\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b).*bytes=(\d*).*time=(\d*).*TTL=(\d*)")
r = regex.findall(output)
print r
#!/bin/sh
# btsync service
# Replace with linux users you want to run BTSync clients for
BTSYNC_USERS="mendel"
DAEMON=/usr/bin/btsync
start() {
for btsuser in $BTSYNC_USERS; do
HOMEDIR=`getent passwd $btsuser | cut -d: -f6`
config=$HOMEDIR/.sync/config.json
D/AndroidRuntime(25948): Shutting down VM
E/AndroidRuntime(25948): FATAL EXCEPTION: main
E/AndroidRuntime(25948): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.b8_show/com.example.b8_show.ui.ExclusiveServiceActivity}: android.view.InflateException: Binary XML file line #155: Error inflating class <unknown>
E/AndroidRuntime(25948): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
E/AndroidRuntime(25948): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
E/AndroidRuntime(25948): at android.app.ActivityThread.access$700(ActivityThread.java:140)
E/AndroidRuntime(25948): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
E/AndroidRuntime(25948): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(25948): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(25948): at android.app.ActivityThread.main(ActivityThread.java:4921)
@mmyjona
mmyjona / gist:5c922f4198cfd1ce7710
Created August 9, 2014 17:27
Disable the memory warning
1. Click Start, click in the Start Search box, type gpedit.msc, and then press ENTER. MMC will start with the Local Group Policy Editor open.
2. In the navigation tree, expand Computer Configuration, expand Administrative Templates, expand System, expand Troubleshooting and 3. Diagnostics, and click Windows Resource Exhaustion Detection and Resolution.
3. In the console pane, right-click Configure Scenario Execution Level, and then click Properties.
4. On the Setting tab, select Disabled, and then click OK.
@mmyjona
mmyjona / install-graphite-centos-6.5.sh
Created April 6, 2016 03:04 — forked from xluffy/install-graphite-centos-6.5.sh
install-graphite-centos-6.5.sh
#!/bin/bash
## Update system
cd
yum update -y
## Install base package
@mmyjona
mmyjona / uwsgi_nginx_on_centos6.7.txt
Created April 23, 2016 05:15 — forked from ckandoth/uwsgi_nginx_on_centos6.7.txt
Set up nginx and uwsgi emperor on a CentOS 6.7 box
# GOAL: On a CentOS 6.7 minimal install, set up nginx as a reverse proxy to uWSGI Emperor with python 2.7.11 as a plugin to run Flask apps
# ::NOTE:: All instructions below are run as a sudoer, not as root. Talk to your sysadmins if you're not a sudoer.
# Install bare essentials:
sudo yum install -y epel-release
sudo yum groupinstall 'Development Tools'
sudo yum install -y vim openssl unzip nginx openssl-devel zlib-devel sqlite-devel bzip2-devel libffi-devel lapack-devel blas-devel libpng-devel freetype-devel
# Set SELINUX=disabled in the file below, and reboot, or this tutorial will get unnecessarily complicated:
docker-machine create -d virtualbox --engine-env HTTP_PROXY=http://192.168.99.1:7007 --engine-env HTTPS_PROXY=https://192.168.99.1:7007 --engine-opt dns=8.8.8.8 dev
@mmyjona
mmyjona / download pack.js
Last active July 18, 2017 14:54
bookmarket to download sticker pack from telegram web
function download(filename, link) {
var element = document.createElement('a');
element.setAttribute('href', link);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
____ _ _ _
| _ \(_)_ __ _ __ ___ (_)_ __ | |_
| |_) | | '_ \| '_ \ / _ \| | '_ \| __|
| __/| | | | | |_) | (_) | | | | | |_
|_| |_|_| |_| .__/ \___/|_|_| |_|\__|
|_|