Skip to content

Instantly share code, notes, and snippets.

View loderunner's full-sized avatar
πŸ‘¨β€πŸ’»
πšŒπš˜πšπšŽβ€‚πš•πš’πšπšŽ

Charles Francoise loderunner

πŸ‘¨β€πŸ’»
πšŒπš˜πšπšŽβ€‚πš•πš’πšπšŽ
View GitHub Profile
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
@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>
@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;
/*
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 / 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
#!/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()
//
// 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>
echo -n This file system is case- > tmp; echo -n in >> TMP; echo sensitive >> tmp; cat tmp; rm tmp; rm TMP 2> /dev/null
#ifndef TROLOLOL_H
#define TROLOLOL_H
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
#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))