Skip to content

Instantly share code, notes, and snippets.

@jimitit
jimitit / debounce.js
Created July 20, 2018 16:22 — forked from luan0ap/debounce.js
Implement a job scheduler which takes in a function f and an integer n, and calls f after n milliseconds.
const debounce = (fn = () => {}, wait = 1000) => (...args) => {
const delayed = () => fn.apply(this, args)
return setTimeout(delayed, wait)
}
@jimitit
jimitit / class.database.php
Created September 6, 2017 11:29 — forked from jonashansen229/class.database.php
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";
@jimitit
jimitit / eloquent.md
Created September 8, 2016 13:17 — forked from msurguy/eloquent.md
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@jimitit
jimitit / home.blade.php
Created June 10, 2016 15:01 — forked from pedrommone/home.blade.php
Socket.io implementantion with Redis, Laravel and Node.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laravel PHP Framework</title>
<style>
</style>
<script src="https://cdn.socket.io/socket.io-1.2.1.js"></script>
@jimitit
jimitit / Wordpress Nginx Config
Created May 6, 2016 17:40 — forked from kjprince/Wordpress Nginx Config
/etc/nginx/wordpress.conf
##################################
# WORDPRESS NGINX CONFIGURATIONS
##################################
# /etc/nginx/wordpress.conf
#
# Contains a common configuration for use by nginx on a WordPress
# installation. This file should be included in any WordPress site
# nginx virtual host config located in sites-available with the following line:
#
# include /etc/nginx/wordpress.config;
@jimitit
jimitit / gist:6dec13ffe84819ae2a7a
Last active August 29, 2015 14:27 — forked from tamoyal/gist:1b7ec4d3871b343d353d
Transitioning your pem/key on an EC2 instance

Note: This is mainly useful for instances you are essentially locked out of in the case where you don't want to create a new instance.

  1. Launch a micro instance with your new key (we'll call this the "key transitioning instance"). This instance will need to be in the same availability zone ("us-east-1b", for example) as the instances you are locked out of.
  2. Make sure you can ssh in
  3. Select the instance you are locked out of and make note of the attached EBS volume ID which will look something like vol-6a844e25 and the Root Device which will look something like /dev/sda1.
  4. Stop the EC2 instance you are locked out of
  5. Go to that instance's Root Device EBS volume and detach it
  6. Re-attach the EBS volume to the key transitioning instance
  7. On the key transitioning instance, run sudo fdisk -l
  8. Note the "Device" column output from this command that is similar to the "Attachment information" which is displayed when you select the EBS volume (we'll use /dev/xvdf1 as an example). That will be yo