Skip to content

Instantly share code, notes, and snippets.

View RafaAguilar's full-sized avatar

Rafael Aguilar RafaAguilar

View GitHub Profile
#!/usr/bin/env python
import logging
import pycurl
import json
from cgi import escape
from StringIO import StringIO
logging.basicConfig(filename='invoices_missing.log',level=logging.DEBUG)
example_invoice_json = '{"against_income_account":"Revenue - C\u0026C","total_commission":0.0,"write_off_amount":0.0,"naming_series":"SINV-","fiscal_year":"2014-2015","doctype":"Sales Invoice","total_advance":0.0,"conversion_rate":1.0,"total":25.0,"customer_name":"31 PTE. LTD.","paid_amount":0.0,"apply_discount_on":"Grand Total","update_stock":0,"packed_items":[],"base_total":25.0,"selling_price_list":"Standard Selling","source":"","base_grand_total":25.0,"recurring_type":"","docstatus":0,"territory":"Venezuela","base_in_words":"BSF Twenty Five only.","due_date":"2015-07-31","ignore_pricing_rule":1,"advances":[],"company":"Fake COMPANY","is_opening":"No","grand_total":25.0,"base_discount_amount":0.0,"outstanding_amount":25.0,"customer_address":"Customer 1","base_rounded_total":25.0,"base_total_taxes_and_charges":0.0,"rema

#Screen brightness / backlight on Sony Vaio #Tested series VPCEG

create /usr/share/X11/xorg.conf.d/20-intel.conf

Section "Device"
        Identifier  "card0"
        Driver      "intel"
 Option "Backlight" "intel_backlight"

#Bluetooth mouse won't reconnect - Specific case Microsoft Mouse

Scan for your mouse Info

# hcitool scan

KDE users:

then edit this /usr/share/apps/bluedevilwizard/pin-code-database.xml

def dump_sitemap(site_name,products):
frmt = 'csv'
logger.debug("Monkey #" + str(os.getpid()) + " Writing Sitemap to " + site_name + "." + frmt)
if frmt == 'json':
site_map_file = open(site_name + ".json","w")
site_map_file.write(json.dumps(products['urlset']))
elif frmt == 'csv':
site_map_file = open(site_name + ".csv","w")
products = products['urlset']['url']
for p_index in range(1,len(products)):

#RVM & Rails 4 on Mageia 5

This guide try to be a guidetrough to install rvm & rails 4 as a single user on Mageia 5

  • Enable sudo: Follow, estrictly, this guide

  • Install Pre-requisites

Run as root(or sudo):

#Codec for play mp4a not found - VLC

To workaorund this you should enable the repos Tainted Release, Tainted Updates (in my case, also Tainted Backports):

Then update the whole system, now you VLC should play properly (with audio) mp4 videos.

@RafaAguilar
RafaAguilar / flaskwithcron.py
Last active November 18, 2015 03:18 — forked from chadselph/flaskwithcron.py
flask with "cron"-like loop
from flask import Flask, render_template, jsonify, request
from threading import Timer, Thread
from time import sleep
app = Flask(__name__)
@app.route("/api/<method>")
def api(method):
data = {
@RafaAguilar
RafaAguilar / order_OrderedDict.py
Last active January 30, 2016 01:32
Order an OrderedDict with numeric String keys
def str_num_order_odict(odict):
return OrderedDict(sorted(odict.items(), key=lambda x: int(x[0])))
@RafaAguilar
RafaAguilar / get_not_null_and_no_default_fields.sql
Created January 31, 2016 03:57
Obtain _not null_ and with no _default value_ fields of a table (useful when you need an _INSERT_ test statement of a big table)
SELECT
COLUMN_NAME AS `Field`
FROM
information_schema.COLUMNS
WHERE
TABLE_SCHEMA = 'schemaName'
AND TABLE_NAME = 'tableName'
AND IS_NULLABLE = 'NO'
AND (COLUMN_DEFAULT IS NULL
OR COLUMN_DEFAULT = '')