Skip to content

Instantly share code, notes, and snippets.

View magsout's full-sized avatar
🦊
Coding and hacking around the world

Guillaume Démésy magsout

🦊
Coding and hacking around the world
View GitHub Profile
@tobitailor
tobitailor / get_barcode_from_image.js
Created June 1, 2010 19:33
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@chriseppstein
chriseppstein / 1_slower_sprite_file.scss
Created December 20, 2010 03:11
This gist demonstrates how a generated sprite file can be optimized to shave some time off your compile.
@import "compass/utilities/sprites/base";
// General Sprite Defaults
// You can override them before you import this file.
$emblem-sprite-base-class: ".emblem-sprite" !default;
$emblem-sprite-dimensions: false !default;
$emblem-position: 0% !default;
$emblem-spacing: 0 !default;
$emblem-repeat: no-repeat !default;
@coolaj86
coolaj86 / how-to-publish-to-npm.md
Last active April 2, 2024 20:18
How to publish packages to NPM

Getting Started with NPM (as a developer)

As easy as 1, 2, 3!

Updated:

  • Aug, 08, 2022 update config docs for npm 8+
  • Jul 27, 2021 add private scopes
  • Jul 22, 2021 add dist tags
  • Jun 20, 2021 update for --access=public
  • Sep 07, 2020 update docs for npm version
@m4dz
m4dz / README.md
Last active March 17, 2016 13:26
jQuery plugins boilerplates

This files contains my boilerplates for jQuery plugins.

mymodule {
@at-root {
.#{&}-header { ... }
.#{&}-footer { ... }
.#{&}-body {
a { ... }
span { ... }
p { ... }
}
}
@Integralist
Integralist / Description.md
Last active April 25, 2020 16:20
This is how BBC News currently implements it's Image Enhancer for responsive images. Note: this is a completely rebuilt version of the code so the BBC's original source code doesn't actually look anything like the below example.

The BBC has a server-side image service which provides developers with multiple sized versions of any image they request. It works in a similar fashion to http://placehold.it/ but it also handles the image ratios returned (where as placehold.it doesn't).

The original BBC News process (and my re-working of the script) follows roughly these steps...

  • Create new instance of ImageEnhancer
  • Change any divs within the page (which have a class of delayed-image-load) into a transparent GIF using a Base64 encoded string.
    • We set the width & height HTML attributes of the image to the required size
    • We know what size the image needs to be because each div has custom data-attr set server-side to the size of the image
    • We then set a class of image-replace onto each newly created transparent image
  • We use a 250ms setTimeout to unblock the UI thread and which calls a function resizeImages which enhances the image-replace images so their source is now set to a URL whe
@kaelig
kaelig / SassMeister-input.scss
Last active December 28, 2015 05:39
Generated by SassMeister.com.
// ----
// Sass (v3.3.0.rc.3)
// Compass (v1.0.0.alpha.18)
// ----
$guss-rem-baseline: 10px !default;
// Transform a value into rem
// Assuming baseline is set to 10px on :root/html
@function rem($value, $baseline: $guss-rem-baseline) {
@Integralist
Integralist / 1. Custom Grunt Tasks - Gruntfile.js
Last active October 20, 2017 07:39
Example of how to structure your Grunt files
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
// Store your Package file so you can reference its specific data whenever necessary
pkg: grunt.file.readJSON('package.json')
// ...tasks...
var gulp = require('gulp');
var size = require('gulp-filesize');
var stream = require('stream');
var util = require('util');
var styles = 'Assets/Styles';
var scripts = 'Assets/Scripts';
function aNewWritableStream() {
stream.Writable.call(this, { objectMode: true }); // make Stream behave like stream of objects instead of a Buffer with a set size