Skip to content

Instantly share code, notes, and snippets.

View loderunner's full-sized avatar
👨‍💻
𝚌𝚘𝚍𝚎 𝚕𝚒𝚏𝚎

Charles Francoise loderunner

👨‍💻
𝚌𝚘𝚍𝚎 𝚕𝚒𝚏𝚎
View GitHub Profile
#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
#define ACCESS_TO_STAT(mask, user_mask) (((((mask)&R_OK)?S_IRUGO:0)|(((mask)&W_OK)?S_IWUGO:0)|(((mask)&X_OK)?S_IXUGO:0))&(user_mask))
#define STAT_TO_ACCESS(mode, user_mask) ((((mode)&(user_mask)&S_IRUGO)?R_OK:0)|(((mode)&(user_mask)&S_IWUGO)?W_OK:0)|(((mode)&(user_mask)&S_IXUGO)?X_OK:0))
// Usage: ACCESS_TO_STAT(R_OK | W_OK | X_OK, S_IRWXU) => 0700
// ACCESS_TO_STAT(R_OK | W_OK, ACCESSPERMS) => 0666
// ACCESS_TO_STAT(X_OK, S_IRWXU|S_IRWXO) => 0101
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
#define ACCESS_TO_STAT(mask, user_mask) (((((mask)&R_OK)?S_IRUGO:0)|(((mask)&W_OK)?S_IWUGO:0)|(((mask)&X_OK)?S_IXUGO:0))&(user_mask))
#define STAT_TO_ACCESS(mode, user_mask) ((((mode)&(user_mask)&S_IRUGO)?R_OK:0)|(((mode)&(user_mask)&S_IWUGO)?W_OK:0)|(((mode)&(user_mask)&S_IXUGO)?X_OK:0))
#ifndef TROLOLOL_H
#define TROLOLOL_H
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
echo -n This file system is case- > tmp; echo -n in >> TMP; echo sensitive >> tmp; cat tmp; rm tmp; rm TMP 2> /dev/null
//
// fs_capabilities.m
//
// Created by Charles Francoise on 13/05/14.
// Copyright (c) 2014 Charles Francoise. All rights reserved.
//
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#!/usr/bin/python
# usage: sudo dtruss -a command 2>&1 > /dev/null | ./dtruss2csv.py > dtruss.log.csv
import re
import sys
if (len(sys.argv) > 1):
s = file(sys.argv[1], 'r').read()
else:
s = sys.stdin.read()
@loderunner
loderunner / flac2mp3.sh
Last active August 29, 2015 14:01
Converts all flac files in the directory to high-quality mp3
#!/bin/sh
# Converts all flac files in the directory to high-quality mp3
for flacfile in *.flac
do
flac --decode "$flacfile"
wavfile="${flacfile:0:(${#flacfile}-4)}wav"
lame -b320 -q0 -ms "$wavfile"
rm "$wavfile"
done
/*
FUSE: Filesystem in Userspace
Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
This program can be distributed under the terms of the GNU GPL.
See the file COPYING.
*/
/*
@loderunner
loderunner / pid2name.c
Created July 24, 2014 09:48
Retrieve process name from pid using sysctl (Darwin)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/sysctl.h>
int main(int argc, char** argv) {
int mib[3], argmax;
size_t syssize;
char *procargs, *cp, *thiscmd;
@loderunner
loderunner / getbroadaddr.c
Last active April 2, 2017 03:13
get broadcast address for an interface
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <net/if.h>
#include <netdb.h>