Code Snippets CoffeeScript

Short texts CoffeeScript 🧑‍💻 Code snippets CoffeeScript ✍️ Reading lists CoffeeScript 👀

Atom Settings Backup by https://atom.io/packages/sync-settings

aaa # Your init script # # Atom will evaluate this file each time a new window is opened. It is run # after packages are loaded/activated and after the previous editor state # has been restored. # # An example hack to log to the console when each text editor is saved. # # […]

user.coffee

router.post ‘/:id’, authorizedOrSelf, validation, (ctx) -> user = await User.findOne({authId:ctx.params.id}).lean().exec() throw Boom.preconditionFailed(“User already exists”) if user? user = await User.findOne({email:ctx.state.context.email}).lean().exec() throw Boom.preconditionFailed(“User with email: #{ctx.state.context.email} already exists”) if user?

Coffeescript – Ajax Request

$(document).ready -> $.ajax ‘/items/get_list’, type: ‘GET’ dataType: ‘json’ beforeSend: -> $(‘#loading’).html ” Now loading…” error: (jqXHR, textStatus, errorThrown) -> $(‘#items’).html “Error: #{textStatus}” success: (data, textStatus, jqXHR) -> $(‘#loading’).hide(); $.each data, (index, item) -> $(‘#items’).append(” + ” + item.title + ”);

Atom Settings Backup by https://atom.io/packages/sync-settings

sync # Your init script # # Atom will evaluate this file each time a new window is opened. It is run # after packages are loaded/activated and after the previous editor state # has been restored. # # An example hack to log to the console when each text editor is saved. # # […]

salesForceMedicare.coffee

# Methodology, we take the lastest group of invoca calls , and the first of that group invocas = _.groupBy lead.additionalProperties.invoca,’complete_call_id’ if _.keys(invocas).length > 1 # there’s more than one group groupId = _.chain lead.additionalProperties.invoca .sortBy (r) -> r.start_time_utc .last() .value() .complete_call_id group = invocas[groupId] else group = _.values(invocas)[0] invocation = _.chain group .sortBy (r) […]