Skip to content

Instantly share code, notes, and snippets.

View johnadan's full-sized avatar
👨‍💻
Back in the office!

John McLem Adan johnadan

👨‍💻
Back in the office!
View GitHub Profile
@ktomk
ktomk / valid_utf8_bytes.php
Created October 4, 2011 19:10
filter valid utf-8 byte sequences
<?php
/**
* filter valid utf-8 byte sequences
*
* take over all valid bytes, drop an invalid sequence until first
* non-matching byte, start over at that byte.
*
* @param string $str
* @return string
*/
@gabrielhurley
gabrielhurley / openstack_translation.rst
Created June 22, 2012 00:02
Translation, Internationalization and Localization in OpenStack

Translation, Internationalization and Localization in OpenStack

OpenStack is committed to broad international support, and as such there must be an ongoing concern with making OpenStack usable for all audiences. This includes proper use of internationalization and localization tools by developers, and high-quality translations for both user-facing messages and documentation.

@mojaray2k
mojaray2k / Bootstrap 1
Created March 6, 2013 06:15
This is a fallback Script for Bootstrap CDN
//bootstrapfallback.js
//<!-- BOOTSTRAP JS WITH LOCAL FALLBACK-->
//<script type="text/javascript" src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/js/bootstrap.min.js"></script>
//<script> if(typeof($.fn.modal) === 'undefined') {document.write('<script src="//www.mysite.com/js/v/bootstrap-2.1.1.js"><\/script>')}</script>
//<!-- BOOTSTRAP CDN FALLBACK CSS-->
//<script>$(document).ready(function() {
var bodyColor = $('body').css("color"); if(bodyColor != 'rgb(51, 51, 51)') {$("head").prepend("<link rel='stylesheet' href='//www.mysite.com/css/fw/bootstrap-combined-2.1.1.css' type='text/css' media='screen'>");}
@msurguy
msurguy / DB.sql
Last active August 20, 2023 18:02
Dynamic dropdown in Laravel, let's say you have multiple drop downs (selects), you click on one and the contents of the other need to be dynamically changed. One solution is to dynamically load JSON from the API and change the dropdown dynamically depending on the user choice.
CREATE TABLE `makers` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`description` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
@hadl
hadl / microtime_diff.php
Last active March 5, 2021 04:05
PHP Microtime Diff -- Calculate a precise time difference
<?php
/**
* Calculate a precise time difference.
* @param string $start result of microtime()
* @param string $end result of microtime(); if NULL/FALSE/0/'' then it's now
* @return flat difference in seconds, calculated with minimum precision loss
*/
function microtime_diff($start, $end = null)
{
if (!$end) {
@ericlbarnes
ericlbarnes / foreach_limit.blade.php
Last active July 13, 2023 07:51
Limit a foreach with Laravel blade
@foreach (array_slice($posts->toArray(), 0, 5) as $post)
<h1>{{ $post['title'] }}</h1>
@endforeach
@Plou
Plou / projectName.local.plou
Created June 18, 2013 21:23
a virtual host example, Access-Control-Allow-Origin set to allow any request from foreign domains
## projectName
<VirtualHost *:80>
ServerName projectName.local.plou
CustomLog "/www/.logs/projectName.local.plou-access_log" combined
ErrorLog "/www/.logs/projectName.local.plou-error_log"
DocumentRoot "/www/projectName/"
Header set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, PUT, GET, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Content-Type"
</VirtualHost>
@ijy
ijy / Laravel: Blade: Limit foreach loop.php
Created June 22, 2013 23:15
A quick and easy way to limit a foreach loop in Laravel Blade.
@foreach (array_slice($posts->toArray(), 0, 5) as $post)
<h1>{{ $post['title'] }}</h1>
@endforeach
@ryansechrest
ryansechrest / php-style-guide.md
Last active July 24, 2024 05:07
PHP style guide with coding standards and best practices.

PHP Style Guide

All rules and guidelines in this document apply to PHP files unless otherwise noted. References to PHP/HTML files can be interpreted as files that primarily contain HTML, but use PHP for templating purposes.

The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

Most sections are broken up into two parts:

  1. Overview of all rules with a quick example
  2. Each rule called out with examples of do's and don'ts
@msurguy
msurguy / List.md
Last active April 30, 2024 15:14
List of open source projects made with Laravel

Other people's projects:

My projects (tutorials are on my blog at http://maxoffsky.com):