Skip to content

Instantly share code, notes, and snippets.

View teocci's full-sized avatar
👨‍💻
Coding

Teocci teocci

👨‍💻
Coding
View GitHub Profile
import android
import time
from datetime import date, datetime
def log_battery_status(droid):
"""Log battery percentage"""
droid.batteryStartMonitoring()
battery = 0
while not battery:
battery = droid.batteryGetLevel().result
@teocci
teocci / RecordingVideo.js
Created April 11, 2016 19:57 — forked from dawsontoth/RecordingVideo.js
How to record video, then share or save it. Using Appcelerator Titanium!
/**
* This sample lets you record and share video with Appcelerator Titanium on Android.
* REQUIRES THE 1.6.0 RC OF TITANIUM MOBILE SDK
* http://developer.appcelerator.com/blog/2011/02/release-candidate-for-titanium-mobile-1-6-0.html
*/
/**
* First, create our UI. We'll have two buttons: record, and share.
*/
var win = Titanium.UI.createWindow({
MediaRecorder mediaRecorder = new MediaRecorder();
CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
profile.videoFrameWidth = 1280;
profile.videoFrameHeight = 720;
mediaRecorder.setCamera(Camera.open());
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(profile);
@teocci
teocci / rtspTcpClient_DSS.py
Created August 1, 2017 08:18 — forked from mike-zhang/rtspTcpClient_DSS.py
rtsp TCP Client for DarwinStreamingServer(python)
#! /usr/bin/python
import socket,time,string,random,thread
m_Vars = {
"bufLen" : 1024 * 10,
"defaultServerIp" : "192.168.1.100",
"defaultServerPort" : 554,
"defaultTestUrl" : "rtsp://192.168.1.100/test1.mp4",
"defaultUserAgent" : "LibVLC/2.0.3 (LIVE555 Streaming Media v2011.12.23)"
@teocci
teocci / nmapScanUdp.py
Created August 1, 2017 08:19 — forked from mike-zhang/nmapScanUdp.py
udp端口扫描(python-nmap代码)
#! /usr/bin/python
import nmap
# python-nmap url : http://xael.org/norman/python/python-nmap/python-nmap-0.1.4.tar.gz
nm = nmap.PortScanner()
nm.scan(hosts='192.168.1.0/24', arguments='-n -p 161 -sU ')
hosts_list = [(x, nm[x][u'udp'][161]['state']) for x in nm.all_hosts()]
#print nm.all_hosts()
#print nm[u'192.168.1.100'][u'udp'][161]['state']
@teocci
teocci / udpServer1.py
Created August 1, 2017 08:20 — forked from mike-zhang/udpServer1.py
a simple udp server (python code)
#! /usr/bin/python
# a simple udp server
import socket, traceback
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind(("127.0.0.1",12345))
while 1:
try:
@teocci
teocci / tcpServer1.py
Created August 1, 2017 08:20 — forked from mike-zhang/tcpServer1.py
a simple tcp server (python code)
#! /usr/bin/python
# a simple tcp server
import socket,os
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('127.0.0.1', 12345))
sock.listen(5)
while True:
connection,address = sock.accept()
buf = connection.recv(1024)
print buf
@teocci
teocci / udpClient1.py
Created August 1, 2017 08:24 — forked from mike-zhang/udpClient1.py
a simple udp client (python code)
#! /usr/bin/python
# a simple udp client
import socket,time,traceback
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
dstHost = ('192.168.1.100', 12345)
while True:
try:
client.sendto('3',dstHost)
print time.time(),' : send success'
@teocci
teocci / tcpClient1.py
Created August 1, 2017 08:24 — forked from mike-zhang/tcpClient1.py
a simple tcp client(python code)
#! /usr/bin/python
# a simple tcp client
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('127.0.0.1', 12345))
#sock.send('Test\n')
sock.send(raw_input("Please input : "))
print sock.recv(1024)
sock.close()
/*
* Copyright (c) 2014 by Bart Kiers
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following