Skip to content

Instantly share code, notes, and snippets.

View davidhemphill's full-sized avatar
☠️
WIP

Hemp davidhemphill

☠️
WIP
View GitHub Profile
@JeffreyWay
JeffreyWay / PjaxMiddleware.php
Last active November 6, 2024 14:26
Laravel middleware for working with pjax.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class PjaxMiddleware
@adamwathan
adamwathan / v-cloak.md
Last active November 6, 2024 14:28
Useful CSS utilities for Vue.js cloaking

Handy helpers for controlling visibility of elements until Vue has compiled.

Use like:

<div v-cloak>
  <h1>
    <span class="v-cloak--inline">Loading...</span> <!-- Only displayed before compiling -->
    <span class="v-cloak--hidden">{{ post.title }}</span> <!-- Hidden until compiling is finished -->
 
<?php
use Illuminate\Support\Collection;
class Feed {
public function fetch($url = 'http://site.com/feed')
{
$feed = implode(file($url));
$xml = simplexml_load_string($feed);
# Tail Laravel and Webserver (NGINX & Apache 2) log files
# Compatible with Laravel 4 & 5
#
alias tl="ls -d /var/log/nginx/* /var/log/apache2/* storage/logs/* app/storage/logs/* storage/laravel.log | grep -v 'gz$' | grep -v '1$' | xargs tail -f"
@drakakisgeo
drakakisgeo / gist:2c756f2e6c1d0c3720e5
Created October 26, 2014 16:47
Preventing Cron Job Collision (File system lock file - Laravel indatus/dispatcher)
public function fire()
{
//// Preventing Cron Job Collision
$file = "/var/www/tick/cronlock";
$fp = fopen($file, 'r+');
if(!flock($fp, LOCK_EX | LOCK_NB)) {
$this->error('Cron is already running another task...');
exit(-1);
}
@mojaray2k
mojaray2k / jsbin.burut.html
Last active September 19, 2023 15:42
CSS only custom-styled select Todd Parker - Filament Group Inc. How this works: This styles a native select consistently cross-platform with only minimal CSS. The native select is then styled so it is essentially invisible (no appearance, border, bg) leaving only the select's text visible. There is a wrapper around the select that has the majori…
<html>
<head>
<title>Select styles with CSS only</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
background-color: #fff;
font-family: helvetica, sans-serif;
margin: 4% 10%
}
@calebd
calebd / ArrayHelpers.swift
Last active January 29, 2025 06:05
Swift Helpers
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@maramtech-sublime
maramtech-sublime / DbmigrateController.php
Created March 5, 2014 14:34 — forked from bruceoutdoors/DbmigrateController.php
PHP: Converts existing MySQL database to migrations in Laravel 4.
<?php
/* * **
*
* This script converts an existing MySQL database to migrations in Laravel 4.
*
* 1. Place this file inside app/controllers/
*
* 2. In this file, edit the index() method to customize this script to your needs.
* - inside $migrate->ignore(), you pass in an array of table
@imjakechapman
imjakechapman / app.js
Last active August 29, 2015 13:56
Conditional script loading based on declarative markup
require.config({
baseUrl: '/assets/js',
paths: {
jquery: [
'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min',
'vendor/jquery'
],
slider: 'vendor/slider',
player: 'vendor/player'
}