This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>SoundCloud OAuth 2 User Agent Authentication Flow Demo</title> | |
<script type="text/javascript" charset="utf-8" src="javascript/jquery-1.4.2.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
$(function () { | |
var extractToken = function(hash) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OAuth = require('oauth').OAuth | |
_ = require 'underscore' | |
class LinkedInClient | |
@baseUrl: 'https://api.linkedin.com' | |
@requestTokenUrl: "#{@baseUrl}/uas/oauth/requestToken" | |
@accessTokenUrl: "#{@baseUrl}/uas/oauth/accessToken" | |
@authorizeUrl: "#{@baseUrl}/uas/oauth/authorize" | |
@profileFields: ['id', 'headline', 'first-name', 'last-name', 'public-profile-url', 'picture-url', 'educations', 'positions', 'email-address'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reverse = (s) -> | |
if s.length < 2 then s else reverse(s[1..-1]) + s[0] | |
s = "Hello" | |
console.log "s=#{s}, s.reverse=#{reverse(s)}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.publishPost = -> | |
userId = window.fbUserId | |
post = | |
caption: "Evil Twins Hunt" | |
message: "Found an app to check FB for presence of Evil | |
Twins from the Evil Parallel Universe. Be watchful, tovarisch! | |
( And yeah, I also learned how to access FB info and publish | |
feed items from code, which is cool. )" | |
link: "http://coffeequery.blogspot.com/2012/04/hunting-evil-twins.html" | |
FB.api "/me/feed", 'post', post |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shouldn't they be colored somehow fancy? | |
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'] | |
#jQuery comes to the resque | |
containerWidth = $('#container2').width() | |
containsrHeight = $('#container2').height() | |
# Add polygons to a layer | |
addPolygon = (layer) -> | |
n = layer.getChildren().length + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sidekiq' | |
require 'securerandom' | |
require 'active_support' | |
# If your client is single-threaded, we just need a single connection in our Redis connection pool | |
class GenerateUUID | |
def call(worker_class, msg, queue) | |
puts "Here goes middleware, worker_class = #{worker_class}, msg = #{msg}, queue = #{queue}" | |
if (last_arg = msg['args'].last).is_a? Proc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make sure you have Sinatra installed, then start sidekiq with | |
# sidekiq -r ./sinkiq.rb | |
# Simply run Sinatra with | |
# ruby ./sinkiq.rb | |
# and then browse to http://localhost:4567 | |
# | |
require 'sinatra' | |
require 'sidekiq' | |
require 'redis' | |
require 'celluloid' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <set> | |
using namespace std; | |
int common_prefix(const string& a, const string& b) { | |
int i = 0; | |
while (i < a.size() && i < b.size() && a[i] == b[i]) | |
++i; | |
return i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <unordered_map> | |
using namespace std; | |
struct Tree { | |
int value; | |
Tree(int v) : value(v) {} | |
vector<Tree*> c; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io._ | |
import java.util.zip._ | |
val pi = new PipedInputStream | |
val po = new PipedOutputStream(pi) | |
val zo = new GZIPOutputStream(po) | |
val zi = new GZIPInputStream(pi) | |
val w = new PrintWriter(zo) | |
val r = new BufferedReader(new InputStreamReader(zi)) |