Skip to content

Instantly share code, notes, and snippets.

@aaronsama
aaronsama / README.md
Last active June 15, 2016 17:03
Star rating
@mikemand
mikemand / README.md
Last active August 25, 2016 16:38
MySQL IP Address octets from binary field

From: http://dev.mysql.com/doc/refman/5.7/en/bit-functions.html#c9386

Posted by Neil Davis on April 3, 2008
Revised by Phillip Temple on September 11, 2008

If you store your ip addresses as a 32 bit unsigned integer representation instead of strings(using INET_ATON()), you can use bitwise operators to pull the octets for grouping and sorting when you need to retrieve them:

select 
ipAddress, (ipAddress >> 24) as firstOctet,
  • Modify: composer.json to use php 5.6.4 and laravel 5.3.*

  • Modify: config/app.php

  • Modify: app/Http/Kernel.php

    • replace can line with:
  • 'can' => \Illuminate\Auth\Middleware\Authorize::class,

@andre-luiz-dos-santos
andre-luiz-dos-santos / trace.coffee
Created January 19, 2017 18:56
A plugin for Vue.JS to help beginners
# Only works on named components
# Vue.use( require('src/plugins/trace') )
# npm install -g coffee-script
# coffee -bc trace.coffee
css = (color = 'black') -> "
background: #{color};
font-weight: bold;
color: white;
@jrmadsen67
jrmadsen67 / gist:5815505
Last active May 1, 2017 21:32
Next time someone asks you to take a FizzBuzz Test...
$biggest =100;
$all_numbers = range(0,$biggest);
$threes = array_fill_keys(range(3, $biggest, 3), 'Fizz');
$fives = array_fill_keys(range(5, $biggest, 5), 'Buzz');
$fifteens = array_fill_keys(range(15, $biggest, 15), 'FizzBuzz');
$all_numbers = array_replace($all_numbers, $threes, $fives, $fifteens);
var_dump($all_numbers);
// I just do a replace to transform something like users.events.inddex in UsersEventsIndex
ViewFactory::macro('component', function ($name, $data = []) {
$name = str_replace(' ', '', ucwords(str_replace('.', ' ', $name)));
return View::make('app', ['name' => $name, 'data' => $data]);
});
// In the app.js tiny little modifications to calculate the componentName
@calebporzio
calebporzio / webpack.mix.js
Created March 2, 2019 15:17
A webpack.mix.js file for writing NPM packages the way you write JS in a Laravel app.
let mix = require('laravel-mix');
mix.js('src/index.js', 'dist/foo.js').sourceMaps();
mix.webpackConfig({
output: {
libraryTarget: 'umd',
}
})
@calebporzio
calebporzio / time_travel_helper.php
Last active August 18, 2019 00:00
A little Laravel helper function for hijacking Carbon's "now()" inside a callback
<?php
// Helper usage:
// timeTravel(Carbon::parse('one year ago'), function () {...});
function timeTravel($target, $callback) {
Illuminate\Support\Carbon::setTestNow($target);
return tap($callback(), function () {
Illuminate\Support\Carbon::setTestNow();
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.21960784494876862</real>
var currencyValidator = {
format: function (number) {
return (Math.trunc(number * 1000000000000) / 1000000000000).toFixed(2)
},
parse: function (newString, oldNumber) {
var CleanParse = function (value) {
return { value: value }
}
var CurrencyWarning = function (warning, value) {
return {