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
- (void)scrollViewDidScroll:(UIScrollView *)sender { | |
BOOL isScrollingRight = _scrollView.contentOffset.x > _previousContentOffsetX; | |
_mostRecentScrollWasRight = isScrollingRight; | |
_previousContentOffsetX = _scrollView.contentOffset.x; | |
CGFloat pageWidth = _scrollView.frame.size.width; | |
int scrollingToPageNum = isScrollingRight ? (ceil((_scrollView.contentOffset.x - pageWidth) / pageWidth) + 1) : (floor((_scrollView.contentOffset.x -pageWidth) / pageWidth) + 1); | |
int percentOfScrollToPageOnscreen = isScrollingRight ? floor((((int)_scrollView.contentOffset.x % (int)pageWidth) / pageWidth)*100) |
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
/* Copied, Pasted and summarized from ps' source code. | |
You can use sysctl to get other process' argv. | |
*/ | |
#include <sys/sysctl.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#define pid_of(pproc) pproc->kp_proc.p_pid |
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
#import "NetworkMonitor.h" | |
NSString *NetworkConfigurationDidChangeNotification = @"NetworkConfigurationDidChangeNotification"; | |
void storeCallback(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info) { | |
[(NetworkMonitor *)info update]; | |
} | |
@implementation NetworkMonitor |
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/sbin/dtrace -C -s | |
#pragma D option quiet | |
proc::posix_spawn:exec-success,proc::__mac_execve:exec-success | |
{ | |
this->isx64=(curproc->p_flag & P_LP64)!=0; | |
#define SELECT_64_86(x64, x86) (this->isx64 ? (x64) : (x86)) | |
#define GET_POINTER(base, offset) (user_addr_t)SELECT_64_86(*(uint64_t*)((base)+sizeof(uint64_t)*(offset)), *(uint32_t*)((base)+sizeof(uint32_t)*(offset))) |
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 | |
### | |
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer) | |
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos | |
### | |
# Alot of these configs have been taken from the various places | |
# on the web, most from here | |
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx |
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
#import <libproc.h> | |
#import <stdlib.h> | |
#import <stdio.h> | |
int main( int argc, const char * argv[]) | |
{ | |
pid_t * pids = calloc(0x4000, 1); | |
int count = proc_listallpids(pids, 0x4000); | |
printf("count=%u\n", count) ; |
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
// task_for_pid leak | |
// **IMPORTANT** To reproduce this bug, you have to sign this program with a developer ID -- do not use a self-signed certificate or run as root! | |
// This code will cause taskgated's memory usage to grow (see activity monitor) | |
// Link to Xcode project with included info.plist: http://tinyurl.com/kps28av | |
// Radar 16230826 | |
#include <mach/mach_init.h> | |
#include <mach/task.h> | |
#include <mach/mach_port.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
; /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 |
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
// | |
// main.swift | |
// mutablecomposition | |
// | |
// Created by Kevin Meaney on 24/08/2015. | |
// Copyright (c) 2015 Kevin Meaney. All rights reserved. | |
// | |
import Foundation |
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
# View on GitHub: https://github.com/sharplet/Switch | |
# Try it yourself: git clone https://github.com/sharplet/Switch.git && cd Switch && rake | |
$ rake | |
mkdir -p Build | |
mkdir -p Build/Switch.framework | |
mkdir -p Build/Switch.framework/Versions/A/Modules/Switch.swiftmodule | |
ln -sf A Build/Switch.framework/Versions/Current | |
ln -sf Versions/Current/Modules Build/Switch.framework/Modules | |
ln -sf Versions/Current/Switch Build/Switch.framework/Switch | |
xcrun -sdk macosx swiftc -module-name Switch -emit-library -o Build/Switch.framework/Versions/Current/Switch -- Source/Array+Ext.swift Source/Option.swift Source/ParseResult.swift Source/Parser.swift Source/String+Ext.swift |
OlderNewer