Skip to content

Instantly share code, notes, and snippets.

View andresdhn's full-sized avatar
:electron:

Andres Hernandez andresdhn

:electron:
View GitHub Profile
@andresdhn
andresdhn / gulpfile.js
Created August 19, 2021 08:24
Shows a Gulpfile with tasks to preprocess Nunjucks
const { src, dest, series, watch } = require('gulp')
const del = require('del')
const njk = require('gulp-nunjucks-render')
const beautify = require('gulp-beautify')
function clean() {
return del(['dist'])
}
function html() {
@andresdhn
andresdhn / footer.njk
Last active August 19, 2021 08:21
Shows an example of conditional rendering in a Nunjucks Partial
@andresdhn
andresdhn / index.njk
Last active August 19, 2021 08:22
Shows a basic example of a Nunjucks templated page
{% set page_name = 'Home' %}
{% set SEO_description = 'SSG using Nunjucks and Gulp' %}
{% set SEO_keywords = 'SSG, Nunjucks, Gulp, JavaScript' %}
{% extends "layouts/layout.html" %}
{% block content %}
<div id="content">
<div class="container">
<h1>Hello World!</h1>
</div>
</div>
@andresdhn
andresdhn / layout.njk
Last active August 19, 2021 08:20
Shows a basic layout file using Nunjucks
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="/css/style.css" />
<title>My site | {{ page_name }}</title>
<meta name="keywords" content="{{ SEO_keywords }}">
@andresdhn
andresdhn / renameFiles.php
Created January 14, 2020 02:14
Rename files within multiple folders
<?php
chdir("slides");
$slides = explode("\n", shell_exec("ls"));
foreach ($slides as $slide) {
echo $slide;
if ($slide) {
chdir("$slide");
shell_exec("mv $slide.html index.html");
chdir("..");
@andresdhn
andresdhn / NoRangeForMen.py
Created March 5, 2019 01:34
This simple gist will create a Python emulator for the range() function
#
# Creating a range() emulator for my big Bro
#
#
# Mens Let's define a function where the magic happens
# @param: num => integer
# @returns: range
#
@andresdhn
andresdhn / RenameFiles.py
Created November 7, 2016 05:33
Rename files sequentially using Python
import glob, re, os
for filename in glob.glob('/Users/your-name/Documents/presentation/*.jpg'):
new_name = filename.replace("slide", "slide-")
print filename
print new_name
os.rename(filename, new_name)