Skip to content

Instantly share code, notes, and snippets.

@smoothdvd
smoothdvd / checkPlayServices.java
Created March 30, 2017 07:45
Check the device to make sure it has the Google Play Services APK. If it doesn't, display a dialog that allows users to download the APK from the Google Play Store or enable it in the device's system settings.
/**
* Check the device to make sure it has the Google Play Services APK. If
* it doesn't, display a dialog that allows users to download the APK from
* the Google Play Store or enable it in the device's system settings.
*/
private boolean checkPlayServices() {
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (apiAvailability.isUserResolvableError(resultCode)) {
@smoothdvd
smoothdvd / hoge.rb
Last active November 18, 2015 06:51
require 'nokogiri'
require 'capybara'
require 'capybara/poltergeist'
class Hoge
def self.scrape_include_js_contents
#poltergistの設定
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {:js_errors => true }) #追加のオプションはググってくださいw
end
@smoothdvd
smoothdvd / application_helper.rb
Created February 7, 2012 05:27 — forked from purcell/application_helper.rb
Make will_paginate generate HTML that bootstrap.less will render nicely
# Based on https://gist.github.com/1182136
class BootstrapLinkRenderer < ::WillPaginate::ActionView::LinkRenderer
protected
def html_container(html)
tag :div, tag(:ul, html), container_attributes
end
def page_number(page)
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
# Author: Abhinay Omkar
# Youtube Downloader
import sys
from urllib import urlopen, unquote
from urlparse import parse_qs, urlparse
youtube_watchurl = sys.argv[1]
url_query = urlparse(youtube_watchurl).query
video_id = parse_qs(url_query)['v'][0]
url_data = urlopen('http://www.youtube.com/get_video_info?&video_id=' + video_id).read()