Skip to content

Instantly share code, notes, and snippets.

View salami-art's full-sized avatar

salami-art

View GitHub Profile
drawRegularBadge() {
return this.getLayer(this.size.rectWidth, this.size.rectHeight + this.size.bottomSpace).then(ctx => {
this.drawRectangle(ctx, [0, 0], [this.size.rectWidth, this.size.rectHeight], this.style);
// ADD TEXT
this.getLine().then(line => {
if (this.style.midStroke) ctx.drawImage(line.canvas, 0, 0);
this.getSpacedText(this.text).then(drawnText => {
// ADD STROKE LINE
ctx.drawImage(drawnText.canvas, this.cn(this.size.padding), this.cn(this.getTextTop(this.size.rectHeight, this.size.fontSize)));
this.drawTriangle(ctx,
def do_stuff_with_data(&block)
data = 1
yield data
end
do_stuff_with_data do |data|
puts data
end
function numericValue() {
if (stringValue === "one") {
numericValue = 1;
} else if (stringValue === "two") {
numericValue = 2;
} else if (stringValue === "three") {
numericValue = 3;
}
}
class SyncPromise {
constructor( callback ) {
try{
this.returnValue = callback();
}
catch(err) {
throw err;
}
}
{
"query": {
// ...
},
"aggs": {
"uniq": {
"nested": {
"path": "nested_object"
},
"aggs": {
def combine_query(query, piece)
# this function always receives its previous return value
_query = {}.merge(query) # also tried Hash.new(), query.dup, query.clone
_query['query'] ||= {}
_query['query']['bool'] ||= {}
_query['query']['bool']['must'] ||= []
_query['query']['bool']['must'] << piece
_query
end
{
"workspace": "kolumbus",
"collection": "meteoweb",
"type": "gallery",
"advancedCategoryTerm": {
"categoryTerms": "/meteoweb",
"searchInSecondaryCategory": true,
"searchInChildCategories": true
},
"paging": {