Skip to content

Instantly share code, notes, and snippets.

View developer88's full-sized avatar

Andrey Eremin developer88

View GitHub Profile
@mattvh
mattvh / favicon.rb
Last active September 4, 2020 12:13
Discovering and saving favicons with Ruby
# by Matt Harzewski
# Read more: http://www.webmaster-source.com/2013/09/25/finding-a-websites-favicon-with-ruby/
require "httparty"
require "nokogiri"
require "base64"
class Favicon
def select2 text, options
page.find("#s2id_#{options[:from]} a").click
find(:xpath, "//body").find("input.select2-input").set(text)
page.execute_script(%|$("input.select2-input:visible").keyup();|)
find(:xpath, '//body').find('ul.select2-results li', text: text).click
end
@jbonney
jbonney / deploy.rb
Created August 17, 2013 15:15
Mina deployment file to setup new host for Rails applications. Creates the folder structure, fill up the database.yml file, create the associated DB and user and set up new Apache virtual host file.
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
# Usually mina focuses on deploying to one host and the deploy options are therefore simple.
# In our case, there is a number of possible servers to deploy to, it is therefore necessary to
# specify the host that we are targeting.
server = ENV['server']
# Since the same host can have multiple applications running in parallel, it is necessary to
@infertux
infertux / select2_helper.rb
Last active July 27, 2024 16:50
Helper to select a Select2 item with Capybara/Cucumber
# spec/support/capybara/select2_helper.rb or features/support/select2_helper.rb
module Select2Helper
# @example
# select2 "Item", from: "select_id"
# select2 /^Item/, from: "select_id"
#
# @note Works with Select2 version 3.4.1.
def select2(text, options)
find("#s2id_#{options[:from]}").click
@willurd
willurd / web-servers.md
Last active April 20, 2025 00:42
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@yctay
yctay / all_locale_switcher.html.erb
Created October 3, 2012 10:05
RefineryCMS frontend locale switcher
<!-- Locale switchers, but presents all available locales as options, even the presently active one -->
<ul>
<% Refinery::I18n.config.frontend_locales.each do |locale| %>
<li>
<%= link_to "/#{locale.to_s + request.path}", {:title => Refinery::I18n.locales[locale]} do%>
<span><%= Refinery::I18n.locales[locale] %></span>
<% end -%>
</li>
<% end %>
@makotokw
makotokw / header_ogp.php
Last active October 9, 2018 14:06
Open Graph protocol for WordPress
<?php
/**
* Open Graph protocol for WordPress
* @version 0.9.2
* @author makoto_kw
* @link https://gist.github.com/3399585
*/
// key into custom fields for description. Default is for All in One SEO Pack
define('WP_OGP_POST_DESCRIPTION_KEY', '_aioseop_description');
@tokarev-yuriy
tokarev-yuriy / .gitignore
Created July 15, 2012 23:01
Bitrix gitignore
*.swp
*.swo
.idea
bitrix/components/bitrix/*
bitrix/php_interface/dbconn.php
bitrix/managed_cache/*
bitrix/stack_cache/*
bitrix/wizards/*
bitrix/themes/*
bitrix/gadgets/*
@matthewlehner
matthewlehner / autopgsqlbackup
Created July 11, 2012 16:10
Auto PostgreSQL backup script.
#!/bin/bash
#
# PostgreSQL Backup Script Ver 1.0
# http://autopgsqlbackup.frozenpc.net
# Copyright (c) 2005 Aaron Axelsen <[email protected]>
#
# This script is based of the AutoMySQLBackup Script Ver 2.2
# It can be found at http://sourceforge.net/projects/automysqlbackup/
#
# The PostgreSQL changes are based on a patch agaisnt AutoMySQLBackup 1.9
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 19, 2025 12:44
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname