Skip to content

Instantly share code, notes, and snippets.

@0xack13
0xack13 / fix_rbenv.md
Created April 8, 2023 17:44 — forked from esteedqueen/fix_rbenv.md
How to fix rbenv: version `x.x.x` is not installed

So, you just cloned an existing project's repo and you run bundle install but you got the error: rbenv: version x.x.x is not installed....

What the issue means? The project uses a specific ruby version that you do not have on your system.

Here's how to fix it:

  • Install the Ruby build for the specified version using:
rbenv install x.x.x
@0xack13
0xack13 / CGPoint+SIMD.swift
Created April 7, 2023 20:30 — forked from Dev1an/CGPoint+SIMD.swift
SIMD extensions for CGPoint and CGSize
import struct CoreGraphics.CGSize
import struct CoreGraphics.CGPoint
import struct CoreGraphics.CGFloat
extension CGSize: SIMD {
public typealias MaskStorage = SIMD2<CGFloat.NativeType.SIMDMaskScalar>
public subscript(index: Int) -> CGFloat {
get {
index == 0 ? width : height
@0xack13
0xack13 / bf.rs
Created April 5, 2023 23:28 — forked from ksurent/bf.rs
Toy Brainfuck interpreter in Rust.
fn main() {
let code = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.";
let mut bf = Bf::new(1000, false);
if let Err(err) = bf.execute(code) {
println!("{} at pos {}", err, bf.ip);
std::process::exit(1);
}
bf.reset();
@0xack13
0xack13 / fork-is-evil-vfork-is-good-afork-would-be-better.md
Created April 4, 2023 04:01 — forked from nicowilliams/fork-is-evil-vfork-is-good-afork-would-be-better.md
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou

@0xack13
0xack13 / ssadump.go
Created April 4, 2023 03:59 — forked from ksurent/ssadump.go
Print Go's SSA form, much like ssadump but with concrete types
package main
import (
"flag"
"fmt"
"go/build"
"go/types"
"os"
"golang.org/x/tools/go/loader"
@0xack13
0xack13 / _main.go
Created March 31, 2023 15:07 — forked from bored-engineer/_main.go
[Golang] PrefixReader (io.WriteCloser) wraps an io.Reader allowing data to be written ("prefixed") to the Reader which will be returned by subsequent Read calls until Close is called at which points all reads will pass-through to the underlying reader.
// THIS IS THE CORRECT SOLUTION, NOT WHAT WAS IN THIS GIST
package main
import (
"strings"
"io"
"io/ioutil"
"fmt"
)
@0xack13
0xack13 / concurrent_hit.py
Created March 27, 2023 09:03 — forked from rednafi/concurrent_hit.py
1000 concurrent API request with ThreadPoolExecutor Python
import time
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
import requests
from tqdm import tqdm
def timeit(method):
@wraps(method)
@0xack13
0xack13 / work-with-multiple-github-accounts.md
Created March 25, 2023 21:42 — forked from rahularity/work-with-multiple-github-accounts.md
How To Work With Multiple Github Accounts on your PC

How To Work With Multiple Github Accounts on a single Machine

Let suppose I have two github accounts, https://github.com/rahul-office and https://github.com/rahul-personal. Now i want to setup my mac to easily talk to both the github accounts.

NOTE: This logic can be extended to more than two accounts also. :)

The setup can be done in 5 easy steps:

Steps:

  • Step 1 : Create SSH keys for all accounts
  • Step 2 : Add SSH keys to SSH Agent
@0xack13
0xack13 / README.md
Created March 25, 2023 21:37 — forked from kwk/README.md
Forgot to sign-off commits?

No problem,

run

git filter-branch --msg-filter "cat - && echo && echo 'Signed-off-by: Your Name <[email protected]>'" HEAD~2..HEAD

To sign-off the last two commits.

Then force to push them to the remote repo with the -f option:

I have been carrying this Rakefile around between projects, that uses another file which reopens the FlogTask class and adds an attr_accessor to it, which the task definition in the Rakefile then uses.

This works but, as you can readily tell, it's less than ideal. In particular, the Rakefile defines multiple tasks which are the same for each project; the only change is usually the Flog threshold value.

What I want to be able to do is:

  1. Subclass a tool's standard Rake task (e.g., FlogTask). The subclass' #initialize method would then set up our standard settings as is presently done in the Rakefile;
  2. Define namespaced Rake tasks (in, e.g., lib/tasks/custom_flog.rake) that use those subclasses rather than the tool's standard Rake task; reducing boilerplate and possibility of copy/paste errors;
  3. Have those tasks be available in