Skip to content

Instantly share code, notes, and snippets.

View sly01's full-sized avatar
πŸ‘¨β€πŸ’»

Ahmet Erkoc sly01

πŸ‘¨β€πŸ’»
View GitHub Profile
import re
f = open("data.csv", "r")
lines = f.readlines()
regex = '\[(.*?)\] "(.*?)" (\d+) (\d+)'
l = []
for line in lines:
path = re.match(regex, line).group(2)
status_code = re.match(regex, line).group(3)
@sly01
sly01 / code.py
Created October 25, 2019 13:00
Decorators with parameters
import functools
user = {"username": "ahmet", "access_level": "guest" }
def make_secure(access_level):
def decarator(func):
@functools.wraps(func)
def secure_function(*args, **kwargs):
if user["access_level"] == access_level:
return func(*args, **kwargs)
@sly01
sly01 / web-servers.md
Created July 5, 2019 09:46 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@sly01
sly01 / docker-compose.yml
Created October 14, 2018 19:35 — forked from ahromis/docker-compose.yml
Gogs docker-compose.yml
version: '2'
services:
postgres:
image: postgres:9.5
restart: always
environment:
- "POSTGRES_USER=${POSTGRES_USER}"
- "POSTGRES_PASSWORD=${POSTGRES_PASSWORD}"
- "POSTGRES_DB=gogs"
volumes:
python main.py --help
usage: main.py [-h] file_name line_number
positional arguments:
file_name filename
line_number number of line
optional arguments:
-h, --help show this help message and exit
#!/usr/bin/env python3.6
message = input("Enter a message: ")
count = input("Number of repeats [1]: ").strip()
if count:
count = int(count)
else:
count = 1
@sly01
sly01 / set_fact
Last active December 4, 2017 08:29
- name: Parse and create dict
set_fact:
user_datas: "{{ user_datas|default({}) | combine( {item.split(':')[0]: item.split(':')[1]} ) }}"
my_list: >
{% set l = [] %}
{% l.append(user_datas) %}
with_items: "{{ user_list }}"
@sly01
sly01 / -
Created September 22, 2017 12:35
[root@test-172-ct20 ~]# puppet agent -t
Info: Using configured environment 'test'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Notice: /Stage[main]/Profile::Monitoring::Nagios/Tidy[tmp_nagios]: Tidying 0 files
Info: Applying configuration version '1506083331'
Notice: /Stage[main]/Profile::Netbackup::Files/File[/opt/openv7c]/ensure: current_value absent, should be directory (noop)
Notice: /Stage[main]/Netbackup::Client::Install/File[install_netbackup_client.expect]/ensure: current_value absent, should be file (noop)
Notice: /Stage[main]/Netbackup::Client::Install/Package[expect]/ensure: current_value purged, should be present (noop)
Error: /Stage[main]/Profile::Base/File[/root/hello.txt]: Could not evaluate: Could not retrieve information from environment development source(s) file:/scripts/hello.txt
Notice: /Stage[main]/Profile::Base/Nfs::Client::Mount[/scripts]/Mount[shared 192.168.33.50:/test by localhost.localdomain /scripts]/ensure: ensure changed 'unmounted' to 'mounted'
Info: /Stage[main]/Profile::Base/Nfs::Client::Mount[/scripts]/Mount[shared 192.168.33.50:/test by localhost.localdomain /scripts]: Scheduling refresh of Mount[shared 192.168.33.50:/test by localhost.localdomain /scripts]
Info: Mount[shared 192.168.33.50:/test by localhost.localdomain /scripts](provider=parsed): Remounting
Notice: /Stage[main]/Profile::Base/Nfs::Client::Mount[/scripts]/Mount[shared 192.168.33.50:/test by localhost.localdomain /scripts]: Triggered 'refresh' from 1 events
include ::nfs::client
nfs::client::mount { '/scripts':
mount => '/scripts',
server => '192.168.33.50',
share => '/test',
perm => '0755',
options => 'rw,nfsvers=3',
}