Skip to content

Instantly share code, notes, and snippets.

View xslim's full-sized avatar

Taras Kalapun xslim

View GitHub Profile
@woloski
woloski / server.js
Created February 4, 2014 14:17
jwt and social auth
app.get('/auth/facebook/callback',
passport.authenticate('facebook', { failureRedirect: '/error', session: false }),
function(req, res) {
var token = jwt.sign(req.user, secret, { expiresInMinutes: 60*5 });
res.redirect('/#jwt=' + jwt);
});
set -e
PRODUCT_PATH="${SYMROOT}/Release/Analytics.framework"
## Prepare the framework Folder Structure
mkdir -p "${PRODUCT_PATH}/Versions/A/Headers"
mkdir -p "${PRODUCT_PATH}/Versions/A/Resources"
# Link the "Current" version to "A"
/bin/ln -sfh A "${PRODUCT_PATH}/Versions/Current"
/bin/ln -sfh Versions/Current/Headers "${PRODUCT_PATH}/Headers"
@baryon
baryon / gist:11246286
Last active August 29, 2015 14:00 — forked from adamgit/gist:3705459
##########################################
#
# c.f. http://stackoverflow.com/questions/3520977/build-fat-static-library-device-simulator-using-xcode-and-sdk-4
#
# Version 2.7
#
# Latest Change:
# - Supports iPhone 5 / iPod Touch 5 (uses Apple's workaround to lipo bug)
#
# Purpose:
@lotreal
lotreal / PlayJsonTests.swift
Last active August 29, 2015 14:03
JSON on swift
//
// PlayJsonTests.swift
// PlayJsonTests
//
// Created by 罗涛 on 14-6-26.
// Copyright (c) 2014年 罗涛. All rights reserved.
//
import XCTest
import PlayJson
@fictorial
fictorial / ContactsLoader.h
Last active August 29, 2015 14:03
Trying to get Facebook social profile from AddressBook
@interface LocalContact : NSObject
@property (nonatomic, copy) NSString *firstName;
@property (nonatomic, copy) NSString *lastName;
@property (nonatomic, copy, readonly) NSString *fullName;
@property (nonatomic, copy) NSString *mobileNumber;
@property (nonatomic, copy) NSString *normalizedMobileNumber;
@property (nonatomic, copy) NSString *facebookID;
@jault3
jault3 / PopulateWeight.m
Last active August 29, 2015 14:06
Populate Weight from HealthKit
HKQuantityType *weightType = [HKQuantityType quantityTypeForIdentifier:HKQuantityTypeIdentifierBodyMass];
// Since we are interested in retrieving the user's latest sample
// we sort the samples in descending order by end date
// and set the limit to 1
// We are not filtering the data, and so the predicate is set to nil.
NSSortDescriptor *timeSortDescriptor = [[NSSortDescriptor alloc] initWithKey:HKSampleSortIdentifierEndDate ascending:NO];
// construct the query & since we are not filtering the data the predicate is set to nil
HKSampleQuery *query = [[HKSampleQuery alloc] initWithSampleType:weightType predicate:nil limit:1 sortDescriptors:@[timeSortDescriptor] resultsHandler:^(HKSampleQuery *query, NSArray *results, NSError *error) {
/** @jsx React.DOM */
FBLoginMessageComponent = new React.createClass({
render: function() {
var status = this.props.status;
var message = '';
if (status === 'logged_in') {
message = 'You\'re already logged in.';
} else if (status === 'not_logged_in') {
message = 'You\'re not logged in yet.';
def format_time_interval(from_time, to_time)
seconds = (to_time - from_time).abs.round
minutes, seconds = seconds.divmod(60)
if minutes > 60 * 24
" "
elsif minutes > 60
hours, minutes =
" %2dh %2dm " % minutes.divmod(60)
else
" %2dm %2ds " % [minutes, seconds]
@assimovt
assimovt / user.rb
Created December 18, 2010 09:56
Railscast #236 extension with Fb_graph and Twitter
# app/models/user.rb
def apply_omniauth(omniauth)
case omniauth['provider']
when 'facebook'
self.apply_facebook(omniauth)
when 'twitter'
self.apply_twitter(omniauth)
end
authentications.build(hash_from_omniauth(omniauth))
@igrigorik
igrigorik / em-http-vcr.rb
Created January 30, 2011 04:56
Mocking with WebMock and VCR
require 'rubygems'
require 'test/unit'
require 'em-http'
require 'vcr'
VCR.config do |c|
c.cassette_library_dir = 'fixtures/vcr_cassettes'
c.http_stubbing_library = :webmock
end