Skip to content

Instantly share code, notes, and snippets.

@argami
argami / text_width_canvas.coffee
Created September 27, 2011 17:44
Right measurement of text width on Javascript using canvas
measure_text: (text, font_size, font_family) ->
canvas = document.createElement('canvas')
ctx = window.canvas.getContext '2d'
ctx.font = "#{font_size} #{font_family}"
ctx.measureText(text).width
@argami
argami / README
Created October 8, 2011 10:20
Openerp Server Requirements
Installation instruction
curl https://raw.github.com/gist/1272098/e0199b49a72121c5e24b19275e7d544529c9e688/openerp-install.sh -o | sh
@argami
argami / Test.js
Created July 25, 2012 14:34
Error on Mocha
require('should');
function a() {
throw new Error("Oops");
return 1;
}
describe('MyLibrary', function(){
it('handles errors', function(){
a().should.equal(1);
@argami
argami / base_controller_decorator.rb
Created August 1, 2012 18:47
Locale on engine mount point (Spree)
Spree::BaseController.class_eval do
before_filter :set_user_language
def set_user_language
I18n.locale = params[:locale]
end
end
@argami
argami / steps
Created August 17, 2012 12:26
Xiki on 1.8.7
rvm install ruby-1.8.7-p358
rvm use --create 1.8.7@xiki
gem install bundler
bundle
gem build xiki.gemspec
gem install xiki-0.5.0a.gem
Output
@argami
argami / config
Created September 11, 2012 12:18
Way to patch error on ngnix and streams
upstream www.XXXXXXX.es {
server XXX.XXX.XXX.XXX:3000;
}
server {
listen 80;
server_name www.XXXX.es XXXXX.es;
location / {
proxy_pass http://www.XXXXXXX.es; #this is the upstream option

Keybase proof

I hereby claim:

  • I am argami on github.
  • I am argami (https://keybase.io/argami) on keybase.
  • I have a public key ASDBhlriQI0kaeuzUd9x-WdXxOMfPKlAtyzJzS8cyuiGiAo

To claim this, I am signing this object:

@argami
argami / prepare-commit-msg
Created January 27, 2021 15:53
Adds the branch name to the beginning of the commit message if the branch name is something like DEV-123 (3 letters-3numbers)
#!/bin/bash
# Include any branches for which you wish to disable this script
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master develop staging test)
fi
# Get the current branch name and check if it is excluded
BRANCH_NAME=$(git symbolic-ref --short HEAD)
BRANCH_NAME_VALID_FORMAT=$(echo $BRANCH_NAME | grep -c -E "^\w{3,}-\d{3,}$")
-- In pg_stat_statements, there is a problem: sometimes (quite often), it registers the same query twice (or even more).
-- It's easy to check in your DB:
--
-- with heh as (
-- select userid, dbid, query, count(*), array_agg(queryid) queryids
-- from pg_stat_statements group by 1, 2, 3 having count(*) > 1
-- ) select left(query, 85) || '...', userid, dbid, count, queryids from heh;
--
-- This query gives you "full picture", aggregating stats for each query-database-username ternary
#!/bin/bash
# install this in any folder in your path and execute it
# by fire.sh in case of a real fire to save your data
echo "Leave the building you fool i will handle it"
# adding new branch to not polute the one beign used
# and unique by user name
git checkout -b fire_starting_$(whoami)