Skip to content

Instantly share code, notes, and snippets.

@naqi
naqi / LogstashService.java
Created May 30, 2019 05:23 — forked from dant3/LogstashService.java
Logstash Android client
import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import java.io.*;
import java.net.*;
@naqi
naqi / gist:8f1a569520247e794757867d65a3b4a5
Created July 1, 2018 05:03
Valve logs when provisioning
Message received: {"token":"hybmry9d","bridge":{"id":"1","pairing":0,"serial":"3813","error":0,"fwVer":"19","rfConfig":"US/Europe","bItv":6}, "valves":[{"id":"1","serial":"7936","statusCode":"0","temp":"58","open":"0","flow":"399","bat":"100","fwVer":"6","pulses":"399","rssi":"0"} ]}
Message sent to hybmry9d: {"bItv":6,"pairing":0,"updtBr":0,"date":"2018-06-30","event":{"current":0,"next":0},"valves":[{"id":"1","serial":7936,"update":0,"vItv":12,"deleted":0}]}
Message received: {"token":"hybmry9d","bridge":{"id":"1","pairing":0,"serial":"3813","error":0,"fwVer":"19","rfConfig":"US/Europe","bItv":6}, "valves":[{"id":"1","serial":"7936","statusCode":"128","temp":"58","open":"0","flow":"399","bat":"100","fwVer":"6","pulses":"399","rssi":"100"} ]}
Message sent to hybmry9d: {"bItv":6,"pairing":0,"updtBr":0,"date":"2018-06-30","event":{"current":0,"next":0},"valves":[{"id":"1","serial":7936,"update":0,"vItv":12,"deleted":0}]}
Message received: {"token":"hybmry9d","bridge":{"id":"1","pairing":0,"serial":"3813","erro
Verifying my Blockstack ID is secured with the address 1LiUoHQAfVsrGfx4uzaT55r4JAonrmj7rq https://explorer.blockstack.org/address/1LiUoHQAfVsrGfx4uzaT55r4JAonrmj7rq
@naqi
naqi / bridge_to_cloud.json
Last active January 29, 2018 15:44
Zilker Cloud to bridge proposal
Charator count: 778
{
"token":"afsadfasf",
"bridge": {
"id":"10",
"pairing":0,
"serial":"5551212",
"error":0,
"fwVer":"100100",
"rfConfig":"US/Europe",
@naqi
naqi / RenderScript.kt
Created November 8, 2016 04:37
render script blur
//Render script blur
layout_content.isDrawingCacheEnabled = true
val bitmap = Bitmap.createBitmap(layout_content.drawingCache)
layout_content.isDrawingCacheEnabled = false
val rs = RenderScript.create(this@FGSimpleRound)
val input = Allocation.createFromBitmap(rs, bitmap, Allocation.MipmapControl.MIPMAP_NONE,
Allocation.USAGE_SCRIPT)
val output = Allocation.createTyped(rs, input.getType())
val script = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs))
@naqi
naqi / gource.sh
Last active September 2, 2016 20:42 — forked from cgoldberg/gource.sh
Gource - Mir development video
# install bzr and gource
# get a branch of Mir's trunk code
# create gource video
$ sudo apt-get install bzr gource
$ bzr branch lp:mir
$ cd mir
$ gource \
-s .06 \
@naqi
naqi / ContactSync.m
Created September 2, 2016 20:24
Search for contact default container > unified contacts matching name predicate > loop to find matching contact with email address
[addressBook containersMatchingPredicate:[CNContainer predicateForContainersWithIdentifiers: @[addressBook.defaultContainerIdentifier]] error:&contactError];
NSArray * keysToFetch = @[CNContactEmailAddressesKey, CNContactGivenNameKey];
CNContactFetchRequest * request = [[CNContactFetchRequest alloc]initWithKeysToFetch:keysToFetch];
request.predicate = [CNContact predicateForContactsMatchingName:user.fullName];
NSArray *result = [addressBook unifiedContactsMatchingPredicate:[CNContact predicateForContactsMatchingName:user.fullName]
keysToFetch:keysToFetch
error:&contactError];
CNContact *unifiedContact;
@naqi
naqi / utils.m
Last active January 21, 2016 20:49
Highlight order and stripping elastic suffix
+ (NSString *) getSortHighlightedField:(NSArray *) fieldList{
NSArray *highlightOrder= @[
@"nickname",
@"skills",
@"interests",
@"group_names",
@"birth_date",
@"start_date",
@"start_date_year",
@"email",
@naqi
naqi / gist:b41a9d4758440a7d666c
Created March 26, 2015 17:30
iOS Operations
[manager enqueueBatchOfObjectRequestOperations:requests
progress:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) {
NSLog(@"%lu/%lu", (unsigned long) numberOfFinishedOperations, (unsigned long) totalNumberOfOperations);
} completion:^(NSArray *operations) {
UIApplication *application = [UIApplication sharedApplication];
self.task = [application beginBackgroundTaskWithExpirationHandler:^{
NSLog(@"Took too long!");
[self.syncOperationQueue cancelAllOperations];