Skip to content

Instantly share code, notes, and snippets.

final class CacheLRU<Key: Hashable, Value> {
private struct CachePayload {
let key: Key
let value: Value
}
private let capacity: Int
private let list = DoublyLinkedList<CachePayload>()
private var nodesDict = [Key: DoublyLinkedListNode<CachePayload>]()
@gnutix
gnutix / Fixture.yml
Last active March 14, 2024 04:53
Custom Faker Provider for generating Symfony encoded password using UserPasswordEncoderInterface.
Symfony\Component\Security\Core\User\User:
member:
__construct: ['member', '<symfonyPassword("Symfony\Component\Security\Core\User\User", "member", "salt")>', ['ROLE_USER']]
admin:
__construct: ['admin', '<symfonyPassword("Symfony\Component\Security\Core\User\User", "admin", "salt")>', ['ROLE_ADMIN']]
@ten0s
ten0s / gist:f6b4f598a46344ab0dfd
Created June 1, 2015 10:21
Fix Vagrant's Authentication failure after re-building the box
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2202
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
@maximecolin
maximecolin / MyController.php
Created February 16, 2015 11:26
Symfony2 : add translated flash with parameters, domain or locale
<?php
namespace Acme\DemoBundle;
use Symfony\Bundle\FrameworkBundle\Controller\Controller
class MyController extends Controller
{
/**
* @Template()
@Blackshawk
Blackshawk / blog - Explaining My Choices Further.md
Last active April 25, 2023 19:31
In which I do a little digging about the choices I've made with PHP. This is a long read, but it isn't something that can be explained in one or two paragraphs.

In the comments from my last post and on Twitter I noticed a lot of people who had something to say about PHP. The comments were varied but they usally sounded something like this (sorry @ipetepete, I picked yours because it was the shortest).

...the little bits of soul from all of us who've had to work on, and or maintain large PHP applications. – ipetepete

In Pete's defense, he did go on to say that rest of the stack I was using was a "smorgasbord of awesome". Thanks, Pete. I agree!

I would, however, like to take a little time to correct a misperception in the developer community about PHP. I recently got into this same... discussion... with Jeff Atwood, and I seem to be running into it more and more. So here goes. Please bear with me as I cover a little history further on.

Pete, and everybody else, _you're exactly rig

@aniljava
aniljava / FontFromBase64.java
Created May 11, 2012 07:50
Convert Base64 Encoded data to Font OTF/TTF
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.nio.ByteBuffer;
public class FontFromBase64 {
public static void main(String[] args) throws Exception {
String infile = "text.txt";
@jonnyreeves
jonnyreeves / index.html
Created April 23, 2012 21:38
JavaScript Class Structure using requireJS. The following code shows you how to create a Class definition in one JavaScript file and then import it for use in another; coming from an ActionScript 3 background this (and some of JavaScript specific traits)
<!DOCTYPE html>
<html>
<head>
<script data-main="usage" src="http://requirejs.org/docs/release/1.0.8/comments/require.js"></script>
</head>
<body>
<p>Check your JavaScript console for output!</p>
</body>
</head>
@darkseed
darkseed / Reachability.h
Created August 30, 2011 23:16 — forked from dhoerl/Reachability.h
Reachability (iOS) ARCified
/*
File: Reachability.h
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
Version: 2.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
("Apple") in consideration of your agreement to the following terms, and your
use, installation, modification or redistribution of this Apple software