Skip to content

Instantly share code, notes, and snippets.

View kissgyorgy's full-sized avatar

György Kiss kissgyorgy

View GitHub Profile
@kissgyorgy
kissgyorgy / no_sysicon.au3
Created January 15, 2013 04:36
AutoIt: No window sysicon
; http://www.autoitscript.com/forum/topic/139953-msgbox-with-scrollbar/#entry982510
#include <APIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIEx.au3> ; www.autoitscript.com/forum/topic/98712-winapiex-udf/
Example()
Func Example()
Local $hGUI = _GUICreate_NoIcon("_GUICreate_NoIcon()")
@kissgyorgy
kissgyorgy / findwindow_under_mouse.au3
Created January 17, 2013 01:32
AutoIt: Find window under mouse pointer
; URL http://stackoverflow.com/a/11270659/720077
; made by ascend4nt (https://sites.google.com/site/ascend4ntscode/processfunctions)
#include <WinAPI.au3>
#include <Misc.au3>
Func _WindowFromPoint($iX,$iY)
Local $stInt64,$aRet,$stPoint=DllStructCreate("long;long")
DllStructSetData($stPoint,1,$iX)
DllStructSetData($stPoint,2,$iY)
@kissgyorgy
kissgyorgy / hwid.au3
Created January 21, 2013 14:40
AutoIt: _HWID() Protect Your Script.
; Original thread: http://www.autoitscript.com/forum/topic/146661-hwid-protect-your-script/
Func _HWID()
local $drives = DriveGetDrive("FIXED")
local $space = 0
local $serial = ""
local $RAM = MemGetStats()
for $i=1 to $drives[0]
$space += DriveSpaceTotal ($drives[$i])
$serial &= StringUpper(DriveGetSerial($drives[$i]))
@kissgyorgy
kissgyorgy / python_or.py
Last active December 15, 2015 15:39
the Boolean operations or and and always return one of their operands
# See: http://docs.python.org/2/library/stdtypes.html
>>> "alma" or "korte"
Out[1]: 'alma'
>>> "" or "barack"
Out[2]: 'barack'
@kissgyorgy
kissgyorgy / remove_punc.py
Created June 8, 2013 08:01
Python: Remove punctuation from string
#http://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string-in-python
import re, string
table = string.maketrans("","")
regex = re.compile('[%s]' % re.escape(string.punctuation))
def test_re(s): # From Vinko's solution, with fix.
return regex.sub('', s)
def test_trans(s):
@kissgyorgy
kissgyorgy / generate_id.py
Created June 8, 2013 08:06
Python: Generate random string
# http://stackoverflow.com/questions/2257441/python-random-string-generation-with-upper-case-letters-and-digits/2257449#2257449
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for x in range(size))
@kissgyorgy
kissgyorgy / TableWidgetCenteredItem.py
Created July 18, 2013 13:55
PyQt: Read only centered cells in QTableWidget.
from PyQt4.QtGui import QTableWidgetItem
from PyQt4.QtCore import Qt
class TableWidgetCenteredItem(QTableWidgetItem):
""" Read only centered cells in QTableWidget. """
def __init__(self, *args, **kwargs):
super(TableWidgetCenteredItem, self).__init__(*args, **kwargs)
self.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
self.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
@kissgyorgy
kissgyorgy / urllib2_cookies.py
Created July 29, 2013 08:03
Python: Add cookies to a request with urllib2
# see: http://stackoverflow.com/a/3334959/720077
# if there are more cookies, they should go all in one "Cookie" header in this format:
# "cookie1name=cookie1value;cookie2name=cookie2value;"
import urllib2
opener = urllib2.build_opener()
opener.addheaders.append(('Cookie', 'cookiename=cookievalue'))
f = opener.open("http://example.com/")
@kissgyorgy
kissgyorgy / download_file.py
Last active November 15, 2022 10:38
Python: Download file, get file size and Content type.
import requests
r = requests.get("http://download.thinkbroadband.com/10MB.zip",
cookies={'cookie1': 'working'}
)
open('10MB.zip', 'wb').write(r.content)
@kissgyorgy
kissgyorgy / filename_from_url.py
Created July 29, 2013 08:13
Python: Get file name from url
# http://stackoverflow.com/a/300533/720077
import urllib2
file_name = urllib2.unquote(url).decode('utf8').split('/')[-1]