Skip to content

Instantly share code, notes, and snippets.

View maier-stefan's full-sized avatar
🏠
Working from home

Stefan Maier maier-stefan

🏠
Working from home
View GitHub Profile
@maier-stefan
maier-stefan / gist:ac9b1aeec1c32b02ed2e
Created October 14, 2014 08:33
nginx: from www to non - www using http
user nginx;
worker_processes {{ workers }};
error_log {{ deploy_to }}/shared/log/nginx_error.log;
events
{
worker_connections 1024;
{% if passenger != true %}
accept_mutex off;
{% endif %}
<iframe src="http://www.pornhub.com/embed/44bc40f3bc04f65b7a35" frameborder="0" height="481" width="608" scrolling="no"></iframe>|http://i1.cdn2a.image.pornhub.phncdn.com/m=eaf88daaaa/videos/201010/27/267/original/0.jpg|http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/1.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/2.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/3.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/4.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/5.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/6.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/7.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/8.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/9.jpg;http://thumb0.cdn1b.image.pornhub.phncdn.com/videos//201010/27/267/320x240/
require 'open-uri'
url = "http://www.domain.com/embed/44bc40f3bc04f65b7a35"
video_page = open(url).read
video = video_page[/'http(.*?)mp4(.*?)'/]
puts download_url = video.tr("'",'')
new_file_path = "/Users/name/Projects/loader/your_video.mp4"
open(new_file_path, "wb") do |file|
file.print open(download_url).read
end
@maier-stefan
maier-stefan / form
Created December 5, 2014 10:34
looking for a saver way then hidden fields
<h3>Lets do a reservation </h3>
<% unless current_user.blank? %>
<%= form_for @reservation, :url => make_a_booking_path, :html => { :class => 'form-horizontal' } do |f| %>
<% if @reservation.errors.any? %>
<div id="errorExplanation">
<h2><%= pluralize(@reservation.errors.count, "error") %> prohibited this reservation from being saved:</h2>
<ul>
<% @reservation.errors.full_messages.each do |message| %>
<li><%= message %></li>
@maier-stefan
maier-stefan / html error
Last active August 29, 2015 14:11
Passenger not working
[ 2014-12-17 15:46:14.3912 21021/7f3250b16700 agents/HelperAgent/RequestHandler.h:2306 ]: [Client 20] Cannot checkout session because a spawning error occurred. The identifier of the error is 87d40d88. Please see earlier logs for details about the error.
App 21217 stdout:
App 21217 stdout:
[ 2014-12-17 15:47:21.1270 21021/7f3252e90700 Pool2/Implementation.cpp:287 ]: Could not spawn process for application /home/deploy/datalove/current: An error occured while starting up the preloader.
Error ID: ac490e7f
Error details saved to: /tmp/passenger-error-cfwWWo.html
Message from application: <p>It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:</p>
<pre class="commands">bundle install</pre>
require "httparty"
class Plugrush
include HTTParty
default_options.update(verify: false)
base_uri "https://www.plugrush.com/api"
def initialize(email, api_key)
@credentials = "?user=#{email}&api_key=#{api_key}"
end
@maier-stefan
maier-stefan / markdownify helper
Created January 16, 2015 16:03
markdown with html pipeline
module JobsHelper
def markdownify(content)
pipeline_context = {gfm:true, asset_root: "https://a248.e.akamai.net/assets.github.com/images/icons"}
pipeline = HTML::Pipeline.new [
HTML::Pipeline::MarkdownFilter,
HTML::Pipeline::SanitizationFilter,
HTML::Pipeline::EmojiFilter
], pipeline_context
pipeline.call(content)[:output].to_s.html_safe
end
@maier-stefan
maier-stefan / application.rb
Created January 19, 2015 11:15
uninitialized constant Rails (NameError)
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
@maier-stefan
maier-stefan / alert displays
Created January 23, 2015 15:36
communication with rails and coffeescript
The page at localhost:3000 says:
first_time=true; profile=afidwogiowjero;
@maier-stefan
maier-stefan / console
Created January 26, 2015 14:44
User auth key
$ rails c
Loading development environment (Rails 4.1.6)
2.1.4 :001 > User.create(email: "stefan@gmail.com", password: "somepassword123", password_confirmation: "somepassword123")
(0.2ms) begin transaction
User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE "users"."auth_token" = '' LIMIT 1
User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'stefan@gmail.com' LIMIT 1
(0.1ms) rollback transaction
=> #<User id: nil, email: "stefan@gmail.com", encrypted_password: "$2a$10$l6LMCC4/LbAZQUxQBZK04O9ks3WXswUNfzhAQpMwBGe...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil, auth_token: "">
2.1.4 :002 >