Skip to content

Instantly share code, notes, and snippets.

@ProGM
ProGM / ac_streams_bench.rb
Last active June 8, 2022 19:46 — forked from palkan/ac_streams_bench.rb
ActionCable Streaming Benchmark
# rubocop disable:all
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
@ProGM
ProGM / Cookbook
Created May 15, 2022 19:18
DSL Example in Ruby
recipe :pasta do
add 1.liter, of: :water, in: :pot
turn_on :fire
wait_until :pot, :boiling?
add 1.gram, of: :salt, in: :pot
wait 1.minute
add 150.grams, of: :pasta, in: :pot
@ProGM
ProGM / cache.ts
Created December 22, 2021 10:57
Cache getters in Angular, similar to computed in Vue, using memoizee
import * as memoizee from 'memoizee';
var objIdMap = new WeakMap, objectCount = 0;
function objectId(object: any){
if (!objIdMap.has(object)) { objIdMap.set(object,++objectCount); }
return objIdMap.get(object);
}
@ProGM
ProGM / DataTable.svelte
Created December 21, 2021 20:22
Sample svelte data table implementation
<script context="module" lang="ts">
import type { SvelteComponent } from 'svelte';
export interface ColumnConfig {
sortable?: boolean;
sort?: string;
name: string;
class?: string;
default?: string;
label: string;
@ProGM
ProGM / example.ts
Last active March 30, 2022 20:36
New Model Parser for JSON::API. Used as a bases for: https://github.com/monade/json-api-parser
import { Parser } from './parser';
import 'models';
const parsable = `{
"data": [
{
"id": "2", "type": "posts",
"attributes": { "name": "My post", "ciao": null, "description": "ciao", "created_at": "2020-10-10T10:32:00Z" },
"relationships": { "user": { "data": { "id": "3", "type": "users" } } }
}
@ProGM
ProGM / arel_cheatsheet_on_steroids.md
Last active April 19, 2024 04:06
Arel cheatsheet on Steroids

Arel Cheatsheet on Steroids

A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.

Tables

posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord

Table alias

<?xml version="1.0" encoding="UTF-8"?>
<document>
<steps>
<wait>5</wait>
<press>SkipIntro</press>
<wait>3</wait>
<press>Menu/Settings</press>
<wait>3</wait>
<press>SettingsTab/Options</press>
@ProGM
ProGM / diff_folders.sh
Created March 6, 2019 06:33
Check differences between two folders in bash
#!/usr/bin/env bash
tmpfile1=$(mktemp /tmp/report.XXXXXX)
tmpfile2=$(mktemp /tmp/report2.XXXXXX)
cd "$1"
find . >> $tmpfile1
cd "$2"
find . >> $tmpfile2
@ProGM
ProGM / delete_files_recursively.sh
Last active March 6, 2019 08:18
Delete files from a google drive folder via command line
# Delete all files in the drive folder, excluding google docs
find . -type f \( ! -iname "*.gdoc" -and ! -iname "*.html" -and ! -iname "*.gsheet" -and ! -iname "*.gdraw" -and ! -iname "*.gslides" -and ! -iname "*.gform" -and ! -iname "*.gtable" -and ! -iname Icon\? \) -delete
@ProGM
ProGM / example.js
Last active September 3, 2017 17:06
Example indiexpo API implementation in Javascript
/*
* An usage example of the previous library
*/
function loadData() {
// Send score 1
indiexpo.sendScore(1).then(function(data) {
console.log('score sent, response:', data);
});
// Get current user username