Skip to content

Instantly share code, notes, and snippets.

View wilsolutions's full-sized avatar
😀

Wils wilsolutions

😀
View GitHub Profile
+ (void)pingReachabilityInternal
{
BOOL ignoresAdHocWiFi = NO;
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000)
struct sockaddr_in6 ipAddress;
bzero(&ipAddress, sizeof(ipAddress));
ipAddress.sin6_len = sizeof(ipAddress);
ipAddress.sin6_family = AF_INET6;
#else
struct sockaddr_in ipAddress;
@wilsolutions
wilsolutions / gist:96e3ae1310ccae86d344
Created January 29, 2015 17:48
XCTest + CoreData = EXC_BAD_ACCESS(code=EXC_i386_GPFLT)
<unknown>:0: error: -[apiTests testExample] : failed: caught "NSInvalidArgumentException", "*** -[NSURL initFileURLWithPath:]: nil string parameter"
(
0 CoreFoundation 0x007321e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x004ac8e5 objc_exception_throw + 44
2 CoreFoundation 0x00731fbb +[NSException raise:format:] + 139
3 Foundation 0x000c592b -[NSURL(NSURL) initFileURLWithPath:] + 123
4 Foundation 0x000c57fd +[NSURL(NSURL) fileURLWithPath:] + 67
5 apiTests 0x04010023 -[DatabaseManager managedObjectModel] + 291
6 apiTests 0x040102b7 -[DatabaseManager persistentStoreCoordinator] + 503
7 apiTests 0x0400f538 -[DatabaseManager setupContexts] + 312
@wilsolutions
wilsolutions / ios
Last active April 6, 2016 23:42
General Objective-C snippets to work around some iOS issues.
// Drawing a dotted line
float width = kBoundsWidth - 90;
CAShapeLayer *shapelayer = [CAShapeLayer layer];
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(-30, 30)];
[path addLineToPoint:CGPointMake(width, 30)];
UIColor *fill = [UIColor lightGrayColor];
shapelayer.strokeStart = 0.0;
shapelayer.strokeColor = fill.CGColor;
shapelayer.lineWidth = 0.5;
Error:
2011/03/15 17:07:12 [crit] 7836#0: *7 connect() to unix:/tmp/phpfpm.sock failed (2: No such file or directory) while connecting to upstream, client: 127.0.0.1, server: wils.drupal7.com.br, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/tmp/phpfpm.sock:", host: "wils.drupal7.com.br"
---
Cause: PHP-FPM misconfiguration.
---
Solution:
1 - Check the php-fpm configuration: vi /etc/php-fpm.d/www.conf
2 - Comment the line ";listen = 127.0.0.1:9000"
3 - Add the line: listen = /tmp/phpfpm.sock
4 - Restart: /etc/init.d/php-fpm restart
I am trying to setup redis sentinel in 2 vms, this is my setup:
- 10.1.8.36 mymaster
- 10.1.8.46 resque (redis.conf = slaveof 10.1.8.36)
- in both mnachines /etc/redis-sentinel.conf
port 26379
sentinel monitor mymaster 10.1.8.36 6379 1
sentinel down-after-milliseconds mymaster 5000
@wilsolutions
wilsolutions / date_range
Created January 3, 2014 17:04
calling Redis keys by minute in a range of minutes...
$objDateTime = new DateTime('NOW');
$this->importTime = $objDateTime->format('Y-m-d H:i:sP');
$objDateTimeAgo = new DateTime('-60 minutes');
$start = $objDateTimeAgo;
$end = $objDateTime;
$interval = DateInterval::createFromDateString('1 min');
$times = new DatePeriod($start, $interval, $end);
$totals = null;
$parsedResults = null;
{
"20131126080000": {
"page_views": 5,
"visits": 4,
"unique_visits": 2
},
"20131126080010": {
"page_views": 5,
"visits": 4,
"unique_visits": 2
Uncaught Error: Parse error on line 5:
... <hr /> XXX {{Rating[0].notes}}
---------------------^
Expecting 'ID'
[
{
"Item":{
"id":"1",
"title":"Lightbulb Gadget - Self Plugging.",
"sub_title":"This guy plugs himself in. So, which came first? The socket or the plug?",
"description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero metus, suscipit vestibulum gravida vitae, ornare sit amet diam. Praesent et tincidunt metus. Etiam eu sapien turpis, id vehicula libero. In hendrerit congue leo sit amet mattis. Pr",
"rating_count":"3",
"created":"2011-10-19 10:49:07",
"modified":"2011-11-10 10:18:23"
@app = window.app ? {}
class Insight extends Backbone.Model
@app.Insight = Insight
class Insights extends Backbone.Collection
model: app.Insight
url: 'http://localhost/items.json'
initialize: ->