Skip to content

Instantly share code, notes, and snippets.

View tejastank's full-sized avatar

Tejas Tank tejastank

View GitHub Profile
@tejastank
tejastank / MagentoClient.java
Created June 25, 2012 04:45 — forked from regisbamba/MagentoClient.java
example XML-RPC client for Magento API
import redstone.xmlrpc.XmlRpcClient;
import redstone.xmlrpc.XmlRpcException;
import redstone.xmlrpc.XmlRpcFault;
import java.net.MalformedURLException;
import java.util.HashMap;
import redstone.xmlrpc.XmlRpcArray;
import redstone.xmlrpc.XmlRpcStruct;
public class MagentoClient {
@tejastank
tejastank / javascript_date_add_days
Created June 25, 2012 07:26
javascript : date add days
dd = new Date();
dd.setDate(dd.getDate()+14); // this works as expected.
or below code :
var today = new Date();
@tejastank
tejastank / gist:2988192
Created June 25, 2012 12:01
dhtmlxscheduler-see-next-more-months
At dhtmlxscheduler_debug.js , near line number : 2436
Default you can see one month :
scheduler._reset_month_scale=function(b,dd,sd){
var ed=scheduler.date.add(dd,1,"month");
With month view to see next 3 month :
@tejastank
tejastank / gist:3096755
Created July 12, 2012 08:42
Python smtp email smtplib
import smtplib
to = '22.22@22.com'
gmail_user = '22222@gmail.com'
gmail_pwd = '22222'
smtpserver = smtplib.SMTP("smtp.gmail.com",587)
smtpserver.ehlo()
smtpserver.starttls()
smtpserver.ehlo
smtpserver.login(gmail_user, gmail_pwd)
@tejastank
tejastank / gist:3100527
Created July 12, 2012 19:55
OpenERP-smpt-email-send-code
"""
Within OpenERP sometime its critical to manage simple email sending feature.
So to make easy it, use below code inside your model.
Just add this method inside your model. also set smtp user and password details with method.
This works fine with a lots of system.
== To use ==
@tejastank
tejastank / gist:3100658
Created July 12, 2012 20:14
OpenERP-Module-Model.py File
# -*- coding: utf-8 -*-
# First import python library or package or files
import smtplib
# Then import openerp related packages or libs
from osv import fields, osv
import addons
@tejastank
tejastank / python-ssh-client
Created July 16, 2012 11:33
Python ssh client
# AGPL
# Tejas.tank.mca@gmail.com,
# Developing network ssh scanner tool by IP addresses.
import socket, sys
import libssh2
DEBUG=False
usage = """Do a SSH remote command with username@hostname Usage: %s <hostname> <username> <password> <command>""" % __file__[__file__.rfind('/')+1:]
@tejastank
tejastank / gist:3134456
Created July 18, 2012 05:47
Python read emails/fetch emails
#!/usr/bin/env python
''' Utility to scan my mailbox for new mesages from Logwatch on systems and then
grab useful info from the message and output a summary page.
'''
import os, sys, imaplib, rfc822, re, StringIO
server ='mail.brianlane.com'
username='yourusername'
password='yourpassword'
getrecords:function(model,domain){
domain = [[1,'=',1]]; // conditional parameter to filter data from server.
var ids = this.rpc.db(["database_name","userid","password",model,"search", [
domain,"",((this.currentpage) * this.listlimit),this.listlimit
]])
// var field_names = _.pluck(this.ir.data.viewarch.field.tree.field ,'name'); // with form view this does not require.
var recs = this.rpc.db(["database_name","userid","password",model,"read", [
ids
]]);
@tejastank
tejastank / gist:3150725
Created July 20, 2012 13:31
OpenERP Leave Request shedular
# Need to import , import smtplib
def notify_leave_approval(self, cr, uid, ids=False, context=None):
print "leave notification...."
leave_ids = self.search(cr, uid, [('state','=','confirm')], context=context)
leaves = self.browse(cr, uid, leave_ids, context=context)
for leave in leaves:
email_from = leave.employee_id.work_email or "tejas.tank.mca@gmail.com"
email_to = leave.employee_id.parent_id.work_email or "tejas.tank.mca@gmail.com"
subject = "Auto Email Sender"