Skip to content

Instantly share code, notes, and snippets.

View matthiaswenz's full-sized avatar
:octocat:

Matthias Wenz matthiaswenz

:octocat:
  • Germany
  • 03:39 (UTC +02:00)
View GitHub Profile
@matthiaswenz
matthiaswenz / SHA1FromFile.m
Created December 20, 2011 11:46
SHA1FromFile
#import <CommonCrypto/CommonDigest.h>
@implementation SHA1FromFile
+ (NSString *)sha1FromFileAtPath:(NSString *)path {
CFReadStreamRef readStream = CFReadStreamCreateWithFile(kCFAllocatorDefault, CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
(CFStringRef)path,
kCFURLPOSIXPathStyle,
(Boolean)false));
/*
Calculation to center diagonal separator:
new width of the :before-element after the rotation (Pythagoras) = 25.46px
add space to the right to visual center diagonal line: 25,46px / 2 = 12.73px
total amount for A: 25.46px + 12.73px = 38.19px
revise position of B: ( 25.46px - 18px ) / 2 = 3.73px;
change gap by adding half amount to B (+9px) than to A (+18px)
slightly change for visual perfection
@matthiaswenz
matthiaswenz / NSDictionary+Localized.h
Last active December 13, 2015 22:19
A simple category on NSDictionary which allows localized values for string-based keys, built for @bowstreet. License: MIT - go on, have fun with it, but don't expect anything from us. You might ask politely, though - we're a nice bunch.
#import <Foundation/Foundation.h>
@interface NSDictionary (Localized)
- (id)localizedValueForKey:(NSString *)aKey;
- (id)localizedValueForKey:(NSString *)aKey withLanguage:(NSString *)aLanguage;
@end
@matthiaswenz
matthiaswenz / user.css
Last active December 18, 2015 17:59
User Stylesheet entry to make 37signals' launchbar in Basecamp (BCX) a little easier on the eyes.
#launchbar {
opacity: 0.1;
-webkit-transition: opacity .2s ease-in-out;
-moz-transition: opacity .2s ease-in-out;
transition: opacity .2s ease-in-out;
}
#launchbar:hover {
opacity: 1.0;
@matthiaswenz
matthiaswenz / gist:8088229
Last active January 1, 2016 03:49
UISearchBar customize Keyboard Return button type (iOS 7)
for (UIView *subview in searchBar.subviews) {
for (UIView *subSubview in subview.subviews) {
if ([subSubview conformsToProtocol:@protocol(UITextInputTraits)]) {
UIView<UITextInputTraits> *textInputField = (UIView<UITextInputTraits> *)subSubview;
textInputField.returnKeyType = UIReturnKeyDone;
break;
}
}
}

Keybase proof

I hereby claim:

  • I am ranterle on github.
  • I am ranterle (https://keybase.io/ranterle) on keybase.
  • I have a public key whose fingerprint is A29F C4DF B112 69A7 88E7 B568 51F8 5115 BFDA 44B8

To claim this, I am signing this object:

# encoding: utf-8
xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
page_count = 0
sitemap.resources.each do |page|
catch :next_page do
# Exclude images, metadata, config, ...
throw :next_page if page.url.start_with?('/images/')
@matthiaswenz
matthiaswenz / gist:e221fc854e193cc82edd
Created November 27, 2014 19:06
Find apps supporting your URL scheme in Android
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData("mycustomscheme://test");
PackageManager manager = context.getPackageManager();
List<ResolveInfo> resolvedActivites = manager.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
if (!resolvedActivities.isEmpty()) {
// ... someone responds to the scheme
} else {
// ... nobody does
}
@matthiaswenz
matthiaswenz / SignInAction.java
Created June 18, 2015 13:33
Base Action subclass for IntelliJ plugin
public class SignInAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent event) {
Project project = event.getProject();
// do your sign in work...
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(!isAuthenticated());
@matthiaswenz
matthiaswenz / plugin.xml
Last active August 29, 2015 14:23
Simple IntelliJ plugin descriptor
<idea-plugin version="2">
<id>com.example.yourPluginID</id>
<name>A simple demo plugin</name>
<description>This is just a simple demo plugin with no other purpose</description>
<version>1.0</version>
<vendor url="http://www.ranterle.de">ranterle</vendor>
<idea-version since-build="135.1"/>
<depends>com.intellij.modules.java</depends>