This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef TROLOLOL_H | |
#define TROLOLOL_H | |
#ifdef TRUE | |
#undef TRUE | |
#endif | |
#ifdef FALSE | |
#undef FALSE | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo -n This file system is case- > tmp; echo -n in >> TMP; echo sensitive >> tmp; cat tmp; rm tmp; rm TMP 2> /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
QApplication qapp(argc, argv); | |
{ | |
QNetworkConfigurationManager manager; | |
QList<QNetworkConfiguration> configs(manager.allConfigurations()); | |
QNetworkConfiguration config; | |
foreach (config, configs) | |
{ | |
NSString* type; | |
switch (config.type()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer