Skip to content

Instantly share code, notes, and snippets.

@antonga23
antonga23 / FullExample.php
Created June 22, 2021 16:51 — forked from IamSmith/FullExample.php
Fully working example
<?php
require_once("PHPExcel/PHPExcel.php");
$phpExcel = new PHPExcel();
$styleArray = array(
'font' => array(
'bold' => true,
)
);
@antonga23
antonga23 / corrupt_zsh.sh
Created May 25, 2021 09:19
Occasionally you may find you have a corrupt zsh history file preventing you from using the `fc` command or searching the history. Here's how to fix it.
cd ~
mv .zsh_history .zsh_history_bad
strings -eS .zsh_history_bad > .zsh_history
fc -R .zsh_history
@antonga23
antonga23 / Privilege Escalation.md
Created May 7, 2021 14:52 — forked from A1vinSmith/Privilege Escalation.md
Privilege Escalation: Systemctl (Misconfigured Permissions — sudo/SUID)
@antonga23
antonga23 / db_connect_test.php
Created April 29, 2021 15:50
DB Connection test for php
<?php
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => '127.0.0.1', // better than localhost if mysqli.default_socket points to a unknown path
'username' => 'db_user', // As of MySQL v5.7, you can't use 'root' without sudo - you must use a different username and password - https://askubuntu.com/questions/763336/cannot-enter-phpmyadmin-as-root-mysql-5-7
'password' => 'password',
'database' => 'dbname',
@antonga23
antonga23 / json_create.py
Created April 7, 2021 16:14
pretty print json
def write_json():
result = {} #some random json
with open('data.json', 'w', encoding='utf-8') as f:
json.dump(result, f, ensure_ascii=False, indent=4)
@antonga23
antonga23 / dig.py
Created April 7, 2021 16:03
With the following small function, digging into a tree-shaped dictionary becomes quite easy:
def dig(tree, path):
for key in path.split("."):
if isinstance(tree, dict) and tree.get(key):
tree = tree[key]
else:
return None
return tree
#EXAMPLE
# mydict = {
driver.get('chrome://settings/')
driver.execute_script('chrome.settingsPrivate.setDefaultZoom(zoomValue);')
docker rm -f $(docker ps -a -q)
#!/usr/bin/env bash
docker run --rm --ulimit nofile=65536:65536 --name esn01 -p 9200:9200 -v esdata01:/usr/share/elasticsearch/data --network elastic-network -e "node.name=esn01" -e "cluster.name=es-cluster" -e "cluster.initial_master_nodes=esn01" -e "bootstrap.memory_lock=true" --ulimit memlock=-1:-1 -e ES_JAVA_OPTS="-Xms2g -Xmx2g" docker.elastic.co/elasticsearch/elasticsearch:7.3.0
# Create the master node for our cluster
# NB we increase max file descriptors to 65536 using the nofile argument
# Expected Output should be similar to this
@antonga23
antonga23 / forwardport.sh
Created November 18, 2020 19:32 — forked from debashisbarman/forwardport.sh
Forward port 80 to 8080 on EC2 instance.
sudo iptables -t nat -L
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000