Skip to content

Instantly share code, notes, and snippets.

@FranciscoG
FranciscoG / proj.sh
Created May 31, 2017 17:59
Bash shell function to easily switch to a known folder in my ~/projects folder. Only tested this in the OSX Terminal
# I added this to my .bashrc but you can place it in its own file if you want
# TODO: find something faster than the 'find' command
##
# recursively searches through folders (only folders) inside of my ~/projects folders
# if it only finds 1 entry, it switches to that folder. If not, it echos all found matches
# takes only 1 argument
# usage: proj my-website
function proj () {
if [ -z "$1" ]
@FranciscoG
FranciscoG / hello.sh
Created May 23, 2017 17:21
Sample all of the accents that OSX or MacOS has to offer with the `say` commant
#!/bin/bash
NAMES="$(say -v ? | sed -E 's/^([a-zA-Z-]+\s?[a-zA-Z]+).+/\1/')"
echo $NAMES
for NAME in $NAMES
do
echo $NAME
say hello -v $NAME
done
@FranciscoG
FranciscoG / createElement.js
Last active March 25, 2017 16:04
i don't know what I'm doing, please ignore all this.
function createElement(type, attributes, text, children =[]) {
if (type === 'text' && text) {
return document.createTextNode(text);
}
var el = document.createElement(type);
if (attributes) {
@FranciscoG
FranciscoG / before_prepare.js
Last active February 17, 2017 15:26
Cordova hook to swap out variables in config.xml before preparing, building, or running. Useful to set different api keys per environment (staging, qa, production, etc)
#!/usr/bin/env node
/*****************************************************************
* I'm using this hook to set environment specific variables
*
* This hooks is executed before the following commands:
* cordova prepare
* cordova platform add
* cordova build
* cordova run
(function( $ ) {
"use strict";
/**
* jQuery.videoSwap.js
* by: https://gist.github.com/FranciscoG
*
* Switches between a silent teaser video and a full video
* Uses html5 <video>
* Very very basic "mobile" support solely based on window width
*
@FranciscoG
FranciscoG / SHA256check.sh
Created July 11, 2016 02:59
OSX shell script that compares the SHA256 hash given by some source and the one provided by openssl
#!/bin/bash
# Usage:
# SHA256check.sh /path/to/file TheLongHashStringProvidedBySource
# - or enter the given hash at the prompt
PATH=$1
SITEHASH=$2
if [ "$SITEHASH" == "" ]; then
@FranciscoG
FranciscoG / timeToMs.js
Created April 19, 2016 21:11
A function which takes in a specifically formatted time string and returns milliseconds
/**
* Takes a string representing time in a specific format and
* returns the total number of milliseconds for that time
* @param {String} timeStr The time you want to convert into ms, see below for format details
* @return {Number} Total number of milliseconds
*
* For now there only 3 options:
* (h)ours, (m)inutes, (s)econds
* formatting examples:
* timeToMS( "1h 10m 5s" )
#!/bin/bash
# run a series of command line test to see if your site is secure
# based on this checklist: https://securitychecklist.org/
#
# INCOMPLETE - still working on it
#
# Todo: download nmap
# Colors
@FranciscoG
FranciscoG / alphaReverse.js
Created August 5, 2015 21:35
used to decode reversed matched strings
(function(){
function alphaInvert(str) {
var alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
var rev = alpha.slice().reverse(); // slice makes a copy of the array
var result = "";
str.split("").forEach(function(val,i,r){
result += rev[alpha.indexOf(val)]; // indexOf IE9+
});
@FranciscoG
FranciscoG / convert.sh
Last active August 29, 2015 14:22
simple shell script to convert a simple php site to flat html files using wget. Pages must end in ".php", do not use url rewriting (which shouldn't matter to you if flat HTML is your desired end result anyways).
#!/bin/bash
###########################################################################
# Change these variables to whatever site you want to grab
# and where you want it to be saved
#
targetDir=''
site=''