Skip to content

Instantly share code, notes, and snippets.

View seyhunak's full-sized avatar
🏆
Winning The Life

Seyhun Akyürek seyhunak

🏆
Winning The Life
View GitHub Profile
@seyhunak
seyhunak / geolocation.js
Created March 20, 2014 14:52
Geolocation + Get links with class and append geolocation data attribute
_mb(function() {
var latitude, longitude;
_mb(document).ready(function(){
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(handle_geolocation_query, handle_errors);
} else {
console.log('Error')
}
});
@seyhunak
seyhunak / agents
Created March 21, 2014 12:44
Mobile Browser - User Agents
"Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3",
"Mozilla/5.0 (iPhone; CPU iPhone OS 7_1 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) CriOS/33.0.1750.15 Mobile/11D167 Safari/9537.53",
"Mozilla/5.0 (iPad; U; CPU OS 5_1_1 like Mac OS X; en-us) AppleWebKit/534.46.0 (KHTML, like Gecko) CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3",
"Mozilla/5.0 (Linux; U; Android-4.0.3; en-us; Galaxy Nexus Build/IML74K) AppleWebKit/535.7 (KHTML, like Gecko) CrMo/16.0.912.75 Mobile Safari/535.7",
"Mozilla/5.0 (Linux; U; Android-4.0.3; en-us; Xoom Build/IML77) AppleWebKit/535.7 (KHTML, like Gecko) CrMo/16.0.912.75 Safari/535.7",
"Mozilla/5.0 (Linux; Android 4.0.4; SGH-I777 Build/Task650 & Ktoonsez AOKP) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
"Mozilla/5.0 (Linux; Android 4.1; Galaxy Nexus Build/JRN84D) AppleWebKit/535.19 (KHTML, like
@seyhunak
seyhunak / regex
Created March 21, 2014 12:45
Mobile Browser Dedection - Regex
/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/
task :env_checker do
unless Rails.env.development?
puts "Not in development environment, exiting!"
exit 1
end
end
namespace :app_name do
desc 'Anonymize user, company, and location information'
task :anonymize => [:environment, :env_checker] do
@seyhunak
seyhunak / _languages.html.erb
Created March 26, 2014 08:13
List all available languages in Rails 4
<% I18n.available_locales.each do |locale| %>
<%= link_to localize(locale), locale: locale %>
<% end %>
@seyhunak
seyhunak / application_controller.rb
Created March 30, 2014 17:28
Set dynamic layout based on controllers
before_action :set_layout
private
def set_layout
if ["users", "items", "authentications"].include?(params[:controller])
self.class.layout 'user'
end
end
#!/usr/bin/env ruby
# Author : Emad Elsaid (https://github.com/blazeeboy)
require 'koala' # gem install koala --no-document
# create a facebook app and get access token from here
# https://developers.facebook.com/tools/explorer
# select "user_status", "friends_status", "user_checkins" when authenticating
oauth_access_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
graph = Koala::Facebook::API.new(oauth_access_token)
places = []
@seyhunak
seyhunak / Preferences.sublime-settings
Created April 2, 2014 15:27
Sublime Text 2 - Default
// While you can edit this file, it's best to put your changes in
// "User/Preferences.sublime-settings", which overrides the settings in here.
//
// Settings may also be placed in file type specific options files, for
// example, in Packages/Python/Python.sublime-settings for python files.
{
// Sets the colors used within the text area
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
// Note that the font_face and font_size are overriden in the platform
@seyhunak
seyhunak / Preferences.sublime-settings
Created April 2, 2014 15:27
Sublime Text 2 - User
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": false,
"caret_style": "solid",
"color_scheme": "Packages/User/Railscasts.tmTheme",
"font_size": 12.0,
"ignored_packages":
[
"Vintage",
"Theme - itg.flat",
@seyhunak
seyhunak / Gemfile
Created April 5, 2014 15:37
Use Redis as Cache store for Rails
gem "redis-store"
gem 'redis-rails'
gem "redis-rack-cache"