Skip to content

Instantly share code, notes, and snippets.

@jagroop
jagroop / Database.php
Created November 27, 2017 10:37
insert or update if duplicate (Bulk)
public static function insertOrUpdate($table, array $rows)
{
$first = reset($rows);
$columns = implode(',', array_map(function($value)
{
return "$value";
}, array_keys($first)));
$values = implode(',', array_map(function($row)
@spences10
spences10 / github-cheat-sheet.md
Last active March 22, 2022 17:59
GitHub Cheat Sheet

Useful Git commands

This is just stuff that I have put down that I find I use a lot of the time for my own reference.

Latest changes from repo to your machine

$ git pull
@pascalbaljet
pascalbaljet / imagick-3.4.0-PHP7-forge.sh
Last active November 26, 2020 09:10
Install Imagick 3.4.0 on PHP 7.0 server (Laravel Forge)
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
@taylorotwell
taylorotwell / gist:db67dd369b00022850b4
Last active November 16, 2021 08:33
Mac Yosemite Dev Machine Setup

XCode

  • Install XCode from App Store.
  • Open XCode and agree to terms and conditions.

XCode CLI Tools

  • xcode-select --install

Install Homebrew

SSL Cheat Sheet

Create self signed certificate:

openssl req -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout server.key -days 365 -out server.crt

Create new key:

openssl genrsa -out server.key 2048
@amochohan
amochohan / 01_Laravel 5 Simple ACL manager_Readme.md
Last active November 8, 2023 21:03
Laravel 5 Simple ACL - Protect routes by an account / role type

#Laravel 5 Simple ACL manager

Protect your routes with user roles. Simply add a 'role_id' to the User model, install the roles table and seed if you need some example roles to get going.

If the user has a 'Root' role, then they can perform any actions.

Installation

Simply copy the files across into the appropriate directories, and register the middleware in App\Http\Kernel.php

@sogko
sogko / app.js
Last active November 8, 2022 12:31
gulp + expressjs + nodemon + browser-sync
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');
@rosskevin
rosskevin / Rakefile
Last active October 28, 2015 10:41
Rakefile - less to sass a.k.a. less2sass or less2scss
# less to scss based on http://stackoverflow.com/a/19167099/2363935
namespace :convert do
task :less_to_scss do
source_glob = "assets/less/*.less"
dest_dir = "converted"
rm_r dest_dir rescue nil
mkdir_p(dest_dir)
@krisanalfa
krisanalfa / phpinfo.php
Created January 8, 2014 11:00
My custom phpinfo page
<!DOCTYPE html>
<html>
<head>
<title>PHP INFO</title>
<style type="text/css">
body {font-family: "Ubuntu Mono", "Monospace", "Monaco", "Courier New"; font-size: 12px}
</style>
<link rel="shortcut icon" href="favicon.png" type="image/x-icon" />
</head>
<body>
@kgriffs
kgriffs / sysctl.conf
Last active February 15, 2024 14:45
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
#
# See also: https://gist.github.com/kgriffs/4027835
#
# Assumes a beefy machine with lots of network bandwidth