Skip to content

Instantly share code, notes, and snippets.

View waiting-for-dev's full-sized avatar
🏠
Working from home

Marc Busqué waiting-for-dev

🏠
Working from home
View GitHub Profile
@waiting-for-dev
waiting-for-dev / refinery_external_image.js.coffee
Created August 20, 2013 09:14
Replace RefineryCMS behaviour to add external images in the WYSIWYG editor. Remember to add it in 'initializers/refinery/core.rb' through the 'config/register_javascript' option
$(document).ready ->
$('.wym_tools_image a').click (e)->
e.stopImmediatePropagation()
e.preventDefault()
id = $('.wym_iframe').find('iframe:visible').attr('id').slice(-1)
url = prompt('Insert external image link')
img = new Image()
img.src = url
alt = prompt('Insert alternative text for the image')
wym = jQuery.wymeditors(id)
@waiting-for-dev
waiting-for-dev / AdminCustomersController.php
Created November 16, 2013 10:54
AdminCustomersController for Newsletter Plus Prestashop module. It delete subscriber when a customer with the same email is created in the backend.
<?php
class AdminCustomersController extends AdminCustomersControllerCore
{
public function afterAdd($customer)
{
require_once _PS_MODULE_DIR_.'newsletterplus/newsletterplus.php';
$newsletterplus = new Newsletterplus();
$newsletterplus->hookActionCustomerAccountAdd(array(
'_POST' => $_POST,
@waiting-for-dev
waiting-for-dev / index.xml.builder
Created February 6, 2014 15:12
sitemap builder for refinerycms with blog support
xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
@locales.each do |locale|
::I18n.locale = locale
::Refinery::Page.live.in_menu.includes(:parts).each do |page|
# exclude sites that are external to our own domain.
page_url = if page.url.is_a?(Hash)
# This is how most pages work without being overriden by link_url
@waiting-for-dev
waiting-for-dev / Default
Last active April 14, 2021 03:06
Force screen resolution for my monitor
# Put in /etc/gdm3/Init/Default or ~/.xprofile
cvt 1280 720 60
xrandr --newmode "1280x720_60.00" 74.50 1280 1344 1472 1664 720 723 728 748 -hsync +vsync
xrandr --addmode VGA-0 1280x720_60.00
function rails() {
if [ "$1" = "start" ]; then
if [ "$2" = "" ]; then
RENV="development"
else
RENV="$2"
fi
rails server -d -e "$RENV"
return 0
elif [ "$1" = "stop" ]; then
@waiting-for-dev
waiting-for-dev / merge2ass.sh
Last active October 16, 2018 16:19
Script to run mplayer with two subtitles tracks at the same time. Usage: mplayer2 video sub1 sub2. merge2ass.sh (http://www.abclinuxu.cz/blog/Joseho_blog/2007/7/30/188299) script must be in the path.
#!/bin/bash
# merge2ass.sh - script for merging two text-subtitles into an ass subtitle file
# version 0.9b, 02-feb-2013
# comments/criticism/praise to jose1711-gmail-com
# dependencies: mplayer (if your subtitle files need to be converted to srt), gnu utils
# thanks to:
# - d.watzke for comments
# - belisarivs for testing
#!/bin/sh
if [ x = x${2} ]; then
BRANCH_NAME=$(git symbolic-ref --short HEAD)
STORY_NUMBER=$(echo $BRANCH_NAME | sed -n 's/.*-\([0-9]\)/\1/p')
if [ x != x${STORY_NUMBER} ]; then
sed -i.back "1s/^/\n\n[#$STORY_NUMBER]/" "$1"
fi
fi
function epub() {
tags="$@"
if [ x = x${tags} ]; then
filename=$(date -I)_feeds
else
filename=$(date -I)_${tags// /_}_feeds
fi
ebook-convert ~/projects/recipes/newsbeuter/newsbeuter.recipe $filename.epub --tags="${tags// /,}"
}
@waiting-for-dev
waiting-for-dev / gist:ec481ca658e2777e65c214327f35f511
Last active August 11, 2016 10:44
`bundle exec derailed bundle:objects` with a Gemfile with just axlsx
Measuring objects created by gems in groups [:default, "production"]
Total allocated: 11269732 bytes (61895 objects)
Total retained: 4477284 bytes (11381 objects)
allocated memory by gem
-----------------------------------
6256569 axlsx-2.0.0
3278098 nokogiri-1.6.6.2
1100457 rubyzip-0.9.9
517043 htmlentities-4.3.4
This file has been truncated, but you can view the full file.
{"label":"","duration":18592.858384999912,"markers":[{"end":1596.5449410000583,"endStack":null,"isOffMainThread":false,"name":"nsCycleCollector::ForgetSkippable","processType":0,"stack":null,"start":1595.9524039999815},{"end":1621.1153550000163,"endStack":null,"eventPhase":2,"isOffMainThread":false,"name":"DOMEvent","processType":0,"stack":null,"start":1620.9124489999376,"type":"mousemove"},{"causeName":"EventListener.handleEvent","end":1621.1104840000626,"endStack":null,"isOffMainThread":false,"name":"Javascript","processType":0,"stack":1,"start":1620.935107999947},{"causeName":"CC_WAITING","end":1674.7230330000166,"endStack":null,"isOffMainThread":false,"name":"MinorGC","processType":0,"stack":null,"start":1673.6202110000886},{"causeName":"REFRESH_FRAME","end":1712.1202819999307,"endStack":null,"isOffMainThread":false,"name":"MinorGC","processType":0,"stack":null,"start":1711.7321020000381},{"causeName":"REFRESH_FRAME","end":1811.9146579999942,"endStack":null,"isOffMainThread":false,"name":"MinorGC","proces