Skip to content

Instantly share code, notes, and snippets.

Avatar

Paulo Basilio paulolorenzobasilio

View GitHub Profile
@paulolorenzobasilio
paulolorenzobasilio / killbutmakeitlooklikeanaccident.sh
Created Aug 15, 2022 — forked from moyix/killbutmakeitlooklikeanaccident.sh
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
View killbutmakeitlooklikeanaccident.sh
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@paulolorenzobasilio
paulolorenzobasilio / mysql2sqlite.sh
Created Oct 14, 2021 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
View mysql2sqlite.sh
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@paulolorenzobasilio
paulolorenzobasilio / squash.php
Created May 5, 2021 — forked from woganmay/squash.php
Use PHP to flatten a multidimensional stdClass object (like a json_decode result)
View squash.php
<?php
function squash($array, $prefix = '')
{
$flat = array();
$sep = ".";
if (!is_array($array)) $array = (array)$array;
foreach($array as $key => $value)
View puppeteer-with-adblock.js
'use strict';
const puppeteer = require('puppeteer');
(async () => {
/* PRECONDITION:
0. download ublock, I used https://github.com/gorhill/uBlock/releases/download/1.14.19b5/uBlock0.chromium.zip
1. run $PATH_TO_CHROME --user-data-dir=/some/empty/directory --load-extension=/location/of/ublock
2. enable block lists you want to use
*/
@paulolorenzobasilio
paulolorenzobasilio / directory-structure.md
Created Jan 9, 2020
Adding directory structure on readme
View directory-structure.md

Directory Structure

Aerobatic defaults to some specific common front-end conventions. By conforming to these conventions you can simplify your configuration (convention over configuration).

Here is the basic suggested skeleton for your app repo that each of the starter templates conforms to:

├── app
│   ├── css
│ │ ├── **/*.css
@paulolorenzobasilio
paulolorenzobasilio / destruct.md
Created Nov 12, 2019
Get subset of a JavaScript object properties
View destruct.md
@paulolorenzobasilio
paulolorenzobasilio / git-is-merged
Last active Aug 22, 2022
Check if source branch has been already merged into destination branch
View git-is-merged
#!/usr/bin/env bash
#
# Check if source branch has been already merged into destination branch
# https://stackoverflow.com/questions/226976/how-can-i-know-if-a-branch-has-been-already-merged-into-master
#
git_is_merged () {
merge_destination_branch=$1
merge_source_branch=$2
@paulolorenzobasilio
paulolorenzobasilio / gitlab-deploy-node.yml
Last active Sep 5, 2019
Sample node project deployment on Gitlab with caching of node_modules, test, build.
View gitlab-deploy-node.yml
image: node:12.9.0-alpine
.ssh: &ssh
before_script:
- "which ssh-agent || ( apk update && apk add openssh-client )"
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *.$STAGING_ENV\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/knit.pem
@paulolorenzobasilio
paulolorenzobasilio / post-merge
Last active Aug 19, 2019
Check changed files on post-merge and execute command
View post-merge
#!/usr/bin/env bash
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
changed() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
View Output Arguments
public class OutputArgument
{
public static void main (String[]args)
{
int[] source = { 1, 2, 3, 4, 5, 6 };
int[] destination = new int[6];
copyFromSourceToDestination (source, destination);
for (int i = 0; i < source.length; i++) {
System.out.println (destination[i]);
}