Skip to content

Instantly share code, notes, and snippets.

View ebsaral's full-sized avatar

Emin Buğra Saral ebsaral

View GitHub Profile
@ebsaral
ebsaral / cthread.c
Created November 22, 2012 17:01
A simple thread example (session control) in C
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <pthread.h> // necessary
#include <stdlib.h>
// Session limit in seconds
#define SESSION_TIME 60
// Global last interaction variable
@ebsaral
ebsaral / capybara_example.rb
Last active August 29, 2015 14:21
Capybara Example
require 'capybara'
class CapybaraHelper
attr_accessor :session
def initialize
# Register Chrome driver
# You might need to install Chrome Driver to make it run (e.g 'brew install chromedriver')
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
@ebsaral
ebsaral / video_wants_to_watch.m
Last active August 29, 2015 14:11
Sending an Open Graph message with video.wants_to_watch action
// In order to display a Open Graph Action in your Facebook Share Dialog (FBDialog), you can construct your code like this:
NSMutableDictionary<FBOpenGraphAction> *action = (NSMutableDictionary<FBOpenGraphAction> *)[FBGraphObject graphObject];
NSMutableDictionary *graphObject = [FBGraphObject openGraphObjectForPostWithType:@"video.movie"
title:@"My movie."
image:@"http://www.mymovie.com/poster.jpg"
url:@"http://www.mymovie.com"
description:@"This movie may contain adult material."];
action[@"movie"] = graphObject;
@ebsaral
ebsaral / 16-base32.py
Last active August 29, 2015 13:56
Generating random string encoded in base32 with Python
import base64
import random
def generate_16char_base32(pre):
"""
Encode a string of 16 length in base32
with a given string - maximum length of 10 chars -
Note: 10 char = 16 char string in base32
Warning: Decoding is not a part of this example