Skip to content

Instantly share code, notes, and snippets.

View MgenGlder's full-sized avatar

Kunle Oshiyoye MgenGlder

  • GitHub
  • Dearborn, Michigan
  • 17:17 (UTC -04:00)
View GitHub Profile
@MgenGlder
MgenGlder / app.js
Created March 14, 2017 15:43
Convert string to string with unicode characters
function toUnicode(theString) {
var unicodeString = '';
for (var i=0; i < theString.length; i++) {
var theUnicode = theString.charCodeAt(i).toString(16).toUpperCase();
while (theUnicode.length < 4) {
theUnicode = '0' + theUnicode;
}
theUnicode = '\\u' + theUnicode;
unicodeString += theUnicode;
}
@MgenGlder
MgenGlder / orderdiscounts.js
Created May 3, 2017 06:28
calculate order level discounts
<isscript>
var merchTotalExclOrderDiscounts : dw.value.Money = LineItemCtnr.getAdjustedMerchandizeTotalPrice(false);
var merchTotalInclOrderDiscounts : dw.value.Money = LineItemCtnr.getAdjustedMerchandizeTotalPrice(true);
var orderDiscount : dw.value.Money = merchTotalExclOrderDiscounts.subtract( merchTotalInclOrderDiscounts );
</isscript>
@MgenGlder
MgenGlder / properties.js
Created May 4, 2017 18:08
Use variables in resource messaging- msgf
//local.properties
global.user.name={0} {1}
//some ISML
${Resource.msgf('global.user.name', 'locale', null, pdict.CurrentCustomer.profile.firstName, pdict.CurrentCustomer.profile.lastName)}
@MgenGlder
MgenGlder / Replace new lines
Created May 16, 2017 18:43
Match all new line characters in a string and replace them
"\nLUL \rLUL".replace(/\r?\n|\r/g, '');
@MgenGlder
MgenGlder / rebase.js
Created June 20, 2017 22:07
Git interactive rebase
git rebase -i origin/development
:q! => if you want to quit
:wq => if you want to save and quit (write)
@MgenGlder
MgenGlder / CheckIfAttribute.js
Created June 21, 2017 17:56
Check if an attribute belongs to an object before accessing it.
(key in inventoryRecord.custom) && inventoryRecord.custom[key] >= qtySelected;
@MgenGlder
MgenGlder / map.js
Last active December 18, 2020 03:14
Convert map to http params
mapToHttpParams(params)
function mapToHttpParams (m : Map) : String {
let s = "";
if (!empty(m)) {
for(let key in m) {
let value = m[key];
if (!empty(value)) {
s = StringUtils.format("{0}{1}{2}={3}",
s,
(s.length != 0) ? "&":"",
@MgenGlder
MgenGlder / http client.js
Created July 7, 2017 18:20
Example http client
var httpClient : HTTPClient = new HTTPClient();
var message : String;
httpClient.setTimeout(timeout || 20000);
httpClient.open('GET', crossSiteRequest, "storefront", password);
httpClient.send();
if (httpClient.statusCode == 200) {
message = httpClient.text;
}
@MgenGlder
MgenGlder / gist:538745d2d33fee38f3a572c5aded8ea1
Created July 11, 2018 11:35
Search history in terminal
history | grep <Search item>
@MgenGlder
MgenGlder / How To Read.txt
Last active July 11, 2018 17:06
How to read; Good note taking ideas
https://robertheaton.com/2018/06/25/how-to-read/