Skip to content

Instantly share code, notes, and snippets.

@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() {}
@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 / 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 / useful.md
Created July 29, 2015 16:00
Useful iOS Development Tools
@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 / package.json
Last active December 28, 2017 13:57
React + Babelify + Watchify with Node Scripts
{
"private": true,
"name": "ReactValidation",
"version": "1.0.0",
"description": "Validates form elements.",
"repository": {
"type": "git",
"url": "git@bitbucket.org:Enijar/reactvalidation.git"
},
"dependencies": {
#!/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 / 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 / Event.js
Last active November 1, 2016 03:30
JavaScript Event System
const Event = {
events: {},
on(event, func) {
if (!this.events.hasOwnProperty(event)) {
this.events[event] = [];
}
this.events[event].push(func);
},
@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