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
// Content source: https://medium.com/@oleavr/diy-kernel-panic-os-x-and-ios-in-10-loc-c250d9649159 | |
// HN thread: https://news.ycombinator.com/item?id=9085536 | |
#include <unistd.h> | |
#include <mach/mach.h> | |
#include <mach-o/dyld.h> | |
extern kern_return_t mach_vm_protect(vm_map_t, mach_vm_address_t, mach_vm_size_t, | |
boolean_t, vm_prot_t); |
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
// | |
// AppDelegate.swift | |
// emailRegexTest | |
// | |
// Created by <#Stan Serebryakov#> on 20/02/15. | |
// | |
import UIKit | |
@UIApplicationMain |
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
// | |
// Created by Stan Serebryakov on 03/02/15. | |
// | |
import UIKit | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? |
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
. |
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
// Updated to Swift 1.2 and CocoaLumberjack 2.0.0-rc by Stan Serebryakov on 2015-02-16 | |
import Foundation | |
extension DDLog { | |
private struct State { | |
static var logLevel: DDLogLevel = .Error | |
static var logAsync: Bool = true | |
} |
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
use std::hashmap::HashMap; | |
fn main() { | |
// create a hashmap | |
let mut hm = HashMap::new(); | |
hm.insert(~"foo", 10); | |
hm.insert(~"bar", 23); | |
hm.insert(~"baz", 99); | |
hm.insert(~"meh", 2); | |
hm.insert(~"muh", -13); |
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
#define printf_dec_format(x) _Generic((x), \ | |
char: "%c", \ | |
signed char: "%hhd", \ | |
unsigned char: "%hhu", \ | |
signed short: "%hd", \ | |
unsigned short: "%hu", \ | |
signed int: "%d", \ | |
unsigned int: "%u", \ | |
long int: "%ld", \ | |
unsigned long int: "%lu", \ |
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
typedef void (^OpCompletionEither)(BOOL success); | |
- (void)sequence:(NSArray *)selectors | |
withFinalBlock:(OpCompletionEither)block { | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
__block OpCompletionEither _block = block; | |
SEL selector = NSSelectorFromString(selectors[0]); | |
if (selectors.count == 1) | |
// last request, perform reply block |
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 System.Random (randomRIO) | |
replies = ["Yes", "Signs point to yes", "It is certain", "It is decidedly so", "Without a doubt" | |
, "Yes, definitely", "You may rely on it", "As I see it yes", "Most likely", "Outlook good" | |
, "Reply hazy try again", "Ask again later", "Better not tell you now", "Cannot predict now" | |
, "Concentrate and ask again", "Don't count on it", "My reply is no", "My sources say no" | |
, "Outlook not so good", "Very doubtful"] | |
randomElem [] = error "Empty list" | |
randomElem xs = randomRIO (0, length xs - 1) >>= return . (xs !!) |
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
#include <vector> | |
#include <iostream> | |
#include <cstdlib> | |
#include <ctime> | |
int main() | |
{ | |
std::vector<std::string> v; | |
v.push_back("Yes"); |