Skip to content

Instantly share code, notes, and snippets.

View smalyshev's full-sized avatar

Stanislav Malyshev smalyshev

View GitHub Profile
#!/usr/bin/python
import urlparse
import oauth2 as oauth
import urllib
import sys
import json
from pymongo import json_util
consumer_key = 'CONSUMERKEY'
consumer_secret = 'CONSUMERSECRET'
restparams['method'] = 'oauth_access'
resp, content = client.request(url, "POST", body=urllib.urlencode(restparams))
print resp
print content
cont = json.loads(content)
sess = cont["id"]
@smalyshev
smalyshev / gist:1787270
Created February 10, 2012 06:52
job creation
<?php
$jq = new SugarJobQueue();
$job = new SchedulersJob();
$job->name = "My Job";
$job->target = "function::myjob";
$jobid = $jq->submitJob($job);
echo "Created job $jobid!\n";
@smalyshev
smalyshev / gist:2477541
Created April 24, 2012 07:38
PA5 S1 tool
import sys
import collections
import re
import itertools
macros = collections.defaultdict(list)
f = open(sys.argv[1])
for l in f:
l = l.strip()
comps = l.split("\t")
array("op" => "OR", args => array(
array("op" => "AND", args => array(
array("op" => "!=", "args" => array("$contacts.state", "CA")),
array("op" => "!=", "args" => array("$contacts.state", "OH")),
)),
array("op" => "=", args => array("$contacts@2.accounts.contacts.state", 'CA')),
array("op" => "=", args => array("$opportunities.contacts.state", 'CA')),
))
SELECT DISTINCT meetings.id, ... FROM meetings
@smalyshev
smalyshev / odo.hbt
Last active December 16, 2015 01:39
<h1>Hello {{getFieldValue model "name"}}</h1>
@smalyshev
smalyshev / data.js
Last active December 16, 2015 01:39
{name: "SugarCon"}
<?php
// get args
if($argc < 3) {
echo "Use: $argv[0] /path/to/php-5.4.16/NEWS 5.4.16\n";
exit(1);
}
// find NEWS entry
$fp = fopen($argv[1], "r");
if(!$fp) {
die("Can not open $argv[1]");
import sys
f = open(sys.argv[1], 'r')
txt = f.readline().strip()
patterns = [p.strip() for p in f]
f = open(sys.argv[2], 'r')
answers = [int(i) for i in f.readline().strip().split(' ')]
anset = set()
array(9) {
["Accounts"]=>
array(5) {
[0]=>
string(15) "billing_address"
[1]=>
string(16) "shipping_address"
[2]=>
string(15) "phone_alternate"
[3]=>