Skip to content

Instantly share code, notes, and snippets.

@dillansimmons
dillansimmons / passUTM.js
Last active August 26, 2024 10:35
Pass current UTMS to in page links Javascript
// JS for grabbing utm params and parsing into url
var getRefQueryParam = function() {
var temp = {};
document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() {
var decode = function(s) {
return decodeURIComponent(s.split("+").join(" "));
};
temp[decode(arguments[1])] = decode(arguments[2]);
});
return temp;
@vmassuchetto
vmassuchetto / remote-mysqldump.sh
Created July 4, 2017 15:14
Run mysqldump remotely via SSH to create local SQL dumps
#!/bin/bash
usage() {
echo ""
echo "USAGE:"
echo ""
echo " $0 [ OPTIONS and PARAMETERS ]"
echo ""
echo "OPTIONS:"
echo ""
@mkorthof
mkorthof / clamav-freshclam
Created June 14, 2017 17:19
limit freshclam memory usage (cron)
29 */1 * * * clamav [ -x /usr/bin/freshclam ] && { ulimit -Sm 512000; ulimit -Sv 512000; ulimit -Hm 1024000; ulimit -Hv 1024000; /usr/bin/freshclam --quiet; } > /dev/null
@fourstacks
fourstacks / Taxonomy.php
Last active January 6, 2023 03:15
Pulling in Yoast SEO meta for terms using Corcel
<?php
// This model simply inherits from the base Corcel Taxonomy model.
// It allows us to set our DB connection and also implement the
// ImportsTermSeo trait (see next file)
namespace App\Models\Corcel;
use App\Wordpress\ImportsTermSeo;
@ediamin
ediamin / wpautop.js
Created February 27, 2017 09:49
JavaScript version of WordPress wpautop function
// source: https://github.com/andymantell/node-wpautop
function _autop_newline_preservation_helper (matches) {
return matches[0].replace( "\n", "<WPPreserveNewline />" );
},
function wpautop(pee, br) {
if(typeof(br) === 'undefined') {
br = true;
}
@languanghao
languanghao / left-bar.vue
Created December 22, 2016 06:56
element ui menu with vue-router
<template>
<el-menu :router="true" :default-active="activeLink">
<template v-for="rule in $router.options.routes">
<el-submenu v-if="rule.children && rule.children.length > 0"
:index="rule.path"
>
<template slot="title"><i :class="rule.icon"></i>{{ rule.title }}</template>
<el-menu-item v-for="child in rule.children" :index="rule.path + '/' + child.path">{{ child.title }}</el-menu-item>
</el-submenu>
<el-menu-item v-else
@0xjac
0xjac / private_fork.md
Last active April 18, 2025 21:18
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@gemmadlou
gemmadlou / acf-panel-config.php
Last active December 8, 2017 17:13
ACF Flexible Content (Programmatically)
<?php
return [
'group_btm_flex_default',
[
'title' => 'Page Content Builder',
'label' => 'Add content',
'location' => [
[
[
@thaliaarchi
thaliaarchi / async-scripts.ts
Created October 10, 2016 02:29
Load multiple scripts asynchronously in javascript
loadScripts([
'https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.min.js',
'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js'
], () => {
console.log('Scripts loaded');
let color = tinycolor('hsl(207, 95%, 44%)');
console.log(color);
$('body').css('background-color', color.toHexString());
});

Recovering deleted files in Ubuntu with ext4 filesystem

Recently, I deleted some files by mistake in a Ubuntu machine with an ext4 fs. These notes document the steps I took to get them back.

Important

  • this procedure assumes that the partition that contained the deleted files is different from the root partition, as that was the scenario with which I had to deal (deleted files were in my home dir). The procedure needs that the partition that contained the files is unmounted, so if the deleted files were in the root partition, the process would be a bit different (e.g. storing the fs journal in a USB stick, using a live CD/USB to boot and issue the commands, etc.)
  • if something is not clear, you need more information, etc. check the sources below

With that out the way, let's begin.