Skip to content

Instantly share code, notes, and snippets.

@kopiro
kopiro / xhr_fetch_hook.js
Last active June 16, 2020 08:32
XHR / Fetch Hook - Log requests directly in the Dev Console
formatBody = (body) => { if (!body) return body; try { return JSON.parse(body); } catch (err) { return body; } };
XMLHttpRequest.prototype._open = XMLHttpRequest.prototype._open || XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function() {
this._openArgs = arguments;
return XMLHttpRequest.prototype._open.apply(this, arguments);
};
XMLHttpRequest.prototype._send = XMLHttpRequest.prototype._send || XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(body) {
@kopiro
kopiro / file.sh
Last active March 31, 2020 15:45
Configure Unattended Upgrades
apt-get -y install unattended-upgrades
dpkg-reconfigure --priority=low unattended-upgrades
@kopiro
kopiro / slack-multiple.scpt
Created September 23, 2019 12:20
Slack - Multiple channels message
set myChannels to {"random"} # Populate this field
set theResponse to display dialog "What's your message?" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"
set theMessage to text returned of theResponse
tell application "Slack"
activate
tell application "System Events"
repeat with theChannel in myChannels
@kopiro
kopiro / get-apple-id-email.sh
Last active June 19, 2019 12:39
Get Apple ID email in OSX
#!/bin/sh
dscl . readpl "/Users/$(whoami)" dsAttrTypeNative:LinkedIdentity "appleid.apple.com:linked identities:0:full name" | awk '{print $4}'
@kopiro
kopiro / AutoUpdater.vb
Created November 26, 2018 08:10
Auto Update VB.NET Compact 3.5 App
Public Class AutoUpdater
Public newVersion As String
Public urlOfCab As String
Public credentials As Net.NetworkCredential
Public askDest As Boolean = False
Public deleteCab As Boolean = True
Public useUI As Boolean = False
Public permitUninstall As Boolean = False
@kopiro
kopiro / README.md
Last active November 6, 2018 14:39
Extract from a JS object with a specific pattern

extractWithPattern

Extract from a JS object with a specific pattern

let msg = [
	{ payload: { errors: { unknown_language: 'hello' } } },
	{ payload: { errors: { number: 1 } } },
	{ randomstuff: 42 }
];
@kopiro
kopiro / backup-repos.sh
Last active October 15, 2018 10:39
Backup all Repositories in current directory
backup-repos() {
for i in $(find . -type d -maxdepth 1 -mindepth 1); do
echo "Looking in $i..."
if [ -d "$i/.git" ]; then
echo "Found repository in $i, init backup..."
pushd $i > /dev/null
zip_name="$i-$(date +'%y%m%d').zip"
zip_path="/opt/backups/$zip_name"
echo "ZIP path: $zip_path"
if [ ! -f "$zip_path" ]; then
@kopiro
kopiro / number_to_english.js
Created September 7, 2018 12:55
Number to English
const digit_to_string = {
0: 'zero',
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
@kopiro
kopiro / README.md
Created June 22, 2018 11:48
Download entire INTERNET

Internet Downloader

Simple POC

Compilation

brew install wget
gcc -lcurl download_internet.c
@kopiro
kopiro / number-generator.php
Created June 13, 2018 16:18
PHP Number Generator
<?php
function autoIncrement($start = 0, $step = 1, $circle = -1, $repeat = 1) {
$i = $start;
while (true) {
for ($j = 0; $j < $repeat; $j++) yield $i;
$i += $step;
if ($i === $circle) $i = $start;
}
}