Skip to content

Instantly share code, notes, and snippets.

Unbinilium /
Last active October 30, 2023 05:59
Get started with OpenCV CUDA C++

First your OpenCV should be compiled with CUDA (and OpenGL) support to test all this features. Detect your CUDA hardware with OpenCV CUDA by:

#include <iostream>
using namespace std;

#include <opencv2/core.hpp>
using namespace cv;

#include <opencv2/cudaarithm.hpp>
using namespace cv::cuda;
sandren /
Last active April 26, 2024 12:37
Tailwind CSS best practices

Tailwind CSS best practices

Utility classes

  1. When writing a string of multiple utility classes, always do so in an order with meaning. The "Concentric CSS" approach works well with utility classes (i.e,. 1. positioning/visibility 2. box model 3. borders 4. backgrounds 5. typography 6. other visual adjustments). Once you establish a familiar pattern of ordering, parsing through long strings of utility classes will become much, much faster so a little more effort up front goes a long way!

  2. Always use fewer utility classes when possible. For example, use mx-2 instead of ml-2 mr-2 and don't be afraid to use the simpler p-4 lg:pt-8 instead of the longer, more complicated pt-4 lg:pt-8 pr-4 pb-4 pl-4.

  3. Prefix all utility classes that will only apply at a certain breakpoint with that breakpoint's prefix. For example, use block lg:flex lg:flex-col lg:justify-center instead of block lg:flex flex-col justify-center to make it very clear that the flexbox utilities are only applicable at the

<template lang='pug'>
div.drop-zone(:class='{dragging: isDragging }'
div(:class='{ hidden: uploadInProgress }' @click='openFileBrowser')
i {{label}}
input(type='file' :multiple='multiple' ref='input' style='display: none')

Business Logic / Domain Model structures for Ruby, Rails

krambertech / Component.jsx
Created July 2, 2016 10:44
ReactJS: Input fire onChange when user stopped typing (or pressed Enter key)
import React, { Component } from 'react';
import TextField from 'components/base/TextField';
const WAIT_INTERVAL = 1000;
const ENTER_KEY = 13;
export default class TextSearch extends Component {
constructor(props) {
remarkablemark /
Last active June 8, 2024 21:48
Classes - ES5 vs ES6

JavaScript Classes - ES5 vs ES6

An example that shows the difference between creating a JavaScript class and subclass in ES5 and ES6.


marioosh / Server.scala
Created May 20, 2016 08:46
Basic akka-http server
package io.scalac.conductr.example
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import{Sink, Source}
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
mlovic /
Last active June 1, 2020 16:24
Difference between mocks and stubs using ruby with mocha library

This gist aims to explain the difference between stubs and mocks and when each should be used. For an introduction to stubs and mocks, start somewhere else, like here.


  • Stub: used to isolate the object under test from its dependencies, preventing the test from being influenced by code outside the object. This way the test can't be made to fail or be broken by code which is not part of the specific functionality being tested. Stubs also lead to less code being run, which helps keep tests fast. A stub has no expectations. It doesn't care if it is called or how many times.

    For example, you might stub out a message sent to a database connection if all you are trying to test is the type of the method's return value.


maxivak /
Last active May 23, 2024 13:24
Sending emails with ActionMailer and Sidekiq

Sending emails with ActionMailer and Sidekiq

Send email asynchroniously using Sidekiq.


Create your mailer us usual:

joyrexus /
Last active August 21, 2023 16:59
Node.js streams demystified

A quick overview of the node.js streams interface with basic examples.

This is based on @brycebaril's presentation, Node.js Streams2 Demystified


Streams are a first-class construct in Node.js for handling data.

Think of them as as lazy evaluation applied to data.