Skip to content

Instantly share code, notes, and snippets.

@aktau
aktau / hello64.s
Last active August 29, 2015 14:07
Hello world and printing numbers a few times
; also see an alternative: http://lpaste.net/111802
; rdi = the number (integer) to print
; prints a number as hex (basically the easy way out)
printnum:
push r13
push r14
push r15
; save the argument because we're going to use it to pass an argument to
@aktau
aktau / fs-read-method-bench.cpp
Created September 18, 2014 04:53
benchmark fread/read/mmap/std::streams
// @aktau: this is not my file, I tried to find the original article this was from but couldn't, I'm pasting it here for posterity
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/uio.h>
@aktau
aktau / cntchr.c
Created September 4, 2014 15:32
cntchr function
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
size_t cntchr(const char *str, char value) {
size_t count = 0;
while ((str = strchr(str, value)) != NULL) {
++str;
++count;
}
@aktau
aktau / strcjoinv.c
Created August 31, 2014 21:11
neovim: path building API tryouts
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdarg.h>
#define MAXPATHL 128
/// like `strcat`, but returns a pointer to the '\0' terminator of rht
/// resulting string.
@aktau
aktau / 32.asm
Created August 31, 2014 09:01 — forked from desertmonad/32.asm
; /usr/local/bin/nasm -f macho 32.asm && ld -macosx_version_min 10.7.0 -o 32 32.o && ./32
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The .data section is for storing and naming constants.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
section .data
msg: db "Hello world!", 10
.len: equ $ - msg
@aktau
aktau / palignr.c
Created August 28, 2014 15:23
How does the SSSE3 PALIGNR instruction work?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <x86intrin.h>
/* void palignr(const __m128i a, const __m128i b, const int offset) { */
#define palignr(a, b, offset) { \
char *buf = calloc(sizeof(__m128i) + 1, 1); \
__m128i res = _mm_alignr_epi8(a, b, offset); \
@aktau
aktau / osx1094_memmove_ivybridge.s
Last active August 29, 2015 14:05
libsystem_platform.dylib memcpy dump, OSX 10.9.4
# seems to delegate to the Nehalem variant, but with some different
# constants to jump directly to relevant parts inside of the function
0000000000003fa0 <__platform_memmove$VARIANT$Ivybridge>:
3fa0: 55 push %rbp
3fa1: 48 89 e5 mov %rsp,%rbp
3fa4: 49 89 fb mov %rdi,%r11
3fa7: 49 29 f3 sub %rsi,%r11
3faa: 48 89 f8 mov %rdi,%rax
3fad: 49 39 d3 cmp %rdx,%r11
3fb0: 0f 82 44 00 00 00 jb 3ffa <__platform_memmove$VARIANT$Nehalem+0x1a>
@aktau
aktau / tinytee.c
Created August 8, 2014 08:03
tinytee.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#if defined(__GNUC__)
#include <stdint.h>
#include <cpuid.h>
#elif defined(_WIN32)
#include <intrin.h>
typedef unsigned __int32 uint32_t;
#endif
#include <stdio.h>
/**

How to connect a PS3 controller to a different machine (PS3, Mac, PC)

You will need a Mini USB cable. Overcome your laziness and go get one!

A big misconception is that keep holding PS button will reset the controller's pairing. It doesn't! From my testing, the controller pairs with the last machine it was CONNECTED VIA A USB CABLE.

Here are the real Steps:

  1. Turn OFF your PS3 controller by either...