Skip to content

Instantly share code, notes, and snippets.

View revolter's full-sized avatar

iulianOnofrei (U-lee-aan) revolter

View GitHub Profile
struct Regex {
let pattern: String
let options: NSRegularExpressionOptions
private var matcher: NSRegularExpression {
return try! NSRegularExpression(pattern: pattern, options: options)
}
init(pattern: String, options: NSRegularExpressionOptions! = nil)
{
@wrzlbrmft
wrzlbrmft / gimp-snap-to-canvas-edges.txt
Created February 2, 2016 20:41
GIMP: Enable "Snap to Canvas Edges" for all images by default.
# ~/.gimp-*/gimprc
(default-snap-to-canvas yes)
@a13xb
a13xb / Podfile
Created January 11, 2016 12:21
Quick workaround for per-target asset catalog compilation using a Podfile post_install hook
# ...
# Workaround for https://github.com/CocoaPods/CocoaPods/issues/1546
post_install do |installer|
installer.aggregate_targets.each do |at|
files = at.user_targets.map{|t|
t.resources_build_phase.files_references.select{|f|
f.last_known_file_type == 'folder.assetcatalog'
}.map{|f|
Pathname.new(f.real_path).relative_path_from(f.project.path.dirname)
@loisaidasam
loisaidasam / mktmpenv.txt
Last active December 7, 2021 07:26
TIL how to make a temporary virtualenv - thanks @hery!
$ mktmpenv
New python executable in tmp-f4732394b48189f9/bin/python
Installing setuptools............done.
Installing pip...............done.
This is a temporary environment. It will be deleted when you run 'deactivate'.
(tmp-f4732394b48189f9) sallah:~/.virtualenvs/tmp-f4732394b48189f9$ deactivate
Removing temporary environment: tmp-f4732394b48189f9
Removing tmp-f4732394b48189f9...
@PurpleBooth
PurpleBooth / README-Template.md
Last active May 28, 2024 08:25
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@cameronmaske
cameronmaske / encode.py
Last active February 5, 2024 19:16
base64 that actually encodes URL safe (no '=' nonsense)
"""
base64's `urlsafe_b64encode` uses '=' as padding.
These are not URL safe when used in URL paramaters.
Functions below work around this to strip/add back in padding.
See:
https://docs.python.org/2/library/base64.html
https://mail.python.org/pipermail/python-bugs-list/2007-February/037195.html
"""
@Antol
Antol / APAspectFitImageView.h
Created October 16, 2014 21:29
UIImageView with aspect fit working with autolayout
//
// APAspectFitImageView.h
// autolayout
//
// Created by Antol Peshkov on 16.10.14.
// Copyright (c) 2014 Antol Peshkov. All rights reserved.
//
#import <UIKit/UIKit.h>
@othiym23
othiym23 / npm-upgrade-bleeding.sh
Created September 20, 2014 19:36
a safe way to upgrade all of your globally-installed npm packages
#!/bin/sh
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
do
npm -g install "$package"
done
@nicklockwood
nicklockwood / Deprecated.md
Last active March 28, 2022 08:16
Writing Objective-C framework code that works on multiple OS versions AND can be compiled using multiple SDK versions without warnings can be a PITA. Here's my approach:

Suppose we want to add support for a new iOS 8 API in our framework that replaces an older iOS 7 API. There are a few problems we might face:

  1. The new API will crash if we call it on iOS 7
  2. The new API won't compile if we build it using the iOS 7 SDK
  3. The old API will raise a deprecation warning if built with a deployment target of iOS 8 and up

These three problems require three different technical solutions:

  1. We can avoid calling the new API on an old OS version by using runtime detection (e.g. respondsToSelector:)
  2. We can avoid compiling new APIs on old SDKs using the __IPHONE_OS_VERSION_MAX_ALLOWED macro
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote