Skip to content

Instantly share code, notes, and snippets.

View MartelliEnrico's full-sized avatar
🏠
Working from home

Enrico Martelli MartelliEnrico

🏠
Working from home
View GitHub Profile
@nathansmith
nathansmith / 1_form-reset.scss
Last active September 8, 2019 09:33
Form Reset
// `Default font for form elements.
//----------------------------------------------------------------------------------------------------
$form-font-stack: Arial, "Liberation Sans", FreeSans, sans-serif !default;
$form-font-size: 13px !default;
// `Form Element Reset.
//----------------------------------------------------------------------------------------------------
input::ms-clear,
@msurguy
msurguy / upload.php
Last active August 29, 2015 13:56
using jquery fileAPI plugin (https://github.com/RubaXa/jquery.fileapi/) with Intervention Image class (intervention.olivervogel.net) to upload and resize images
ini_set("memory_limit","200M");
if( !empty($_SERVER['HTTP_ORIGIN']) ){
// Enable CORS
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type');
}
if( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ){
@msurguy
msurguy / Ajax-Instructions.md
Created April 4, 2014 22:52
Morris bar charts with AJAX (Laravel)

Did I hear you wanted AJAX charts instead of hard coded? You got it.

Follow this guide to integrate bar chart reports into your Laravel application with AJAX. Reports like the following come with this guide:

  • Total number of Orders by day
  • Total number of Users subscribed by day
  • etc

The library used for the charts is: http://www.oesmith.co.uk/morris.js/

How to create Swap on Linux / Ubuntu

Enable swap

sudo swapon -s

Create a 2GB file

sudo dd if=/dev/zero of=/swapfile bs=1024 count=2048k

@OllieJones
OllieJones / fullquery
Last active September 25, 2023 14:09
Fast nearest-location finder for SQL (MySQL, PostgreSQL, SQL Server)
SELECT zip, primary_city,
latitude, longitude, distance
FROM (
SELECT z.zip,
z.primary_city,
z.latitude, z.longitude,
p.radius,
p.distance_unit
* DEGREES(ACOS(LEAST(1.0, COS(RADIANS(p.latpoint))
* COS(RADIANS(z.latitude))
@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
@LoveAndHappiness
LoveAndHappiness / gulpfile.js
Last active September 24, 2016 23:13
Laravel+Polymer Gulpfile
var elixir = require('laravel-elixir');
var gulp = require('gulp');
var vulcanize = require('gulp-vulcanize');
// npm install --save-dev browser-sync gulp-vulcanize vulcanize
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
@taylorotwell
taylorotwell / gist:68f614deb9538f2e30108c2698266fda
Last active May 28, 2020 08:41
ADR out of the box for Brandon
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
@lurbas
lurbas / DuotoneColorFilter.java
Last active July 14, 2023 02:13
Duotone ColorFilter for Android
public ColorFilter duotoneColorFilter(@ColorInt int colorBlack, @ColorInt int colorWhite, float contrast) {
ColorMatrix cm = new ColorMatrix();
ColorMatrix cmBlackWhite = new ColorMatrix();
float lumR = 0.2125f;
float lumG = 0.7154f;
float lumB = 0.0721f;
float[] blackWhiteArray = new float[]{
lumR, lumG, lumB, 0, 0,
lumR, lumG, lumB, 0, 0,
@bendc
bendc / simulate-typing.js
Created September 1, 2017 08:57
Fake typing animation
const trackTime = timing => {
const now = performance.now();
if (!timing.startTime) timing.startTime = now;
const elapsed = now - timing.startTime;
const {duration} = timing;
if (duration != null && duration <= elapsed) timing.startTime = null;
return elapsed;
};
const delay = (callback, duration) => {