Skip to content

Instantly share code, notes, and snippets.

# 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()
@smoothdvd
smoothdvd / youtube-downloader.py
Created September 6, 2011 00:14
Youtube Downloader
# Author: Abhinay Omkar
# Youtube Downloader
# Modifier: Alex Gao
# Youtube now uses cookies to verify download
import sys
from urllib2 import urlopen, unquote
from urlparse import parse_qs, urlparse
import requests
@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)
@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 / 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)) {
for image_path in TEST_IMAGE_PATHS:
image = Image.open(image_path)
# the array based representation of the image will be used later in order to prepare the
# result image with boxes and labels on it.
image_np = load_image_into_numpy_array(image)
# Expand dimensions since the model expects images to have shape: [1, None, None, 3]
image_np_expanded = np.expand_dims(image_np, axis=0)
# Actual detection.
output_dict = run_inference_for_single_image(image_np, detection_graph)
# Visualization of the results of a detection.
@smoothdvd
smoothdvd / Dockerfile
Created March 18, 2020 05:41
Install ca certificates in docker
FROM ubuntu
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
@smoothdvd
smoothdvd / schema.json
Last active January 22, 2022 02:24
In Strapi headless CMS V4, if you want add some specific type column (such as tstzrange type PostgreSQL offered), you can code like this
{
...
"attributes": {
"effective_range": {
"type": "string",
"columnType": {
"type": "specificType",
"args": [
"tstzrange"
]
'use strict';
module.exports = require('./server');
@smoothdvd
smoothdvd / index.js
Last active February 5, 2022 08:40
server/index.js
'use strict';
const register = require('@strapi/plugin-users-permissions/server/register');
const bootstrap = require('./bootstrap');
const contentTypes = require('@strapi/plugin-users-permissions/server/content-types');
const middlewares = require('@strapi/plugin-users-permissions/server/middlewares');
const services = require('./services');
const routes = require('@strapi/plugin-users-permissions/server/routes');
const controllers = require('@strapi/plugin-users-permissions/server/controllers');
const config = require('@strapi/plugin-users-permissions/server/config');