Skip to content

Instantly share code, notes, and snippets.

@rsp
rsp / better-box-model-no-box-model.md
Last active July 19, 2023 04:12
Better Box Model == No Box Model - how to solve problems with CSS3 box-sizing: border-box; https://twitter.com/pocztarski/status/489619558991675393

Better Box Model == No Box Model

The premise is that a better box model would be no box model at all, or rather no dependence on any particular box model that happens to be in use.

This proposal specifies new CSS properties that would make working with issues related to box-sizing easier and less error prone.

Problems

@pacotole
pacotole / csstoinline_EN.md
Last active August 16, 2022 14:32
Copy CSS rules to inline styles

Copy CSS rules to inline styles

It's very useful for email layout. You can add css styles in header <style> tag and after apply this script to get the HTML with inline styles.

// remove duplicates from array
// http://www.etnassoft.com/2011/06/24/array-unique-eliminar-valores-duplicados-de-un-array-en-javascript/
Array.prototype.unique = function(a){
  return function(){return this.filter(a)}
}(function(a,b,c){return c.indexOf(a,b+1)<0});
@azinasili
azinasili / px-to-em.scss
Last active August 1, 2023 22:14
Convert px values to em
// Functions and mixin to convert `px` values into `em` units
//
// px-to-em can easily be changed to `rem` values
// Change any instance of `em` to `rem`
//
// EXAMPLE:
// .foo {
// @include em(margin, 10px auto);
// padding: em(1px 2 3px 4);
// }
@yuval-a
yuval-a / js-micro.js
Last active November 28, 2024 08:13
Javascript micro-optimizations
NOTE: This document is OLD - and most of the tips here are probably outdated, since newer versions of Javascript have been
released over the years - with newer optimizations and more emphasis on optimizing newly supported syntax.
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
@elad-yosifon
elad-yosifon / sortJSON.js
Last active March 8, 2023 04:39
JSON object sort by key - recursive
/**
* this is a utility.
* should NOT be used in production!
*/
function sortJSON(object) {
if (object instanceof Array) {
for (var i = 0; i < object.length; i++) {
object[i] = sortJSON(object[i]);
}
return object;
@ambroisemaupate
ambroisemaupate / security.conf
Last active May 21, 2025 12:55
Nginx CSP example
# config to don't allow the browser to render the page inside an frame or iframe
# and avoid clickjacking http://en.wikipedia.org/wiki/Clickjacking
# if you need to allow [i]frames, you can use SAMEORIGIN or even set an uri with ALLOW-FROM uri
# https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options
add_header X-Frame-Options SAMEORIGIN;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
# https://www.owasp.org/index.php/List_of_useful_HTTP_headers
# currently suppoorted in IE > 8 http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
@NicolasRitouet
NicolasRitouet / changelog.js
Last active June 1, 2023 11:10
Changelog.js
#!/usr/bin/env node
// TODO(vojta): pre-commit hook for validating messages
// TODO(vojta): report errors, currently Q silence everything which really sucks
'use strict';
var child = require('child_process');
var fs = require('fs');
var util = require('util');
@milanaryal
milanaryal / schema-org-structured-data-markup-using-microdata.html
Last active May 6, 2025 19:06
An example of how to mark up a HTML5 webpage using the schema.org schemas and microdata.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Site Title</title>
<link rel="stylesheet" href="/assets/css/style.min.css">
@rolaveric
rolaveric / mixinSchema.json
Created March 28, 2015 02:29
Example of using "allOf" to make JSON Schema mixins
{
"definitions": {
"nameMixin": {
"type": "object",
"properties": {
"nameFirst": {"type": "string"},
"nameLast": {"type": "string"}
},
"required": ["nameFirst", "nameLast"]
},
@daniel-aranda
daniel-aranda / instructions.txt
Last active December 27, 2022 22:06
Git split components :: Using PHP Splitter to forward Laravel component
#INSTRUCTIONS
Those instructions would move the Laravel Cache component into a desired repo, given a specific tag
1. Go to any folder that you desire, for example: /tmp/splitter/
2. Run: git clone [email protected]:daniel-aranda/PHP-Git-Component-Splitter.git
3. Run: composer update
4. Copy from this gist "splitter.config.json" and put on your cloned folder under bin.
5. Run: php bin/daniel-splitter.php --tag v5.0.0