Skip to content

Instantly share code, notes, and snippets.

View wodCZ's full-sized avatar

Martin Janeček wodCZ

View GitHub Profile
@tugascript
tugascript / build-mercurius-federated-schema.util.ts
Created April 15, 2022 09:39
Mercurius drivers with plugins
import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { transformSchema } from '@nestjs/graphql';
import { BuildFederatedSchemaOptions } from '@nestjs/graphql';
import { GraphQLSchema, isObjectType, buildASTSchema } from 'graphql';
import { forEach } from 'lodash';
export function buildMercuriusFederatedSchema({
typeDefs,
resolvers,
}: BuildFederatedSchemaOptions) {
@miguelmota
miguelmota / Makefile
Last active June 11, 2024 00:17
Makefile docker push to AWS Elastic Container Registry (ECR)
# Login to AWS registry (must have docker running)
docker-login:
$$(aws ecr get-login --no-include-email --region us-east-1 --profile=mycompany)
# Build docker target
docker-build:
docker build -f Dockerfile --no-cache -t mycompany/myapp .
# Tag docker image
docker-tag:
@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
<?php
use Kdyby;
use Kdyby\RabbitMq\Connection;
use Kdyby\RabbitMq\DI\RabbitMqExtension;
use Nette;
use Nette\Reflection\ClassType;
use PhpAmqpLib\Message\AMQPMessage;
use Tester;
<?php
class CategorySpecification
{
private $category;
public function __construct($category)
{
$this->category = $category;
}

Meteor Alternatives Per Feature

This table was created in 2015 so may be quite outdated today.

Feature Meteor Solution Alternative Solutions Description
Live DB Sync [livequery][lq] ([mongo-oplog]), [ddp] RethinkDB, Redis, ShareDB, [npm:mongo-oplog], [firebase], etc. Push DB updates to client/server.
Latency Compensation, Optimistic UI [minimongo][mm] [RethinkDB][lcr], [mWater/minimongo] (fork, not ws but http, browserify) Imitate successful db query on client before it is done.
Isomorphic Code [isobuild] & isopacks browserify Write one code for server/client/mobile.
Isomorphic Packaging [isobuild], atmosphere No more separate packages for server & client. Get bower + npm + mobile.
@juzna
juzna / 01-server-config-in-git.md
Last active November 9, 2021 07:27
Server Configuration in git

Server Configuration in git

With git you can have anything versioned. You're used to version your code, which is a bunch of files. Your server configuration (on Linux) is also just a bunch of files, so it can be versioned as well.

The idea is simple: create a git repository in /etc/ and commit everytime you change any configuration of your server. Written in code:

cd /etc
git init
git add .
@extraordinaire
extraordinaire / reconnecting_pdo.php
Last active June 27, 2023 11:12
Reconnectable PDO
<?php
class ReconnectingPDO
{
protected $dsn, $username, $password, $pdo, $driver_options;
public function __construct($dsn, $username = "", $password = "", $driver_options = array())
{
$this->dsn = $dsn;
$this->username = $username;
$this->password = $password;