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
#!/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
CREATE DEFINER = CURRENT_USER TRIGGER `task`.`user_AFTER_INSERT`
AFTER INSERT ON `user` FOR EACH ROW
INSERT INTO `task`.`event` SET `type` = 'create',
`user_id` = NEW.`id`,
`timestamp` = NULL,
`created_at` = NULL,
`modified_at` = NULL;
CREATE DEFINER = CURRENT_USER TRIGGER `task`.`user_AFTER_UPDATE`
AFTER UPDATE ON `user` FOR EACH ROW
QApplication qapp(argc, argv);
{
QNetworkConfigurationManager manager;
QList<QNetworkConfiguration> configs(manager.allConfigurations());
QNetworkConfiguration config;
foreach (config, configs)
{
NSString* type;
switch (config.type())
// GetHostName.c
//
// Prints current host's name in localized, human-readable format to stdout
//
// Compile using:
// cc -framework SystemConfiguration -framework CoreFoundation -o GetHostName GetHostName.c
//
#include <SystemConfiguration/SystemConfiguration.h>
@loderunner
loderunner / change_install_path.sh
Created February 12, 2015 17:32
Change ids and install paths relative to @executable_path
USER_PREFIX=/Users
LOADER_PATH_PREFIX=@loader_path
for f in *.dylib; do
old_install_path="$(otool -D "$f" | sed '2q;d' | grep -E "$USER_PREFIX|$LOADER_PATH_PREFIX")"
if [ -n "$old_install_path" ]; then
new_install_path="$(sed -E "s%($USER_PREFIX|$LOADER_PATH_PREFIX).*%@executable_path/../Frameworks/%" <<< "$old_install_path")""$(basename "$old_install_path")"
echo "$old_install_path -> $new_install_path"
install_name_tool -id "$new_install_path" "$f"
fi
for old_install_path in $(otool -L "$f" | grep -E "$USER_PREFIX|$LOADER_PATH_PREFIX" | awk '{print $1}'); do