Skip to content

Instantly share code, notes, and snippets.

@tudorels
tudorels / gist:d0b1e79bc2dad5aa4782508d4e760af8
Created October 4, 2023 10:56 — forked from neumino/gist:6554108
Filtering nested arrays with RethinkDB
r.table("test").filter( function(doc) {
return doc("adresses").contains(function(adress) {
return adress("city").eq("Paris")
})
})
/*
{
@Vishal-Isharani
Vishal-Isharani / historyState.ts
Created July 6, 2022 10:17
Konva js Undo/Redo History
import Konva from 'konva';
import { ShapeConfig } from 'konva/lib/Shape';
export class HistoryStat {
private static _instance: HistoryStat;
public _currentStat: any[] = [];
private _currentPointer: number = -1;
private _history: Array<Object[]> = [];
@ap1969
ap1969 / snapsvg.vue
Created July 22, 2021 09:28
Using snap-svg in Vue 3
<template>
<q-page class="flex flex-center">
<div>
<svg id="svg" width="300" height="300"></svg>
</div>
<svg width="0" height="0">
<pattern
id="pattern"
patternUnits="userSpaceOnUse"
x="0"
@seblegall
seblegall / reverseproxy.go
Last active April 15, 2025 07:36
A reverse proxy in Golang using Gin
package main
import (
"fmt"
"net/http"
"net/http/httputil"
"net/url"
"github.com/gin-gonic/gin"
)
@mikaello
mikaello / group-objects-by-property.md
Last active December 17, 2024 07:57 — forked from JamieMason/group-objects-by-property.md
Group Array of JavaScript Objects by Key or Property Value

Group array of JavaScript objects by keys

This fork of JamieMason's implementation changes the key parameter to be an array of keys instead of just a single key. This makes it possible to group by multiple properties instead of just one.

Implementation

const groupBy = keys => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = keys.map(key => obj[key]).join('-');
@JamieMason
JamieMason / group-objects-by-property.md
Created September 14, 2018 07:38
Group Array of JavaScript Objects by Key or Property Value

Group Array of JavaScript Objects by Key or Property Value

Implementation

const groupBy = key => array =>
  array.reduce((objectsByKeyValue, obj) => {
    const value = obj[key];
    objectsByKeyValue[value] = (objectsByKeyValue[value] || []).concat(obj);
    return objectsByKeyValue;
@salmoni
salmoni / goQueryTest.go
Last active October 13, 2024 12:20
Parsing HTML in Go/Golang using goQuery to extract data from only one of multiple tables. Demonstrates nested Find statements.
package main
import (
"fmt"
"log"
"strings"
"github.com/PuerkitoBio/goquery"
)
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "TearFree" "true"
Option "DRI" "3"
Option "AccelMethod" "uxa"
#Option "AccelMethod" "sna"
EndSection
@theorigin
theorigin / SQLServer-APIPost.sql
Last active March 15, 2025 03:16
SQL Server code to POST to an API
DECLARE @Object AS INT;
DECLARE @ResponseText AS VARCHAR(8000);
DECLARE @Body AS VARCHAR(8000) =
'{
"what": 1,
"ever": "you",
"need": "to send as the body"
}'
EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
@jahanson
jahanson / pasteimage.html
Created March 3, 2014 17:42
Paste image from clipboard to canvas. Convert to base64 image string.
<!DOCTYPE html>
<html>
<head>
<title>Paste Image</title>
<script type="text/javascript">
var imageObj = new Image();
window.onload = function() {
document.getElementById("pasteTarget").
addEventListener("paste", handlePaste);
var canvas = document.getElementById('canvasTarget');