Skip to content

Instantly share code, notes, and snippets.

View fdv's full-sized avatar
🚀
Taking over the world

Fred de Villamil fdv

🚀
Taking over the world
View GitHub Profile
@fdv
fdv / elasticsearchreallocator.sh
Last active January 4, 2016 21:59
In case your Elasticsearch cluster goes red and refuses to assign some shards anymore...
# Seems you have 2 solutions left:
# - either you trash the whole index and reindex. Good luck, have fun
# - or you manually reallocate the whole thing
#
# Guess what I'll pick up
curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
"commands": [
{
"allocate": {
@fdv
fdv / gist:8800597
Created February 4, 2014 09:32
Gracefully restart an ES cluster
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.disable_allocation": true}}'
/etc/init.d/elasticsearch restart
curl -XPUT localhost:9200/_cluster/settings -d '{"transient":{"cluster.routing.allocation.disable_allocation": false}}'
# Easier way to install FreeBSD 10 on a Dedibox using the rescue system
# - no vnc
# - no qemu network unable to join the host network issue
sudo su -
aptitude update
aptitude install
wget ftp://ftp.free.fr/mirrors/ftp.freebsd.org/ISO-IMAGES-amd64/10.0/FreeBSD-10.0-RELEASE-amd64-disc1.iso
sudo qemu-system-x86_64 -hda /dev/sda -cdrom ./FreeBSD-10.0-RELEASE-amd64-disc1.iso -display curses -boot d
linking shared-object nokogiri/nokogiri.so
/usr/bin/ld: /usr/local/lib/ruby/gems/1.9/gems/nokogiri-1.6.1/ports/libxslt/1.1.26/lib/libexslt.a(common.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/ruby/gems/1.9/gems/nokogiri-1.6.1/ports/libxslt/1.1.26/lib/libexslt.a: could not read symbols: Bad value
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** Error code 1
Stop.
make: stopped in /usr/local/lib/ruby/gems/1.9/gems/nokogiri-1.6.1/ext/nokogiri
document.getElementbyId('boobs').innerHTML = document.head.innerHTML;
document.head.innerHTML = '';
- name: create the {{ launch_config }} launch config
local_action: >
ec2_lc
aws_access_key={{ ec2_access_key }}
aws_secret_key={{ ec2_secret_key }}
region={{ region }}
name={{ launch_config }}
image_id={{ image_id }}
key_name={{ keypair }}
security_groups={{ group }}
@fdv
fdv / word-frequency-nuplet-1.rb
Last active August 29, 2015 14:03
Quick and dirty way to find nuplets word frequency in a series of texts
# coding utf-8
=begin
Working on y blog internal linking, I started to think about a better than just tags way to find similarities between texts.
I wanted to find 2 and 3 words similarities betwen my posts, so I wrote that quick and dirty script to do it. I'm then comparing the token appearing 2 to 5 times with the tags used in the article to build my "related posts" link.
Results are not great so far, because I'm working with only a 1200 articles with very unique content. Next step is to include a list of synonymouses to get better results.
=end
dig -t ns @ns1.7el.net t37.net
; <<>> DiG 9.8.3-P1 <<>> -t ns @ns1.7el.net t37.net
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33441
;; flags: qr aa rd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2
;; WARNING: recursion requested but not available
# In the main vhost config
proxy_cache_path /var/cache/nginx levels=1:2
keys_zone=microcache:5m max_size=1000m;
# In the location /
# Init cache bypass
set $no_cache "";
# If non GET/HEAD, don't cache & mark user as uncacheable for 1 second via cookie
NoMethodError (undefined method `with_scope' for #<Class:0x0000001ef7f3c8>):
app/models/trigger.rb:37:in `remove'
app/models/article/states.rb:145:in `published_at='
lib/stateful.rb:65:in `published_at='
app/controllers/admin/content_controller.rb:157:in `update_article_attributes'
app/controllers/admin/content_controller.rb:70:in `update'