Skip to content

Instantly share code, notes, and snippets.

@nicocrm
nicocrm / gist:858086
Created March 7, 2011 04:50
SalesForce Apex CSV Parser
/**
* Used to read a delimited file.
*/
public class SSSCsvReader {
private String delim = ',';
// the input data
private String[] buffer;
public SSSCsvReader(String data){
this.buffer = data.split('\n');
@isTest
private class SSSCsvReaderTest {
static testmethod void testSplitCsvSimple(){
String line = 'abc,efg';
String[] splitted = new SSSCsvReader(line).readLine();
System.assertEquals(2, splitted.size());
System.assertEquals('efg', splitted[1]);
System.assertEquals('abc', splitted[0]);
}
/**
* Used to read a delimited file.
*/
public class SSSCsvReader {
private String delim = ',';
// the input data
private String[] buffer;
public SSSCsvReader(String data){
this.buffer = data.split('\n');
@nicocrm
nicocrm / SlxRwEl.cs
Created October 15, 2021 05:00
Static class containing utilities to decrypt strings encrypted with the SLX RW EL
/// <summary>
/// Static class containing utilities to decrypt strings encrypted with the SLX RW EL
/// </summary>
public class SlxRwEl
{
/// <summary>
/// Decode the specified data.
/// </summary>
/// <param name="data"></param>
@nicocrm
nicocrm / gist:858089
Created March 7, 2011 04:52
CSV Reader Test
@isTest
private class SSSCsvReaderTest {
static testmethod void testSplitCsvSimple(){
String line = 'abc,efg';
String[] splitted = new SSSCsvReader(line).readLine();
System.assertEquals(2, splitted.size());
System.assertEquals('efg', splitted[1]);
System.assertEquals('abc', splitted[0]);
}
<?php
// Execute with php -S 0.0.0.0:3000 to serve API
// And point the client to http://localhost:3000/cors-proxy.php/api
//
$path = $_SERVER['PATH_INFO'];
$base_url = MY_BASE_URL;
$url = $base_url . $path;
if(isset($_SERVER["QUERY_STRING"])) {
$url = $url . '?' . $_SERVER["QUERY_STRING"];
@nicocrm
nicocrm / nc.js
Created February 9, 2016 20:33
A simple netcat type tool for Windows (or anything really since it's written in javascript but no reason to use it on Linux)
var http = require('http');
var stdin = process.openStdin();
const PORT = 8080;
function handleRequest(request, response) {
console.log('Incoming request...');
body = '';
request.on('data', function(chunk) {
body += chunk;
});
@nicocrm
nicocrm / switchByProp.js
Last active March 26, 2018 21:43
transitionProps - a HOC to help build transitions with react-transition-group v2. Very nice with styled-components.
// build a switch function that examines a key/value collection based on an object literal,
// and return the first match
//
// Example usage:
// ```
// const result = switchBy({
// entering: 'A',
// entered: 'B',
// default: 'C'
// })(props)
#set($stringObjectName = "${pagegenerator.FormName}${qfcontrol.ControlId}_Strings")
## -----------Column and Grid macros -----------------------------------------------
#macro(doDefaultColParts $col)
field: '$col.DataField',
#if($col.TextFormatString != "")
displayFields: ['$col.DataField'],
displayFormatString: ${stringObjectName}['$generator.ConvertResourceKeyToScriptReference($col.getColResourceKey("FormatString"))'] || '$col.TextFormatString',
#end
#doHideCondition($col)
label: ${stringObjectName}['$generator.ConvertResourceKeyToScriptReference($col.getColResourceKey("ColumnHeading"))'] || '$col.ColumnHeading',
@nicocrm
nicocrm / CustomDashboardPageSetting.js
Last active May 8, 2017 21:25
Javascript Snippets for Infor CRM
define(['Sage/UI/Dashboard/DashboardPage', 'dojo/aspect', 'dojo/query', 'dojo/dom-construct', './MultiSelectDropdown', './PicklistDataStore'],
function (DashboardPage, aspect, query, domConstruct, MultiSelect, PicklistDataStore) {
var _portalAccess = undefined;
aspect.after(DashboardPage.prototype, '_editOptionsMenu', function () {
var trButtons = query('.dijitDialog .edit-options-table > table > tbody > tr');
if (trButtons.length == 0) {
console.warn('Unable to find options dialog');
return;
}