Skip to content

Instantly share code, notes, and snippets.

@oshihirii
oshihirii / example_webpack.config.js
Last active August 27, 2019 08:18
just the config i use, I’m sure it could be better but it’s worked for me for a while.
const path = require('path');
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
// see: https://stackoverflow.com/a/28989476
var webpack = require("webpack");
console.log("the __dirname is: " + __dirname);
module.exports = {
mode: "production",
@elalemanyo
elalemanyo / ampify_img.php
Last active August 27, 2021 12:33
Make img AMP-ready
<?php
/**
* Replace img tag with amp-img
*
* <amp-img src="[src]"
* width="[width]"
* height="[height]"
* layout="responsive"
* alt="[alt]">
* </amp-img>
@jsit
jsit / soundcloud.php
Last active June 7, 2021 05:12
PHP preg_replace strings for AMP HTML extensions
$body = preg_replace( '/<iframe\b[^>]*soundcloud.com\/tracks\/(\d*).*"[^>]*>(.*?)>/', '<amp-soundcloud height=300 layout="fixed-height" data-trackid="$1" data-visual="true"></amp-soundcloud>', $body );
@m1kah
m1kah / chevron-arrow.css
Created October 4, 2015 17:06
CSS chevron arrow
#chevron-arrow {
display: inline-block;
border-right: 4px solid black;
border-bottom: 4px solid black;
width: 10px; height: 10px;
transform: rotate(-45deg);
}
@sohyl87
sohyl87 / jQuery: append JS file to <head>
Last active April 24, 2019 03:54
Append JS file to the Head or body from anywhere (footer) in the page
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
@wisbey
wisbey / PHP remove empty row from array
Created October 3, 2012 11:52
PHP: removing row from a multidimensional array if empty
$arr = array(... your multi dimension array here ...);
foreach($arr as $idx => $row) {
if (preg_grep('/^$/', $row)) {
unset($arr[$idx]);
}
}