Skip to content

Instantly share code, notes, and snippets.

@ryancole
ryancole / foo.m
Created August 7, 2012 01:06
Convert NSPredicate into NSDictionary for use as a query string in an AFNetworking HTTP request
- (NSURLRequest *)requestForFetchRequest:(NSFetchRequest *)fetchRequest
withContext:(NSManagedObjectContext *)context {
// init the query string dictionary
NSMutableDictionary *queryString = nil;
// if we're given a predicate, convert it to a dictionary
if (fetchRequest.predicate) {
if ([fetchRequest.predicate isKindOfClass:[NSCompoundPredicate class]]) {
@ryancole
ryancole / remote.ini
Created March 25, 2012 20:47
Nickname auto-completion for mIRC
on *:TABCOMP:#: {
/editbox -a $1- $+ $chr(58)
/halt
}
@ryancole
ryancole / foo.css
Created October 30, 2019 00:30
use bootstrap to create fillable content divs
#parent {
height: 300px;
}
# https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
while (1) {
$duration = Get-Random -Minimum 10 -Maximum 60
Write-Output "Waiting $duration seconds ...";
Start-Sleep -Seconds $duration
// Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
#include "ShooterGame.h"
#include "Weapons/ShooterWeapon.h"
#include "Weapons/ShooterDamageType.h"
#include "UI/ShooterHUD.h"
#include "Online/ShooterPlayerState.h"
#include "Animation/AnimMontage.h"
#include "Animation/AnimInstance.h"
#include "Sound/SoundNodeLocalPlayer.h"
(defn append-user-data [handler]
(fn [request]
(clutch/with-db database-address
(let [access-token (get-in request [:headers "token"])
view-data (clutch/get-view "api" "users-by-token" {:keys [access-token]})]
(if (= 1 (count view-data))
(handler (assoc request :api-user (:value (first view-data))))
{:status 403
:body "Invalid access token"})))))
@ryancole
ryancole / foo.sql
Last active December 11, 2015 20:59
get a count of items for each user, accounting for duplicates and nulls / empties
SELECT v.custodian_id, COUNT(DISTINCT NVL(LOWER(TRIM(v.serial_numberev)), v.evidence_id)) AS esi_count
FROM evidence_to_custodian e
LEFT OUTER JOIN evidence_main v ON v.evidence_id = e.evidence_id
WHERE v.purged != 1 AND LOWER(v.source) = 'ac' AND v.inventory_class = 1 AND LOWER(v.source_mediaev) = 'hdd' AND e.custodian_id IN (:custodians)
GROUP BY v.custodian_id
@ryancole
ryancole / foreign_key_count.sql
Created January 9, 2013 17:58
Query for records with more than X number of foreign key matches.
SELECT t.emplid
FROM term_file t
WHERE t.emplid IN (SELECT v.custodian_id FROM evidence_main v GROUP BY v.custodian_id HAVING COUNT(v.custodian_id) > 50)
#include <node.h>
#include <v8.h>
#ifndef UNIX
#define UNIX
#define UNIX_64
#endif
#include <scctype.h>
#include <sccex.h>
@ryancole
ryancole / TitleField.h
Created August 14, 2012 02:27
A subclass of `UITextField` that has a prefixed label.
//
// TitleField.h
// mustached-bear
//
// Created by Ryan Cole on 8/12/12.
// Copyright (c) 2012 Ryan Cole. All rights reserved.
//
#import <UIKit/UIKit.h>