Skip to content

Instantly share code, notes, and snippets.

View ytlvy's full-sized avatar

Yt ytlvy

View GitHub Profile
.section __TEXT,__text,regular,pure_instructions
.globl _insert
.align 4, 0x90
_insert: ## @insert
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp2:
.cfi_def_cfa_offset 16
Ltmp3:
@ytlvy
ytlvy / gist:43ffa864bd72ce898c84
Created January 5, 2016 04:34
Example of copyfile() progress via COPYFILE_STATE_COPIED
#include "copyfile.h"
typedef enum {
_NotStarted = 0,
_InProgress,
_Finished,
} _State;
@implementation BAVAppDelegate
{
@ytlvy
ytlvy / make_cert.sh
Created January 4, 2016 02:09 — forked from m1entus/make_cert.sh
Generating apple push notifications
#!/bin/sh
if [ "$#" != 3 ]; then
echo "Illegal number of parameters, usage: ./make_cert.sh apn_file key_file output_filename"
fi
eval "openssl x509 -in $1.cer -inform DER -out $1.pem -outform PEM"
eval "openssl pkcs12 -nodes -export -inkey $2.key -in $1.pem -out $1.p12"
eval "openssl pkcs12 -nodes -nocerts -out $2.pem -in $1.p12"
eval "cat $1.pem $2.pem > $3.pem"
@ytlvy
ytlvy / aes128.m
Created January 4, 2016 02:09 — forked from m1entus/aes128.m
AES128 endryption
- (NSData *)AES128EncryptWithData:(NSData *)data {
NSUInteger dataLength = [self length];
//See the doc: For block ciphers, the output size will always be less than or
//equal to the input size plus the size of one block.
//That's why we need to add the size of one block here
size_t bufferSize = dataLength + kCCBlockSizeAES128;
void *buffer = malloc(bufferSize);
@ytlvy
ytlvy / build-ffmpeg.sh
Created January 4, 2016 02:08 — forked from m1entus/build-ffmpeg.sh
Installing ffmpeg ios libraries armv7, armv7s, i386
#!/bin/bash
###########################################################################
# Choose your ffmpeg version and your currently-installed iOS SDK version:
#
VERSION="2.0.2"
SDKVERSION="7.0"
ARCHS="armv7 armv7s i386"
#
#
@ytlvy
ytlvy / signal_handlers.cpp
Created December 17, 2015 08:28
#signal #cpp #linux
//
// Example of linux signal handlers
//
// Authored by Daniel Shih <[email protected]>
//
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ytlvy
ytlvy / test_access.c
Created December 17, 2015 08:26 — forked from phoeagon/test_access.c
Test whether memory can be accessed
#define _GNU_SOURCE
#include <stdio.h>
#include <udis86.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <ucontext.h>
#include <execinfo.h>
#include <setjmp.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
void
segv() // <--- never gets called
{
fprintf(stderr, "segv\n");
exit(0);
@ytlvy
ytlvy / TableViewCell.m
Created November 13, 2015 10:33
iOS 8 workaround for no inset in UITableViewCell separator
// No separator insets
self.separatorInset = UIEdgeInsetsZero;
if ([self respondsToSelector:@selector(layoutMargins)]) {
self.layoutMargins = UIEdgeInsetsZero;
}
@ytlvy
ytlvy / TimerWithGCD.md
Created November 13, 2015 10:31
Creating a timer with Grand Central Dispatch

##Creating a timer with Grand Central Dispatch

At the following is the implementation file of a sample class that shows, how to make a timer with the help of Grand Central Dispatch. The timer fires on a global queue, just change the queue to the main queue or any custom queue and the timer fires on this queue and not on the global queue anymore.

#import <Foundation/Foundation.h>

@interface SampleClass : NSObject
- (void)startTimer;