Skip to content

Instantly share code, notes, and snippets.

@trufae
trufae / yt.sh
Created February 28, 2024 10:13
yt
#!/bin/sh
pkill mpv
q=$(echo $@ | sed -e 's/ /%20/g')
res=$(curl -s "https://www.youtube.com/results?search_query=$q" | sed -e 's/}/\n/g' -e 's/{/\n/g' | grep videoId | grep ']$' |sort -u | cut -d '"' -f 4 | grep -v '%' )
CMD="mpv --shuffle --no-video"
for a in $res ; do
CMD="$CMD ytdl://$a"
done
eval $CMD
@trufae
trufae / toot.sh
Last active May 23, 2023 13:27
toot.sh
#!/bin/sh
TOKEN="##PUT##YOUR##KEY##HERE"
MESSAGE="$1"
INSTANCE="c.im"
curl --header "Authorization: Bearer ${TOKEN}" \
--form "status=${MESSAGE}" \
"https://${INSTANCE}/api/v1/statuses"
@trufae
trufae / r2poke
Created February 28, 2023 16:11
r2poke/json test
Q: whats "fields", whats "boffsets", the offset inside looks wrong. not 0x100003a3c :?
Q: will be good to have field offsets starting from struct map address and struct mapping absolute address
```sh
$ r2 /bin/ls
[0x100003a3c]> . ./json.pk
[0x100003a3c]> ""poke type Test = struct { byte a; byte b; }
[0x100003a3c]> ""poke var root = Test@0x100003a3c#B
[0x100003a3c]> poke print json_format(root)
{"value": {"fields": [127, 35], "boffsets": [119264, 119272], "mapping": {"mapped": 1, "strict": 1, "IOS": 0, "offset": {34359857632, "type": {"code": "Offset", "info": {"magnitude": {"code": "Integral", "info": {"size": 64, "signed_p": false}}, "unit": 1}}}}}, "type": {"code": "Struct", "info": {"name": "Test", "fields": [{"name": "a", "type": {"code": "Integral", "info": {"size": 8, "signed_p": false}}}, {"name": "b", "type": {"code": "Integral", "info": {"size": 8, "signed_p": false}}}]}}}
@trufae
trufae / vimrc
Last active August 23, 2022 19:45
pancake's vimrc
set cinoptions=p0,t0,:0,=8
set cindent
colorscheme desert
" peachpuff
set noexpandtab
set hlsearch
set nu
set mouse=a
sy on
@trufae
trufae / flashdump.js
Created January 3, 2022 09:59
flash hexdump for banglejs2
function loadMenu() {
var menuItems = {
"Open Flash": () => openFlash(),
"Open File": () => openFile(),
"Create File": () => createFile(),
"": {
value: ""
},
"About": {
@trufae
trufae / bangle-sketch.js
Created December 16, 2021 00:52
My first app for the Bangle watch. an app to draw stuff in your wrist
var pen = 'circle';
var discard = null;
var kule = [255, 255, 255];
function nextPen () {
kule[0] = Math.random();
kule[1] = Math.random();
kule[2] = Math.random();
console.log('CURPEN', pen, kule);
switch (pen) {
case 'circle': pen = 'pixel'; break;
@trufae
trufae / r2frida-agent.js
Last active December 14, 2021 11:44
r2frida-agent.js
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
exports.byteLength = u, exports.toByteArray = i, exports.fromByteArray = d;
for (var r = [], t = [], e = "undefined" != typeof Uint8Array ? Uint8Array : Array, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", o = 0, a = n.length; o < a; ++o) r[o] = n[o],
t[n.charCodeAt(o)] = o;
function h(r) {
var t = r.length;
$ r2 -i examples/test-py-asm.py -
[0x00000000]> e asm.arch=MyPyDisasm
[0x00000000]> pd 10
0x00000000 0000 opcode 0
0x00000002 0000 opcode 0
0x00000004 0000 opcode 0
0x00000006 0000 opcode 0
0x00000008 0000 opcode 0
0x0000000a 0000 opcode 0
0x0000000c 0000 opcode 0
@trufae
trufae / codetoken.c
Last active September 8, 2021 22:53
/* radare - LGPL - Copyright 2007-2021 - pancake */
#if 0
Very simple code parser in C
============================
Takes a string representing the code and runs a callback everytime a token is found
r_codetok ("string", callback, &userdata);
#endif
if [ -f ~/.vim/autoload/plug.vim ]; then
echo "fzf-vim already installed."
else
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
cat >> ~/.vimrc <<EOF
call plug#begin('~/.vim/plugged')
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
call plug#end()
command! -bang -nargs=* GGrep