Skip to content

Instantly share code, notes, and snippets.

@serg-z
serg-z / usbreset.c
Created June 2, 2015 08:21
usbreset -- send a USB port reset to a USB device
/* usbreset -- send a USB port reset to a USB device */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
@serg-z
serg-z / erun
Created April 3, 2014 04:43
Note - expect test
#!/bin/bash
echo testo?
read VAR
echo password?
read VV
echo ">$VAR"
echo ">$VV"
@serg-z
serg-z / filter-branch-author-email
Created January 31, 2014 00:58
Rewrite commit history author & email (filter-branch)
#!/bin/bash
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "user.name before" ];
then
GIT_COMMITTER_NAME="user.name after";
GIT_AUTHOR_NAME="user.name after";
GIT_COMMITTER_EMAIL="user.mail after";
GIT_AUTHOR_EMAIL="user.mail after";
git commit-tree "$@";
@serg-z
serg-z / get_platform_uuid
Last active December 31, 2015 01:09
UUID on OS X
void get_platform_uuid(char *buf, int bufSize)
{
io_registry_entry_t ioRegistryRoot = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
CFStringRef uuidCf = (CFStringRef) IORegistryEntryCreateCFProperty(ioRegistryRoot, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0);
IOObjectRelease(ioRegistryRoot);
CFStringGetCString(uuidCf, buf, bufSize, kCFStringEncodingMacRoman);
CFRelease(uuidCf);
}