Skip to content

Instantly share code, notes, and snippets.

View d8vjork's full-sized avatar
💰
Focused on commercial projects

Ruben Robles d8vjork

💰
Focused on commercial projects
View GitHub Profile
import Vue from 'vue'
import Moment from 'moment'
Vue.directive('moment-ago', {
update (timestamp) {
this.el.innerHTML = Moment(timestamp).fromNow()
this.interval = setInterval(() => {
this.el.innerHTML = Moment(timestamp).fromNow()
}, 1000)
@agorilla
agorilla / _map-get-next.scss
Last active March 7, 2020 11:01
Sass function map-get-next
/// Function to get next map item
/// returns next map item or fallback value if map, key or next item does not exist
/// Github Repo: https://github.com/elcheio/sass-map-get-next-prev
/// Node Module: https://www.npmjs.com/package/sass-map-get-next-prev
///
/// @author Simon Koch <agorilla@me.com>
///
/// Licensed under the MIT license.
///
/// @access public
@petrkohut
petrkohut / howto.md
Last active October 20, 2021 08:57
How to have redis-cli and psql installed on machine using Docker

How to install redis-cli and psql client on your machine with Docker

Preparing docker images

We will use minimalistic Linux distribution called Alpine (5MB)

Dockerfile of redis-cli

FROM alpine:latest
RUN apk --update add redis
@misaxi
misaxi / web.config
Created September 28, 2014 10:20
web.config for IIS hosted multi-site WordPress
<!-- http://lauragentry.com/blog/2010/07/30/how-to-create-a-wordpress-3-0-multisite-network-on-a-windows-server-using-sub-directories/ -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress Rule 1" stopProcessing="true">
<match url="^index\.php$" ignoreCase="false" />
<action type="None" />
</rule>
@remy
remy / details.js
Created April 18, 2010 22:28
Add <details> support - includes stylesheet
/**
* Note that this script is intended to be included at the *end* of the document, before </body>
*/
(function (window, document) {
if ('open' in document.createElement('details')) return;
// made global by myself to be reused elsewhere
var addEvent = (function () {
if (document.addEventListener) {
return function (el, type, fn) {
@drewjoh
drewjoh / Cors.php
Created June 13, 2016 22:47
Laravel CORS Middleware
<?php // /app/Http/Middleware/Cors.php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
return $next($request)
@mgol
mgol / ie11-only.md
Last active May 11, 2023 15:50
How to easily not serve JS and/or CSS to IE<11

Here's how to make your site not load CSS and/or JS in IE older than 11:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=8,9,11">
        <title>Page title</title>
        <!--[if !IE]>-->
 
@fhdalikhan
fhdalikhan / help.php
Created October 23, 2020 08:42
Functions to get current CPU load and memory usage under Windows and Linux.
https://www.php.net/manual/en/function.sys-getloadavg.php#118673
Function to get current CPU load as percentage value under Windows and Linux.
Note: Function is getServerLoad(). It will return a decimal value as percentage of current CPU load or NULL if something went wrong (e. g. insufficient access rights).
<?php
header("Content-Type: text/plain");
@KL13NT
KL13NT / aww.js
Last active October 6, 2023 05:11
A script to transform Animated Webp files into Webm files. Tested on Windows only. Depends on ffmpeg and libwebp. Make sure to add them to your PATH.
/**
* This script transforms animated webp files which are not widely supported yet
* to simple animated webm. Please state the source of your share this.
*
* # How this works
* This script depends on ffmpeg and libwebp provided by Google. Make sure
* they're in your PATH.
*
* The way this works is based off this answer https://askubuntu.com/a/1141049.
* It starts by extracting the input webp frames to a ./frames directory and,
@JacobBennett
JacobBennett / blog.md
Last active October 21, 2023 17:30
Clean up your Vue modules with ES6 Arrow Functions

Recently when refactoring a Vue 1.0 application, I utilized ES6 arrow functions to clean up the code and make things a bit more consistent before updating to Vue 2.0. Along the way I made a few mistakes and wanted to share the lessons I learned as well as offer a few conventions that I will be using in my Vue applications moving forward.

The best way to explain this is with an example so lets start there. I'm going to throw a rather large block of code at you here, but stick with me and we will move through it a piece at a time.

<script>

// require vue-resource...

new Vue({