Skip to content

Instantly share code, notes, and snippets.

@enijar
enijar / Image.php
Created July 11, 2016 16:52
Safe Image Upload
<?php
namespace App\Soberistas\Assets;
use Intervention\Image\Constraint;
use Intervention\Image\ImageManager;
// TODO: We might want to remove this. It was added to deal with large images.
ini_set('memory_limit', -1);
@enijar
enijar / backup.sh
Last active September 5, 2016 17:03
A work in progress, incremental backup script in Node.js
'use strict';
const fs = require('fs');
const crypto = require('crypto');
const currentDirectory = `${__dirname}/backup-tests/current`;
const backupDirectory = `${__dirname}/backup-tests/backup`;
const getFileHash = (filePath) => {
const contents = fs.readFileSync(filePath);
@enijar
enijar / colours.sh
Created September 5, 2016 11:29
Print Colours in Terminal
#!/usr/bin/env bash
for i in {0..255} ; do
printf "\x1b[38;5;${i}m%3d " "${i}"
if (( $i == 15 )) || (( $i > 15 )) && (( ($i-15) % 12 == 0 )); then
echo;
fi
done
@enijar
enijar / ssh_tasks.sh
Created August 24, 2016 08:38
Execute Set of Tasks via SSH
#!/usr/bin/env bash
ssh -i ~/path/to/ssh_key username@255.255.255.255 -T <<EOF
echo "Execute some set of tasks"
cd /path/to/some/dir
echo "Pulling from master branch..."
git pull
echo -e ""
exit
EOF
#!/usr/bin/env bash
# Resize all png images in a given directory, using pngquant.
# Usage:
# bash crushPng.sh "path/to/files/"
# Check that a path has been provided from the cli.
if [ -z "$1" ]; then
echo "A path must be provided."
@enijar
enijar / Parallax.js
Last active September 21, 2015 10:59
jQuery Parallax Class
var Parallax = function () {
/**
* @type {Parallax}
*/
var that = this;
/**
* Holds all of the elements and their callback
* functions inside objects.
@enijar
enijar / useful.md
Created July 29, 2015 16:00
Useful iOS Development Tools
@enijar
enijar / app.js
Created July 28, 2015 19:34
Angular Configuration File for Laravel
var app = angular.module('app', ['ngRoute']);
/**
* Define all routes and any global Angular scopes.
*
* Note: I am using the templateUrl property to refer to
* a URI for Laravel to pick up and serve, instead of
* loading a HTML file. This is a cleaner way to use
* templates with Angular and Laravel
*/
@enijar
enijar / errors.php
Last active August 29, 2015 14:08
Apache Error Codes
<?php
if (!function_exists('http_response_code')) {
function http_response_code($code = NULL) {
if ($code !== NULL) {
switch ($code) {
case 100: $text = 'Continue'; break;
case 101: $text = 'Switching Protocols'; break;
@enijar
enijar / Config.js
Last active August 29, 2015 14:07
Object-Oriented JavaScript
/**
* Cross-browser supported OOP JS class with methods
*/
// Create a class "Config". The self-invoking
// function avoids the pollution the global namespace
var Config = (function() {
// Construct
function Config() {}