Skip to content

Instantly share code, notes, and snippets.

@tprochazka
tprochazka / WidthEvaluator.java
Created May 10, 2012 19:45
How to animate width of any View
import android.animation.IntEvaluator;
import android.view.View;
import android.view.ViewGroup;
public final class WidthEvaluator extends IntEvaluator {
private final View view;
public WidthEvaluator(View dashboard) {
this.view = dashboard;
@cihancimen
cihancimen / string_contains_emoji
Created November 26, 2012 00:54
Check if an NSString contains an emoji character
- (BOOL)stringContainsEmoji:(NSString *)string {
__block BOOL returnValue = NO;
[string enumerateSubstringsInRange:NSMakeRange(0, [string length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
const unichar hs = [substring characterAtIndex:0];
// surrogate pair
if (0xd800 <= hs && hs <= 0xdbff) {
if (substring.length > 1) {
const unichar ls = [substring characterAtIndex:1];
@zrxq
zrxq / gist:5362898
Last active December 16, 2015 02:29
contentCenter CGRect for a CALayer from a resizable UIImage (resizableImageWithCapInsets)
inline static CGRect CGRectCenterRectForResizableImage(UIImage *image) {
return CGRectMake(image.capInsets.left/image.size.width, image.capInsets.top/image.size.height, (image.size.width-image.capInsets.right-image.capInsets.left)/image.size.width, (image.size.height-image.capInsets.bottom-image.capInsets.top)/image.size.height);
}
@CVertex
CVertex / export-devices.js
Created May 27, 2013 09:25
Extract UDIDs and Device names from Apple dev portal
// open the devices portal and run this in chrome console
var rows = $('#grid-table tr');
rows.each(function(i,val) {
var udid = $(val).find('td[aria-describedby=grid-table_deviceNumber]').html();
var name = $(val).find('td[aria-describedby=grid-table_name]').html();
console.log(udid + '\t' + name);
});
@pixnbit
pixnbit / CIFaceFeature+UIImageOrientation.h
Last active May 3, 2018 01:59
Category on CIFaceFeature to convert CGPoint and CGRect with respect to UIImageOrientation, also with handy helpers to convert locations inside of a given UIView size.
//
// CIFaceFeature+UIImageOrientation.h
//
//
// Created by Xiaochao Yang on 6/9/13.
// Copyright (c) 2013 Xiaochao Yang. All rights reserved.
//
#import <CoreImage/CoreImage.h>
@anth-3
anth-3 / passThruProxy.cs
Last active April 24, 2019 11:18
Defines a simple pass-through proxy interface for C#.NET (IIS) Server applications and web sites.
<%@ WebHandler Language="C#" Class="PassThruProxy" Debug="true" %>
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Web;
/**
* <summary><c>PassThruProxy</c> is a simple pass-through proxy interface for C#.NET (IIS Servers).</summary>
@aprato
aprato / AMPNavigationBar.m
Last active July 13, 2018 00:23
Darker iOS7 translucent UINavigationBar
// .h
@interface AMPNavigationBar : UINavigationBar
@property (nonatomic, assign) CGFloat extraColorLayerOpacity UI_APPEARANCE_SELECTOR;
@end
// .m
@indyfromoz
indyfromoz / Alter-Collation.sql
Created October 31, 2013 05:34
Alter the collation of a SQL database
USE master;
GO
ALTER DATABASE MyOptionsTest
COLLATE French_CI_AS ;
GO
--Verify the collation setting.
SELECT name, collation_name
FROM sys.databases
WHERE name = N'MyOptionsTest';
@danharper
danharper / background.js
Last active August 29, 2025 17:45
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-color.md
Last active August 29, 2022 15:54
GLSL color functions

RGB - YUB

mat3 yuv2rgb = mat3(1.0, 0.0, 1.28033, 1.0, -0.21482, -0.38059, 1.0, 2.12798, 0.0);
mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722, -0.09991, -0.33609, 0.43600, 0.615, -0.5586, -0.05639);

RGB - HSV