Skip to content

Instantly share code, notes, and snippets.

View ryanfitz's full-sized avatar

Ryan Fitzgerald ryanfitz

View GitHub Profile
@ryanfitz
ryanfitz / sample.js
Created October 12, 2014 14:47
dynamodb document example
var AWS = require("aws-sdk");
var DOC = require("dynamodb-doc");
var path = require('path');
var util = require('util');
var _ = require('lodash');
var async = require('async');
var internals = {};
for (NSDictionary *data in responseObject[@"discussions"]) {
NFTDiscussionModel *discussion = [MTLJSONAdapter modelOfClass:[NFTDiscussionModel class]
fromJSONDictionary:data error:nil];
[items addObject:discussion];
}
success([items firstObject]);
@ryanfitz
ryanfitz / s3_list.swift
Created August 3, 2014 23:48
list s3 buckets using the aws sdk
AWSS3.defaultS3().listBuckets(nil).continueWithBlock {
(task: BFTask!) -> AnyObject! in
let output : AWSS3ListBucketsOutput = task.result() as AWSS3ListBucketsOutput
println("found \(output.buckets.count) buckets")
for bucket in output.buckets as [AWSS3Bucket] {
println("Found bucket \(bucket.name)")
}
return nil
int resultsSize = [self.dataController.products count]; //data is the previous array of data
[self.dataController.products addObjectsFromArray:products];
[self.productsView performBatchUpdates:^{
NSMutableArray *arrayWithIndexPaths = [NSMutableArray array];
for (int i = resultsSize; i < resultsSize + products.count; i++) {
[arrayWithIndexPaths addObject:[NSIndexPath indexPathForRow:i inSection:0]];
}
[self.productsView insertItemsAtIndexPaths:arrayWithIndexPaths];
}
@ryanfitz
ryanfitz / settings.json
Created February 11, 2013 16:38
transmission settings
"download-queue-size": 5,
"encryption": 1,
"idle-seeding-limit": 30,
"idle-seeding-limit-enabled": false,
"incomplete-dir": "/mnt/BIGHUSK/torrents",
"incomplete-dir-enabled": false,
"lpd-enabled": false,
"message-level": 2,
"peer-congestion-algorithm": "",
"peer-limit-global": 240,
@ryanfitz
ryanfitz / golang-nuts.go
Created December 2, 2012 22:45
two ways to call a function every 2 seconds
package main
import (
"fmt"
"time"
)
// Suggestions from golang-nuts
// http://play.golang.org/p/Ctg3_AQisl
@ryanfitz
ryanfitz / tmux.conf
Created October 20, 2012 05:15
tmux config
set -g prefix C-a
unbind C-b
set -g default-terminal "screen-256color"
set -sg escape-time 1
# window and panes index
set -g base-index 1
setw -g pane-base-index 1
@ryanfitz
ryanfitz / blocklist_update.sh
Created April 21, 2012 01:07
update transmission blocklists
#!/usr/bin/env sh
killall -9 transmission-daemon
rm -v /mnt/SEA_DISC/torrents/.config/transmission-daemon/blocklists/*
cd /mnt/SEA_DISC/torrents/.config/transmission-daemon/blocklists
ls /mnt/SEA_DISC/torrents/.config/transmission-daemon/blocklists
wget -q -O bt_level1.gz http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz
wget -q -O bt_level2.gz http://list.iblocklist.com/?list=bt_level2&fileformat=p2p&archiveformat=gz
@ryanfitz
ryanfitz / stitch_jade_compile.js
Created February 19, 2011 02:26
render jade templates on client side using stitch
var stitch = require('stitch');
var express = require('express');
options = {
paths : [__dirname + '/lib', __dirname + '/vendor'],
compilers: {
jade: function(module, filename) {
var jade = require('jade');
var source = require('fs').readFileSync(filename, 'utf8');
class User
include Mongoid::Document
field :username, :type => String
field :full_name, :type => String
references_many :friends, :class_name => 'User', :stored_as => :array, :inverse_of => :followers
references_many :followers, :class_name => "User", :stored_as => :array, :inverse_of => :friends
end