Skip to content

Instantly share code, notes, and snippets.

Avatar
🧩
Focusing

agustín méndez matagus

🧩
Focusing
View GitHub Profile
View utils.js
// using jQuery
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
View json_log_decode.lua
require "cjson"
-- Generic decoder for JSON logs. This will extract all JSON
-- keys and add them to the `Fields` variable of the created
-- Heka message.
--
-- Example use:
--
-- [NginxJsonLogDecoder]
-- type = "SandboxDecoder"
View learn.lua
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@matagus
matagus / booting-and-flashing.md
Last active Aug 29, 2015
Flashing Firefox OS for Geekphone
View booting-and-flashing.md
  • Download the image you want to flash from http://downloads.geeksphone.com/ according to the geekphone model you have (keon, peak or revolution)
  • unzip .zip
  • cd
  • If you look at the content of the directory you'll see it contains adb and fastboot Android platform tools.
  • Start adb server: sudo ./adb start-server
  • Turn on your phone and enable "Remote Debugging" under Developer settings section.
  • Plug your phone to your computer using your USB wire.
  • Check that your computer is listening to your phone: ./adb devices. You'll see something like this:
@matagus
matagus / opml.xml
Created Mar 13, 2014
planetdjango.org opml file listing all its feeds
View opml.xml
<?xml version="1.0"?>
<opml version="1.1">
<head>
<title>Planet Django</title>
<dateModified>Sat, 08 Mar 2014 20:57:35 +0000</dateModified>
<ownerName>Adomas Paltanavičius</ownerName>
<ownerEmail>adomas.paltanavicius@gmail.com</ownerEmail>
</head>
<body>
@matagus
matagus / rabbitmq.config
Last active Jan 2, 2018
a sample rabbitmq config file, tested with RabbitMQ 3.0.2, Erlang R15B01
View rabbitmq.config
[
{rabbit, [
{auth_backends, [rabbit_auth_backend_internal]},
{auth_mechanisms, ['PLAIN','AMQPLAIN']},
{backing_queue_module, rabbit_variable_queue},
{cluster_nodes, []},
{collect_statistics, coarse},
{collect_statistics_interval, 5000},
{default_permissions, [<<".*">>,<<".*">>,<<".*">>]},
{default_user, <<"guest">>},
View nginx-host.conf
server {
server_name www.sarasa.com sarasa.com;
if ($host != 'sarasa.com' ) {
rewrite ^/(.*)$ http://sarasa.com/$1 permanent;
}
# Serve an empty 1x1 gif _OR_ an error 204 (No Content) for favicon.ico
location = /favicon.ico {
empty_gif;
View languages.list
Spanish
Portuguese
English
Norwegian
Hungarian
Danish
Finish
French
Italian
Dutch
View celery-tips.txt
* If you don’t care about the results of a task, be sure to set the ignore_result option, as storing results wastes time and resources:
@celery.task(ignore_result=True)
def mytask(...)
something()
Results can even be disabled globally using the CELERY_IGNORE_RESULT setting.
* Or instead of routing it you could rate limit the task instead, so that only 10 tasks of this type can be processed in a minute (10/m):
View admin.py
from django.contrib import admin
from django.contrib.admin import SimpleListFilter
from django.utils.translation import ugettext_lazy as _
from object_images.models import ObjectImage
class ObjectImagesListFilter(SimpleListFilter):
title = _("object images")
parameter_name = "images"