Skip to content

Instantly share code, notes, and snippets.

View alexfaber2011's full-sized avatar

Alex Faber alexfaber2011

View GitHub Profile
@alexfaber2011
alexfaber2011 / reactivity.coffee
Created June 5, 2014 17:13
Reactivity Problem with $in - Case 135
#roles_custom.coffee (src/lib/roles_custom.coffee)
#TODO swap this function out with James's implementation or harness a proper implementation - Case 129
@getGroupsForUser = (userId) ->
user = Meteor.users.findOne _id: userId
if user and user.roles
Object.keys user.roles
#checks to see if a user is the admin of user's group
#returns empty array if not admin of any groups, or array of strings of groups user is admin of
public int c_l(String word, Label label){
Integer count;
if(label == Label.SPAM){
count = spam_table.get(word);
} else {
count = ham_table(word);
}
return (count == null) ? 0 : count;
}
@alexfaber2011
alexfaber2011 / gist:0056de65764f73e322f8
Created November 27, 2014 17:10
Error after pulling master. Have you seen this before?
W20141127-10:58:00.904(-6)? (STDERR) /home/alex/.meteor/packages/meteor-tool/.1.0.35.364gru++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20141127-10:58:00.905(-6)? (STDERR) throw(ex);
W20141127-10:58:00.905(-6)? (STDERR) ^
W20141127-10:58:00.915(-6)? (STDERR) Error: Non-whitespace before first tag.
W20141127-10:58:00.916(-6)? (STDERR) at Object.Future.wait (/home/alex/.meteor/packages/meteor-tool/.1.0.35.364gru++os.linux.x86_64+web.browser+web.cordova/meteor-tool-os.linux.x86_64/dev_bundle/lib/node_modules/fibers/future.js:323:16)
W20141127-10:58:00.917(-6)? (STDERR) at packages/meteor/helpers.js:118
W20141127-10:58:00.917(-6)? (STDERR) at f (packages/peerlibrary:blocking/server.js:15)
W20141127-10:58:00.918(-6)? (STDERR) at scrape_fuel_price (server/lib/fuel_prices.coffee:6:16)
W20141127-10:58:00.918(-6)? (STDERR) at server/startup/startup.coffee:7:2
W20141127-10:58:00.919(-6)? (STDERR) at /hom
firstChunkMillis = [3604,3615,3624,3634,3645,3655,3664,3675,3684,3695,3705,3714,3724,3734,3745,3755,3764,3775,3785,3795,3805,3815,3825,3837,3844,3859,3865,3875,3885,3895,3904,3915,3926,3950,3952,4037,4038,4038,4039,4040,4040,4042,4043,4043,4044,4054,4064,4074,4085,4094,4104,4115,4125,4134,4144,4155,4165,4174,4184,4194,4205,4214,4225,4234,4245,4255,4265,4275,4284,4294,4304,4314,4325,4334,4345,4354,4364,4375,4384,4394,4404,4415,4424,4434,4444,4454,4464,4474,4484,4494,4504,4514,4524,4534,4545,4554,4564,4574,4584,4595,4605,4615,4624,4634,4646,4654,4664,4675,4684,4694,4705,4714,4724,4734,4745,4755,4765,4774,4784,4794,4804,4815,4825,4835,4845,4857,4866,4875,4885,4894,4905,4914,4925,4934,4947,4955,4965,4975,4984,4994,5004,5014,5024,5034,5044,5055,5064,5074,5084,5094,5104,5114,5125,5134,5144,5155,5164,5174,5185,5195,5205,5214,5224,5234,5244,5255,5264,5275,5286,5295,5305,5314,5326,5334,5345,5355,5365,5377,5385,5395,5405,5420,5425,5438,5446,5456,5465,5476,5484,5495,5506,5515,5524,5538,5544,5554,5566,5575,5585,5594,5604
Apr 20 18:25:30 faber-MEAN default: <<<SumanAlarm>>> headers: {"host":"104.236.94.200:5555","connection":"keep-alive","content-length":"71","cache-control":"no-cache","origin":"chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop","content-type":"application/x-www-form-urlencoded","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36","postman-token":"0a2b3c39-794a-6a5d-4354-035b65a06bac","accept":"*/*","dnt":"1","accept-encoding":"gzip, deflate","accept-language":"en-US,en;q=0.8,pt;q=0.6"}
Apr 20 18:25:30 faber-MEAN default: <<<SumanAlarm>>> params: {}
Apr 20 18:25:30 faber-MEAN default: <<<SumanAlarm>>> query: {}
Apr 20 18:25:30 faber-MEAN default: <<<SumanAlarm>>> body: {"firstName":"Geoff","lastName":"Gilles","userName":"geoff_gilles","password":"password"}
Apr 20 18:25:30 faber-MEAN default: <<<SumanAlarm>>> url: /users/
Apr 20 18:25:30 faber-MEAN default: <<<SumanAlarm>>> method: POST
Apr 20 18:25:30 faber-MEAN d
@alexfaber2011
alexfaber2011 / ChallengeRESTClient.java
Created May 9, 2015 16:47
Converting JSONObject to POJO
return new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
VolleyLog.v(response.toString());
List<Challenge> challenges = new ArrayList<Challenge>();
//iterate over each JSONObject
for(int i = 0; i < response.length(); i++){
try {
JSONObject obj = (JSONObject) response.get(i);
String JSONString = obj.toString();
//Gather all of the form fields
NSMutableArray *smsValues = [[NSMutableArray alloc] initWithCapacity:3];
NSMutableArray *phoneValues = [[NSMutableArray alloc] initWithCapacity:3];
NSMutableArray *emailValues = [[NSMutableArray alloc] initWithCapacity:3];
NSArray *smsCells = [self.smsTable visibleCells];
NSArray *phoneCells = [self.phoneCallTable visibleCells];
NSArray *emailCells = [self.emailTable visibleCells];
for(NSUInteger i = 0; i < smsCells.count; i++){
//Does the compiler optimize this?
@alexfaber2011
alexfaber2011 / gist:f90123d5e5fb1bc8375f
Last active August 29, 2015 14:25
Clojurescript Debugging

Testing Results

3149a7b23a52abdd42f6e37c7b5ce5eaa71a47a8 - Localize both cli and cljs code

ERROR in (icm-anon-service.core-test/test-home) (:)
Uncaught exception, not in assertion.
expected: nil
  actual:
TypeError: 'null' is not an object (evaluating 'f.cljs$lang$maxFixedArity')
    at target/test.js:42883
func startLoad() {
ReachabilityManager.performOperationOnceReachable("SelfServiceViewController", onConnectionBlock: {
let rkObjectManager = RKObjectManager.sharedManager()
let dndFetchOperation = AFJSONRequestOperation(request: rkObjectManager.HTTPClient.requestWithMethod("GET", path: "users/\(AppPreferences.userId())/extensions/b77bb090-2fde-11e5-80c4-56847afe9799", parameters: nil))
let devicesFetchOperation = rkObjectManager.appropriateObjectRequestOperationWithObject(nil, method: .GET, path: "users/\(AppPreferences.userId())/devices", parameters: ["limit": 1000]) as! RKObjectRequestOperation
rkObjectManager.enqueueBatchOfObjectRequestOperations([devicesFetchOperation, dndFetchOperation], progress: nil, completion: { [weak self] operations -> Void in
let hasError = devicesFetchOperation.error != nil || dndFetchOperation.error != nil
if hasError {
if !devicesFetchOperation.cancelled && !
@alexfaber2011
alexfaber2011 / core.cljs
Created August 25, 2015 13:52
taste of clojurescript and reagent
(ns informacast-csv.core
(:require [informacast-csv.informormacast-communicator :as communicator]
[informacast-csv.zip-worker :as zip-worker]
[reagent.core :as reagent]
[reagent.session :as session]
[reagent-forms.core :refer [bind-fields]]
[goog.history.EventType :as EventType]
[goog.events :as events]
[secretary.core :as secretary :refer-macros [defroute]])
(:import goog.History))