Skip to content

Instantly share code, notes, and snippets.

View hectr's full-sized avatar

Hèctor M. R. hectr

  • Barcelona, Spain
View GitHub Profile
@hectr
hectr / NSObject+mr_mock_method.h
Last active August 29, 2015 14:27
Mock Objective-C method with a block
// Copyright (c) 2015, Héctor Marqués
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// Copyright (c) 2015, Héctor Marqués
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
@hectr
hectr / MRManagedObjectContext.h
Created August 20, 2015 00:33
Core Data stack with read-only main context
// Copyright (c) 2013, Héctor Marqués
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
@hectr
hectr / git-cdc
Created January 1, 2017 18:31
Changes author and commit dates of a commit.
#!/bin/bash
# commit
# date YYYY-mm-dd HH:MM:SS
################################################################################
#
# Changes author and commit dates of a commit.
#
# Warning:
# For OS X you may also install GNU coreutils (brew install coreutils), add it
@hectr
hectr / git-conflict
Last active January 1, 2017 18:33
Checks if a branch can be automatically merged into current branch.
#!/bin/bash
# branch
################################################################################
#
# Checks if a branch can be automatically merged into current branch.
#
# Example:
# ./git conflict develop
#
@hectr
hectr / iPhone 5s
Last active January 1, 2017 18:38
Opens iPhone simulator.
#! /bin/bash
################################################################################
#
# Opens in iPhone simulator named after this file (e.g. if you want the iPhone 5
# simulator, rename this file to "iPhone 5").
#
# Examples:
#
# Usage without parameters: ./iPhone\ 5s
@hectr
hectr / random_string
Last active January 1, 2017 18:38
Returns random string of length 32.
#! /bin/bash
################################################################################
#
# Returns random string of length 32.
#
# Example:
# ./random_string
#
################################################################################
@hectr
hectr / .gitconfig
Last active October 16, 2018 20:34
Git config file
[user]
# TODO: set name and email
#name = <name>
#email = <email>
excludesfile = ~/.gitignore_global
editor = vim
[merge]
tool = Kaleidoscope
[mergetool]
prompt = false
@hectr
hectr / utf8.c
Created March 2, 2018 04:57 — forked from stanislaw/utf8.c
Some C functions to work with UTF-8 string : you can check if a string is valid UTF-8, get the length of a UTF-8 string and replace things in a UTF-8 string. All `char *` arguments must be regular, null-byte terminated, C strings. I've tried to optimize the best I could. I'd be grateful for any suggestions or improvements. Please note I have onl…
//
// utf8.c
// training
//
// Created by Conrad Kleinespel on 5/27/13.
// Copyright (c) 2013 Conrad Kleinespel. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@hectr
hectr / gist:55890ac2e1a24b683d02ecc1e695ea53
Created March 2, 2018 17:00 — forked from Madsy/gist:1088393
Fixedpoint versions of ln, pow, exp, sqrt and division
/*
Copyright (c) 2011, Mads A. Elvheim
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the