Skip to content

Instantly share code, notes, and snippets.

@Serjip
Serjip / pub-sub.js
Created March 16, 2018 10:09 — forked from reu/pub-sub.js
node.js redis pub-sub example
var redis = require("redis")
, subscriber = redis.createClient()
, publisher = redis.createClient();
subscriber.on("message", function(channel, message) {
console.log("Message '" + message + "' on channel '" + channel + "' arrived!")
});
subscriber.subscribe("test");
//
// NSObject+AutoCoder.h
// AutoCoder
//
// Created by Sergey Popov on 03.02.16.
// Copyright © 2016 Sergey Popov. All rights reserved.
//
#import <Foundation/Foundation.h>
http://iphonedevwiki.net/index.php/Preferences.app
http://pastie.org/pastes/8305153
//
// Detect the device
//
#define IS_IPHONE_4 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)480) < DBL_EPSILON)
#define IS_IPHONE_5 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
#define IS_IPHONE_6 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)667) < DBL_EPSILON)
#define IS_IPHONE_6_PLUS (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)736) < DBL_EPSILON)
//
@Serjip
Serjip / Localized stings generator
Created September 16, 2014 13:14
Localized.strings genearator
find . -name \*.m | xargs genstrings -o en.lproj
//Original http://cocoasnippets.io/cocoa/ui/nswindow/coregraphics/2014/02/27/translucent-nswindow-with-blurred-background.html
// one more solution http://stackoverflow.com/questions/11174918/how-to-get-window-with-semi-transparent-blurred-background
typedef void * CGSConnection;
extern OSStatus CGSSetWindowBackgroundBlurRadius(CGSConnection connection, NSInteger windowNumber, int radius);
extern CGSConnection CGSDefaultConnectionForThread();
- (void)enableBlurForWindow:(NSWindow *)window
{
[window setOpaque:NO];
window.backgroundColor = [NSColor colorWithCalibratedWhite:1.0 alpha:0.5];
@Serjip
Serjip / Color macros
Last active August 29, 2015 14:05
Color macros for pleasure work with RGBA and Hex color codes. Available for cocoa and cocoa touch
// OS X
#define NSColorFromRGBA(r,g,b,a) [NSColor colorWithCalibratedRed:r/255.f green:g/255.f blue:b/255.f alpha:a/100.f]
#define NSColorFromHex(rgbValue) [NSColor colorWithCalibratedRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
// iOS
#define UIColorFromRGBA(r,g,b,a) [UIColor colorWithRed:r/255.f green:g/255.f blue:b/255.f alpha:a/100.f]
#define UIColorFromHex(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
NSDictionary *dictCodes = [NSDictionary dictionaryWithObjectsAndKeys:@"972", @"IL",
@"93", @"AF", @"355", @"AL", @"213", @"DZ", @"1", @"AS",
@"376", @"AD", @"244", @"AO", @"1", @"AI", @"1", @"AG",
@"54", @"AR", @"374", @"AM", @"297", @"AW", @"61", @"AU",
@"43", @"AT", @"994", @"AZ", @"1", @"BS", @"973", @"BH",
@"880", @"BD", @"1", @"BB", @"375", @"BY", @"32", @"BE",
@"501", @"BZ", @"229", @"BJ", @"1", @"BM", @"975", @"BT",
@"387", @"BA", @"267", @"BW", @"55", @"BR", @"246", @"IO",
@"359", @"BG", @"226", @"BF", @"257", @"BI", @"855", @"KH",
@"237", @"CM", @"1", @"CA", @"238", @"CV", @"345", @"KY",
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3