Skip to content

Instantly share code, notes, and snippets.

Avatar

Fabrizio Regini freegenie

View GitHub Profile
View hs_hiddien_fields.js
var mapping = {
'last_lp_brand' : 'SEAT'
} ;
window.addEventListener('message', event => {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
console.log(">> Form is ready!");
Object.keys( mapping).forEach(function(key) {
View hs_hiddien_fields.js
var mapping = {
'last_lp_brand' : 'SEAT'
} ;
window.addEventListener('message', event => {
if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormReady') {
console.log(">> Form is ready!");
Object.keys( mapping).forEach(function(key) {
View gist:4e08e299c0878bc110d3f00d900e2ffb
## color bash
PS1='\e[33;1m\u@\h: \e[31m\W\e[0m\$ '
## Git lg
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@freegenie
freegenie / apache-wordpress.conf
Created Jun 30, 2015
Protect Wordpress installation with Fail2ban against xmlrpc attacks
View apache-wordpress.conf
[Definition]
failregex = ^<HOST> - - \[.+\] "POST /xmlrpc.php HTTP/1.(1|0)
ignoreregex =
View cemento.rb
qnt0 = 'cemento.txt'
if File.exists?(qnt0)
cemento = File.read('cemento.txt').to_i
else
cemento = 100
File.write(qnt0, cemento)
end
prod0 = 'cemento'
@freegenie
freegenie / unbox.sh
Last active Aug 29, 2015
Restore a wordpress instance from a WPEngine backup
View unbox.sh
#/bin/bash -l
# set -e # intentionally disabled
REMOTE_URL=$1 # Remote URL where to download the wpengine snapshot zip
DOMAIN=$2 # The new domain nme to use
GROUP=www-data
MYSQL_PW='your-password' # your database password even with special chars inside like >!- etc
USER=`stat --format '%U' . ` # this line takes the username from the owner of the current folder
@freegenie
freegenie / gist:eebd004c67ac5d6afb45
Created Feb 9, 2015
desk.com multipass authentication
View gist:eebd004c67ac5d6afb45
module DeskMultipass
URL_TEMPLATE = "https://%s.desk.com/customer/authentication/multipass/callback?multipass=%s&signature=%s"
def self.signed_url(user, redirect_to=nil)
raise "DESK_API_KEY is not set" if ENV['DESK_API_KEY'].blank?
raise "DESK_SUBDOMAIN is not set" if ENV['DESK_SUBDOMAIN'].blank?
# Create the encryption key using a 16 byte SHA1 digest of your api key and subdomain
key = Digest::SHA1.digest(ENV['DESK_API_KEY'] + ENV['DESK_SUBDOMAIN'])[0...16]
@freegenie
freegenie / production.rake
Created Jan 31, 2014
Supposed to copy assets to non fingerprinted name
View production.rake
namespace :app do
task :nonfingerprint_assets => :environment do
fingerprint = /\-[0-9a-f]{32}\./
filemap = {}
Dir["public/assets/**/*"].each do |file|
next if file !~ fingerprint
next if File.directory?(file)
next if file.split(File::Separator).last =~ /^manifest/
nondigest = file.sub fingerprint, '.'
View deploy.rake
#Deploy and rollback on Heroku in staging and production
task :deploy_staging => ['deploy:set_staging_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
task :deploy_production => ['deploy:set_production_app', 'deploy:push', 'deploy:restart', 'deploy:tag']
namespace :deploy do
PRODUCTION_APP = 'YOUR_PRODUCTION_APP_NAME_ON_HEROKU'
STAGING_APP = 'YOUR_STAGING_APP_NAME_ON_HEROKU'
task :staging_migrations => [:set_staging_app, :push, :off, :migrate, :restart, :on, :tag]
task :staging_rollback => [:set_staging_app, :off, :push_previous, :restart, :on]
@freegenie
freegenie / migration.rb
Created Mar 12, 2013
Rails migration set null to false with no default
View migration.rb
class AddPrivacyToSubscription < ActiveRecord::Migration
def change
add_column :subscriptions, :privacy, :boolean, :default => false, :null => false
change_column_default(:subscriptions, :privacy, nil)
end
end