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 / Angular 2 + Laravel Nginx Configuration
Created March 29, 2017 14:50
Angular 2 + Laravel Nginx Configuration
server {
listen 80;
#listen [::]:80;
server_name dev.hio.com;
root /Users/jimit/Code/rl_projects/hio/api/public;
access_log /Users/jimit/Code/rl_projects/hio/api/storage/local/nginx.access.log;
error_log /Users/jimit/Code/rl_projects/hio/api/storage/local/nginx.error.log;
location / {
alias /Users/jimit/Code/rl_projects/hio/front/dist/;
try_files $uri $uri/ /index.html?$args;
@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 / FK Maker
Created July 7, 2016 06:24
FK Maker
<?php
$dsn = 'mysql:host=localhost;dbname=information_schema';
$username = 'root';
$password = 'password';
$dbh = new PDO($dsn, $username, $password);
$tableSchema = 'db_name';
$fkColumnName = 'emp_id';
$pkColumnName = 'admin_id';
$pkTableName = 'admin_login';
@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 / .txt
Created March 1, 2016 13:55
Angular + Nginx Configuration
This a dirty solution, but worked for me.
Sacrifice my 404 page, but fix the main problem.
server {
listen 0.0.0.0:12345;
location / {
root /home/zdwolfe/src/angularAWS/app;
try_files $uri $uri/ /index.html =404;
}
@jimitit
jimitit / webhook.php
Created December 15, 2015 15:03
Facebook webhook
<?php
require_once __DIR__ . '/config/facebook.php';
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/lib/utility.class.php';
use Facebook\Facebook;
use Facebook\Exceptions\FacebookResponseException;
use Facebook\Exceptions\FacebookSDKException;
use FacebookAds\Object\AdUser;
use FacebookAds\Api;
SidebarEnhancements
AdvancedNewFile
Alignment
DocBlockr
Emmet