Skip to content

Instantly share code, notes, and snippets.

@dsueiro
dsueiro / sm-annotated.html
Created July 5, 2014 10:23 — forked from hdragomir/sm-annotated.html
The deferred font loading logic of smashing magazine
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
<div class="modal hide fade" id="confirm-dialog">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3>Confirm</h3>
</div>
<div class="modal-body">
&nbsp;
</div>
<div class="modal-footer">
<a href="#" class="btn btn-danger">Ok</a>
<?php
function get_flag($value) {
$value = strtolower($value);
return $value === TRUE || ($value !== 'false' && !!$value);
}
$modules_dir = dir('app/etc/modules/');
$rewrites = array();
$conflicts = array();
@dsueiro
dsueiro / gist:5406417
Created April 17, 2013 18:02 — forked from anonymous/gist:3842009
Every prepareCollection
File: Adminhtml/Block/Api/Grid/Role.php
function _prepareCollection()
{
$collection = Mage::getModel("api/roles")->getCollection();
$this->setCollection($collection);
return parent::_prepareCollection();
}
+--------------------------------------------------+
File: Adminhtml/Block/Api/Role/Grid/User.php

This is a review of "Quantitative Analysis of the Full Bitcoin Transaction Graph" by Dorit Ron and Adi Shamir.

There are some incorrect details and analyses that warrant attention.

Oct. 31 UPDATE

The authors have introduced several revisions to their paper, available at the same URL as before.

The criticism below may be outdated in part or in full.

The new Secure Password Hashing API in PHP 5.5

The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:

Why do we need a new API?

Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.

'use strict';
/**
* Base class for managed objects. It expects it's descendants to have a pool
* array. Initialization and de-initialization logic should be moved to the
* initInternal and releaseInternal.
* Managed objects are marked as reusable by a call to the release method.
*/
var Managed = function() {
@dsueiro
dsueiro / Object.defineProperties.js
Created December 8, 2012 12:59 — forked from Mr0grog/Object.defineProperties.js
Object.defineProperties modeled in JS
Object.defineProperties = function(O, Properties) {
// 1. If Type(O) is not Object throw a TypeError exception.
if (typeof(O) !== "object" || O == null) {
throw TypeError("Object.defineProperties called on non-object");
}
// 2. Let props be ToObject(Properties)
var props = Object(Properties); // not *exactly* the same, but similar enough
// 3. Let names be an internal list containing the names of each enumerable own property of props.
@dsueiro
dsueiro / gist:4190910
Created December 2, 2012 20:28 — forked from paulirish/gist:4158604
Learn JavaScript concepts with recent DevTools features

Learn JavaScript concepts with the Chrome DevTools

Authored by Peter Rybin , Chrome DevTools team

In this short guide we'll review some new Chrome DevTools features for "function scope" and "internal properties" by exploring some base JavaScript language concepts.

Closures

Let's start with closures – one of the most famous things in JS. A closure is a function, that uses variables from outside. See an example:

@dsueiro
dsueiro / windows.h__.js
Created November 23, 2012 15:36
windows.h.js INFINITY
var ffi = require('ffi'),
ref = require('ref'),
Struct = require('ref-struct'),
Library = require('./Library'),
Type = ref.Type,
NULL = ref.NULL,
isNull = ref.isNull;
var groups = ['libs', 'types', 'structs', 'callbacks', 'enums'];