Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / Privilege Escalation.md
Created May 7, 2021 14:52 — forked from A1vinSmith/Privilege Escalation.md
Privilege Escalation: Systemctl (Misconfigured Permissions — sudo/SUID)
@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 / 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 / git.migrate
Created June 23, 2021 15:22 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@antonga23
antonga23 / coinId.php
Created July 1, 2021 11:08 — forked from crcrcr999/coinId.php
XCH(chia) getCoinId by PHP
<?php
function hexToStr($hex){
$string='';
for ($i=0; $i < strlen($hex)-1; $i+=2){
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
return $string;
}
function getCoinId($parent_coin_info,$puzzle_hash,$amount){
@antonga23
antonga23 / facebook.py
Created December 31, 2021 10:31 — forked from ezl/facebook.py
Are there any put-call parity opportunities? Lets check facebook options
"""
Checking for put-call parity mispricings in facebook.
fb is American, so put call parity doesn't actually apply, but
this is a short term option, with no dividends between now and the
expiration (apr 17, 1 week option), in a low interest rate environment
so you can expect the trees to act almost european.
easier to find this data on yahoo than actual european data and
everyone knows what facebook is so i went with it.
@antonga23
antonga23 / git-ssh.txt
Created January 7, 2022 15:17
A simple way to authenticate to github using ssh across multiple accounts
1. Generate keys for github accounts
eg.
ssh-keygen -t ed25519 -C "[email protected]"
ssh-keygen -t ed25519 -C "[email protected]"
2. Start ssh-agent in background and add keys
@antonga23
antonga23 / example.md
Created March 29, 2022 08:42 — forked from devdrops/example.md
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯