Skip to content

Instantly share code, notes, and snippets.

import java.util.ArrayList;
import javax.print.Doc;
import javax.print.DocFlavor;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.SimpleDoc;
import javax.swing.JOptionPane;
public class Ticket{
/**
* Este script de javascript permite trabajar transparentemente solicitudes que requieren
* protección del token CSRF por medio de AJAX JQUERY.
* Esto te permitirá hacer solcitudes a web Services de Django por medio de AJAX Jquery.
* Para utilizarlo basta con integrar el archivo DjangoAjax.js en tu directorio de JS y hacer referencia a él en tus templates
* que requieren del uso de AJAX por POST o algún otro que requiera el token CSRF.
* Este script está basado en la documentación oficial de Django https://docs.djangoproject.com
*/
$(function(){
-- GET back the object to verify that we saved it
response = {}
save = ltn12.sink.table(response)
id = objAsTable["_id"] -- get the _id field from the object table
url = "https://baas.kinvey.com/appdata/KINVEY_APP_ID/testObjects/" .. id
h = {Authorization = "Basic " .. (mime.b64("KINVEY_APP_ID:KINVEY_APP_SECRET")), ["Content-Type"] = "application/json" }
ok, code, headers = http.request{url = url, headers = h, sink = save, redirect = true, method = "GET"}
-- load required modules
http = require("socket.http") --luasocket
ltn12 = require("ltn12")
mime = require("mime")
io = require("io")
json = require("json") -- luajson
-- Create a Lua table to represent our entity to save
--- This is from our doc REST example: http://docs.kinvey.com/rest-appdata.html
jamesBond = { ["firstName"] = "James", ["lastName"] = "Bond", ["email"] = "[email protected]", ["age"] = 34 }
#include "linklabel.h"
#include <QtWidgets>
LinkLabel::LinkLabel(QWidget * parent)
:QLabel(parent)
{
connect( this, SIGNAL( clicked() ), this, SLOT( slotClicked() ) );
}
void LinkLabel::slotClicked()
# By default the behavior is:
# Primary monitor work as always and second monitor only have one and fixed workspace
# I.e. you change to next workspace, primary monitor change to this workspace and second monitor remain as is.
# The desired behaviour is:
# Primary monitor and secondary monitor are linked workspace.
# I.e. you change to next workspace, primary monitor change to this workspace and second monitor too.
$ gconf-editor
# Look for /desktop/gnome/shell/windows/workspaces_only_on_primary and set to false
@jjfajardo
jjfajardo / break_for.py
Created November 26, 2013 23:15
how to break nested for loops
#!/usr/bin/env python
#Example written by jfajardo. 2013
# This trivial program shows how to break to nested for loops, when a
# condition is TRUE
for letter in 'murcielago':
for i in range(10):
@jjfajardo
jjfajardo / minval.cpp
Last active December 28, 2015 01:49
minval.cpp find de min value in an array of C
#include <algorithm>
#include <iostream>
#include <vector>
#define NELEMS(x) (sizeof(x) / sizeof(x[0]))
using namespace std;
double minval(double x[])
{
<?php
//Documentation on:
// http://en.wikipedia.org/wiki/B%C3%A9zier_curve
//Implemented by: jfajardo.
//NOTES: This program fails with a length of array > 1020 elements.
//Binomial coefficient
function binomial_coeff($n, $k){
@jjfajardo
jjfajardo / readline.py
Created February 4, 2012 21:18
Un lector simple de lineas escrito en Python.
#!/usr/bin/python
f = open("Total_energy.dat", "r")
# print "set ylabel 'E'"
# print "set xlabel 'r'"
# print "set title 'Energia vs radio'"
for line in f:
line = line[11:15] + "\t" + line[47:58]
print line
# do something with line