Skip to content

Instantly share code, notes, and snippets.

View nverinaud's full-sized avatar

Nicolas VERINAUD nverinaud

View GitHub Profile
@code-twister
code-twister / Injection.kt
Last active March 18, 2022 09:06
Simple Kotlin Dependency Injection
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KClass
import kotlin.reflect.KProperty
/*
* Using the Injection framework:
*
* Create bindings somewhere in the application before the injections would occur.
*
* factory<MyInterface>(named = "specialName") { SomeImplementation() }
@nverinaud
nverinaud / gist:083f8cf1a1ff63bd4222
Created April 8, 2015 13:08
Xcode Regex to find all non-localized string.
(?<!(NSLocalizedString\(|NSLog\())@".*"
@steipete
steipete / FixUISearchDisplayController.m
Last active December 31, 2018 08:42
I fixed UISearchDisplayController for iOS 7. So. Much. Pain.
static UIView *PSPDFViewWithSuffix(UIView *view, NSString *classNameSuffix) {
if (!view || classNameSuffix.length == 0) return nil;
UIView *theView = nil;
for (__unsafe_unretained UIView *subview in view.subviews) {
if ([NSStringFromClass(subview.class) hasSuffix:classNameSuffix]) {
return subview;
}else {
if ((theView = PSPDFViewWithSuffix(subview, classNameSuffix))) break;
}
@fklingler
fklingler / Markdown Preview Bookmarklet
Created January 29, 2013 19:18
This bookmarklet gives you a markdown editor/previewer in your browser in a single click.
data:text/html, <script type="text/javascript" src="https://raw.github.com/MrMitch/downatello/develop/downatello.js"></script><style type="text/css">#md,#html{position:absolute;top:0;bottom:0;padding:5px;border:none;outline:none;font-family:monaco,consolas,sans-serif;font-size:1em}#md{resize:none;left:0;right:50%;border-right:1px solid black}#html{left:50%;right:0;font-family:sans-serif}</style><textarea id="md" oninput="document.getElementById('html').innerHTML=downatello.toHtml(document.getElementById('md').value);"></textarea><div id="html"></div>
@caruccio
caruccio / bash-path-vars
Last active December 28, 2023 22:47
Path manipulation with bash vars
$ FILE=/some/path/to/file.txt
###################################
### Remove matching suffix pattern
###################################
$ echo ${FILE%.*} # remove ext
/some/path/to/file
$ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts
@nverinaud
nverinaud / gist:3706079
Created September 12, 2012 11:33
Git workflow: project with libraries
# Add a library
$ git remote add -f lib/[libname] [lib-remote-URL] # Add the lib remote and fetch
$ git read-tree --prefix=lib/[libname]/ -u lib/[libname]/master # Import the library files
$ git commit -m "Add [libname] library." # Commit the added library
$ git push # We're done !
# Update to the latest version of a library
$ git pull -s subtree --squash --no-commit lib/[libname] master # Update files of the library