Skip to content

Instantly share code, notes, and snippets.

View drrost's full-sized avatar

Rostyslav Druzhchenko drrost

  • Kharkiv, Ukraine
View GitHub Profile
@drrost
drrost / Package.swift
Last active May 5, 2021 11:05
_OBJC_METACLASS_$_XCTestCase issue package file
// swift-tools-version:5.3
import PackageDescription
let package = Package(
name: "ExtensionsFoundation",
products: [
.library(
name: "ExtensionsFoundation",
targets: ["ExtensionsFoundation"]),
#!/bin/bash
echo "Hello, script!" > /tmp/a.log
@drrost
drrost / git_push_origin.sh
Last active October 27, 2020 09:07
Make git push to a selected remote. Useful when you use more than one remote for a project.
# List all available remotes
git remote -v
# Push to a selected remote
git push <a name from the list above>
@drrost
drrost / find_text.sh
Created September 20, 2020 21:16
Searches for text in a directory recursively
cat $(find . -type f) | grep memcpy
void *callstack[128]; // 1
int frames = backtrace(callstack, 128); // 2
char **strs = backtrace_symbols(callstack, frames); // 3
static void *(*real_malloc)(unsigned long) = 0; // 1
int malloc_counter = 0; // 2
static void malloc_init(void) { // 3
real_malloc = (void *(*)(unsigned long))dlsym(RTLD_NEXT, "malloc");
if (real_malloc == 0)
fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
}
void *malloc(unsigned long size) { // 4
@drrost
drrost / leacks_cheker_ex.c
Last active April 4, 2024 17:08
Extended version of memory leaks checker. Shows the place where memory was allocated.
//
// Created by Rostyslav Druzhchenko on 05.09.2020.
//
#include <stdio.h>
#include <dlfcn.h>
#include <execinfo.h>
#include <string.h>
#include <stdlib.h>
@drrost
drrost / main.c
Last active September 13, 2020 10:50
Check leaks usage
void check_leaks();
int main(int argc, const char *argv[]) {
//...
check_leaks();
return 0;
}
@drrost
drrost / leaks_chekcer.c
Created September 13, 2020 10:39
Checking for leaks in C code
//
// Created by Rostyslav Druzhchenko on 05.09.2020.
//
#include <stdio.h>
#include <dlfcn.h>
int malloc_counter = 0;
// ================================== PUBLIC ==================================
@drrost
drrost / section.el
Created August 3, 2020 16:38
magit section color
M-x set-face-background
magit-section-highlight
red