Skip to content

Instantly share code, notes, and snippets.

View jeznag's full-sized avatar

Jeremy Nagel jeznag

View GitHub Profile
@jeznag
jeznag / SpecialFormTest.php
Last active August 29, 2015 14:20
Connecting PHPUnit with PhantomJS
<?php
include_once 'TestScaffold.php';
class SpecialFormTest extends TestScaffold
{
public function testTitle() {
$cookies=$this->cookie();
$cookies->clear();
$this->url('http://localhost/special_form/public/' );
@jeznag
jeznag / TestScaffold.php
Last active November 23, 2020 00:08
Combine PhantomJS with PHPUnit
<?php
class TestScaffold extends \PHPUnit_Extensions_Selenium2TestCase {
protected function setUp() {
$this->setBrowser( 'phantomjs' );
$this->setBrowserUrl( 'http://www.example.com/' );
$this->run_selenium_server();
$this->run_phantom_js();
}
@jeznag
jeznag / Person.js
Created May 17, 2015 04:55
Person model
import DS from 'ember-data';
import Ember from 'ember';
var inflector = Ember.Inflector.inflector;
inflector.irregular('person', 'people');
inflector.singular(/person/, 'person');
let Person = DS.Model.extend({
fullName: DS.attr( 'string' ),
@jeznag
jeznag / gist:6d08233bd3af27761a9e
Created May 17, 2015 04:57
Expected JSON payload
{
"people": [
{
"name": "Oliver Oldham",
"location": "Sydney Australia",
"description": "Enterprise Technologist in Cloud and Infrastructure. General Manager of the Cloud Practice @ Telstra, critical thinker and Jumps from perfectly good planes.",
"photo": "https://pbs.twimg.com/profile_images/422596819260936192/EAHtLc78_normal.jpeg"
},
{
"name": "Tim Love",
@jeznag
jeznag / actual JSON payload
Created May 17, 2015 04:59
Actual JSON payload from Kimono
{
"name": "followerwonk",
"count": 50,
"url": "https://followerwonk.com/bio/?q=Redacted&q_type=all&l=Sydney",
"results": {
"people": [
{
"name": "[Name redacted]",
"location": "Sydney Australia",
"description": "Enterprise Technologist in Cloud and Infrastructure. General Manager of the Cloud Practice @ Telstra, critical thinker and Jumps from perfectly good planes.",
@jeznag
jeznag / person.js
Created May 17, 2015 05:06
Person deserializer
import DS from 'ember-data';
import config from '../config/environment';
var counter = 1;
export default DS.RESTSerializer.extend({
extractSingle: function(store, type, payload, id) {
var people = payload.results.people;
payload = {
@jeznag
jeznag / gist:62f22aa9b7a54d7ed107
Created May 22, 2015 10:10
Get profile details for Zoho CRM user using deluge script
//get details for this user
userResp = getUrl(("https://crm.zoho.com/crm/private/xml/Users/getUsers?authtoken=AUTHTOKEN&scope=crmapi&type=ActiveUsers"));
info userResp;
users = userResp.executeXPath("/users/user");
if ((users != null) && (users != "")) {
userList = users.toList("-|-");
for each user in userList {
idNode = user.executeXPath("/user/@id");
id = idNode.executeXPath("/id/text()");
if (id == ownerId) {
@jeznag
jeznag / gist:836b3963f4398531e99f
Created May 22, 2015 10:12
Mass update lookups in Zoho CRM using custom function
void update_vendor_lookup (int finance_equity_id)
finance_equity_obj = zoho.crm.getRecordById("CustomModule4", finance_equity_id);
lender_string = finance_equity_obj.get("Lender");
lender_id = 0;
if (lender_string.contains("Adelaide")){
//figure out appropriate lookup value based on picklist
lender_id = 1002375000002270019;
}
@jeznag
jeznag / gist:2fb9466adeb5c302668f
Last active September 11, 2020 06:47
Bulk updating thousands of Zoho CRM records
//trick to do a while loop in Deluge script
lst_iterator = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25};
for each iterator in lst_iterator{
//can get 200 records at a time. range is like 1-200, 201-300, etc.
start_index = 200 * iterator + 1;
end_index = start_index + 199;
//find leads that don't have updated notes
leads_without_updated_notes = zoho.crm.searchRecords("Leads", "(Notes migrated|=|false)", start_index, end_index);
for each lead in leads_without_updated_notes
{
@jeznag
jeznag / gist:7e12bf5c68a36ad44fbd
Created May 31, 2015 06:58
Update amount for Zoho CRM potential based on related products
potential_obj = zoho.crm.getRecordById("Potentials", potential_id);
related_products = zoho.crm.getRelatedRecords("Products", "Potentials", potential_id.toString(), 1,200);
total_amount = 0.0;
for each product in related_products {
total_amount = total_amount + product.get("Unit Price").toDecimal();
}
potential_obj.put("Amount", total_amount);
potential_obj.put("Populate amount based on products associated", false);