Skip to content

Instantly share code, notes, and snippets.

@pilsy
pilsy / ThreadWorkflow.ts
Created January 24, 2025 13:06
chrono-forge-example.ts
import {
ChronoFlow,
StatefulWorkflow,
StatefulWorkflowParams,
StatefulWorkflowOptions,
ManagedPaths,
Property,
On,
interceptors,
ManagedPath,
@pilsy
pilsy / batch-operation.sh
Last active January 26, 2025 15:39
Bella V2
temporal workflow signal \
--workflow-id MyWorkflowId \
--name MySignal \
--input '{"Input": "As-JSON"}' \
--query 'ExecutionStatus = "Running" AND WorkflowType="YourWorkflow"' \
--reason "DoSomething"
@pilsy
pilsy / timepan.ts
Created March 1, 2019 05:37 — forked from ranwahle/timepan.ts
.Net-like timespan class in TypeScript
const MILLISECONDS_IN_A_SECOND: number = 1000;
const SECONDS_IN_A_MINUTE: number = 60;
const MINUTES_IN_AN_HOUR: number = 60;
const HOURS_IN_A_DAY: number = 24;
const DAYS_IN_A_WEEK: number = 7;
const MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
const MILLISECONDS_IN_AN_HOUR = MILLISECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR;
const MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_AN_HOUR * HOURS_IN_A_DAY;
const MILLISECONDS_IN_A_WEEK = MILLISECONDS_IN_A_DAY * DAYS_IN_A_WEEK;
@pilsy
pilsy / userland_brew.sh
Created September 17, 2018 05:09
Brew me B$#%%
#!/bin/bash
set -ex
export HOMEBREW_PREFIX=~/homebrew
# export HOMEBREW_NO_ANALYTICS=1
mkdir -p "${HOMEBREW_PREFIX}"
curl -fsSLk https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C "${HOMEBREW_PREFIX}"
ls -laR "${HOMEBREW_PREFIX}"
@pilsy
pilsy / cleverstack-model-field-definition-complete-example.js
Created November 2, 2015 03:22
A complete example of defining a model field in the CleverStack Framework - http://cleverstack.io/developer/
Model.extend({ /* @Prototype */
// ...
field: {
validate: {
is: ["^[a-z]+$",'i'], // will only allow letters
is: /^[a-z]+$/i, // same as the previous example using real RegExp
not: ["[a-z]",'i'], // will not allow letters
isEmail: true, // checks for email format (foo@bar.com)
isUrl: true, // checks for url format (http://foo.com)
isIP: true, // checks for IPv4 (129.89.23.1) or IPv6 format
@pilsy
pilsy / how-to-use-model-instance-methods-in-cleverstack-clever-orm.js
Created November 2, 2015 00:57
An example of using model instance methods with the CleverStack Node.js Framework Module clever-orm - http://cleverstack.io/developer/
Model.extend('User',
{
type: 'ORM'
},
{
hashPassword: function(password) {
this.debug('Hashing users password');
this.password = crypto.createHash('sha1').update(password).digest('hex');
}
});
@pilsy
pilsy / how-to-use-getters-and-setters-in-cleverstack-clever-orm.js
Created November 2, 2015 00:49
An example of using custom getters/setters in the CleverStack Node.js Framework Module clever-orm - http://cleverstack.io/developer/
Model.extend('User',
{
type : 'ORM'
},
{
firstName : String,
setFirstName : function(firstName) {
this.entity.dataValues.firstName = 'foo' + firstName;
},
@pilsy
pilsy / how-to-use-include-in-cleverstack-clever-orm.js
Created November 2, 2015 00:44
An example of using the include attribute in the CleverStack Node.js Framework Module clever-orm - http://cleverstack.io/developer/
include: [
{
// Required, the model you want to eager load
model: UserModel,
// Required if the assocation is aliased 'as'
as: 'users',
// Optional, smart where for the query
where: {},
@pilsy
pilsy / how-to-use-order-in-cleverstack-clever-orm.js
Created November 2, 2015 00:41
An example of using the order attribute in the CleverStack Node.js Framework Module clever-orm - http://cleverstack.io/developer/
order: [
'name',
// will return `name`
'username DESC',
// will return `username DESC` -- i.e. don't do it!
['username', 'DESC'],
// will return `username` DESC
Model.fn('max', Model.col('age')),
// will return max(`age`)
[Model.fn('max', Model.col('age')), 'DESC'],
@pilsy
pilsy / dynamic-finders-in-cleverstack-clever-orm.js
Created November 2, 2015 00:39
Dynamic Finders in the CleverStack Node.js Framework Module clever-orm - http://cleverstack.io/developer/
findByName
findByNameIn
findByNameLike
findByNameNotLike
findByNameILike
findByNameNotILike
findByNameStartsWith
findByNameEndsWith
findByNameNot
findByNameNotEqual