Skip to content

Instantly share code, notes, and snippets.

@Twister915
Twister915 / topk.rs
Last active April 21, 2022 07:30
topk
use std::marker::PhantomData;
pub enum TopK<I, E, K, F, const N: usize> {
// this TopK has just been created and no data has been computed
// this is the initial state
Prepared {
itr: I,
f: F,
_k: PhantomData<K>,
},
@freddi301
freddi301 / rust_hooks.rs
Created February 6, 2020 16:30
Rust hooks
use std::assert;
use std::rc::Rc;
mod rust_hooks {
use std::cell::{Cell, RefCell};
use std::rc::Rc;
pub trait Notifiable {
fn notify(&self);
}
@pfernandom
pfernandom / threads.rs
Last active November 9, 2018 21:42
Using multiple threads in Rust. The tests are measured to quantify the impact of concurrency.
use std::thread;
use std::time::Duration;
use std::sync::mpsc;
use std::time::Instant;
fn start(label: &String) -> Instant {
println!("Start {}", label);
Instant::now()
}
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active March 22, 2024 23:37
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@dmaicher
dmaicher / TagAwareQueryResultCache.php
Last active April 16, 2020 08:47
use symfony/cache 3.2 tag aware cache as Doctrine DBAL query result cache
<?php
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
use Symfony\Component\Cache\CacheItem;
use Symfony\Component\Cache\DoctrineProvider;
class TagAwareQueryResultCache extends DoctrineProvider
{
/**
@maryo
maryo / IsolatedKernelTestCase.php
Last active November 2, 2015 16:28
Symfony2 / Doctrine2 Tests isolation without schema reloading / DB purging + fixtures support
<?php
namespace AcmeBundle\Test;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\Common\DataFixtures\ReferenceRepository;
use Doctrine\DBAL\Connection;
use Doctrine\ORM\EntityManager;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
<?php
namespace Acme\Serializer\Normalizer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
@macromaniac
macromaniac / XHR.ts
Last active November 3, 2019 23:19
simple typescript xhr using promises
module XHR {
export class Header {
header: string;
data: string;
constructor(header: string, data: string) {
this.header = header;
this.data = data;
}
}
@joepie91
joepie91 / README.md
Last active October 28, 2015 04:50
Uploading to curl.io without a browser (but with a progress bar!)

Simply save the script in your home directory (as set-alias.sh or whatever else you want), and add the following to your .bashrc:

source ~/set-alias.sh

Don't forget to use the right filename if you've changed it!

Now you can just use the curlio command:

@norberttech
norberttech / REDME.md
Last active July 27, 2016 13:15
TuTu as a dependency of application that use Symfony2 HttpKernel Component

This gist presents how to use TuTu as a dependency of Symfony2 application instead of using standalone TuTu application.

Lets assume that we have clean Symfony 2.3.* standard application.
We are going to use following libraries:

First we need to prepare configs for TuTu, lets create following folders structure in our application.