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
document.getElementbyId('boobs').innerHTML = document.head.innerHTML;
document.head.innerHTML = '';
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
# 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
@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}}'
@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": {
#!/bin/bash
KITTEN_SITE_URL="http://emergencykitten.com"
KITTEN_IMG_FILE=kitten.jpg
KITTEN_SECS=$1
usage(){
echo "Usage : $(basename $0) <sleep_time>"
echo "Exemple : $(basename $0) 60"
exit 1

Every article about Nginx optimization talks about using the sendfile, tcp_nodelay and tcp_nopush settings. Unfortunately, none of them explains neither why they should be used, nor how they actually work.

A few weeks ago, as we were building Botify SAAS platform, we started working on the Web server performances. As we're relying a lot on peer review to improve the quality of our work, Greg left my pull request open with questions, lots of questions, most of them starting with "Why?".

As we didn't find any obvious answer, we started a journey inside the Linux Kernel TCP stack, trying to understand Nginx internals and why we should combine 2 options as opposed as tcp_nopush and tcp_nodelay.

tcp_nodelay

How can I force a socket to send the data in its buffer? One answer to that tricky question lies in the TCP_NODELAY option of the Linux TCP(7) stack. When you

@fdv
fdv / gist:8385670
Created January 12, 2014 15:01
Big merge is big.
Branch: refs/heads/master
Home: https://github.com/fdv/publify
Commit: 0cd73579fbbe14e6934fd69f4a3ceb727c4c8ab2
https://github.com/fdv/publify/commit/0cd73579fbbe14e6934fd69f4a3ceb727c4c8ab2
Author: Frédéric de Villamil <[email protected]>
Date: 2013-11-08 (Fri, 08 Nov 2013)
Changed paths:
R app/assets/images/admin/glyphicons-halflings.png
R app/assets/javascripts/bootstrap-affix.js
# Dans mon controleur
respond_to do |format|
format.js {
render 'autosave'
}
end
# Ma vue
<%= javascript_tag "alert('All is good');" %>
# dans autosave
respond_to do |format|
format.js
end
# autosave.js.erb
$('#autosave').replaceWith("<%= hidden_field_tag('article[id]', @article.id) %>")
$('#destroy_link').replaceWith('<%= link_to_destroy_draft(@article) %>')
$('#publish').replaceWith("<%= text_field_tag('article', 'published_at', {:class => 'span7 datepicker'}) %>")